Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ jobs:
with:
version: 0.15.14
args: format --check --exclude testdata

build_release_artifacts:
name: Build release artifacts
uses: ./.github/workflows/release_build_artifacts.yaml
secrets: inherit
7 changes: 3 additions & 4 deletions .github/workflows/release_build_artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
name: "Release: Build Artifacts"

on:
pull_request:
workflow_call:
inputs:
ref:
description: "The git ref (e.g. release tag) to build"
required: true
description: "The git ref (e.g. release tag) to build. Defaults to the selected ref."
required: false
type: string
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -132,7 +131,7 @@ jobs:
env:
INPUT_REF: ${{ inputs.ref }}
# ${INPUT_REF:+...} expands to the --stamp and --embed_label flags only
# when INPUT_REF is non-empty (release builds, not pull_request builds).
# when INPUT_REF is non-empty (release builds, not CI builds).
run: >-
bazel build
${INPUT_REF:+--stamp "--embed_label=$INPUT_REF"}
Expand Down
15 changes: 13 additions & 2 deletions tests/workflows/release_build_artifacts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,23 @@ def test_matrix_matches_dev_platforms():


def test_workflow_is_safe_for_presubmit():
"""Verifies that release_build_artifacts.yaml is read-only and never publishes."""
"""Verifies that release_build_artifacts.yaml is read-only, never publishes,
and is called by ci.yaml.
"""
workflow = _load_workflow()

# PyYAML parses unquoted `on:` as boolean True in YAML 1.1.
triggers = workflow.get("on") or workflow.get(True, {})
assert "pull_request" in triggers
assert set(triggers.keys()) == {"workflow_call", "workflow_dispatch"}
assert not triggers["workflow_call"]["inputs"]["ref"].get("required", False)

ci_workflow = _load_workflow("ci.yaml")
ci_triggers = ci_workflow.get("on") or ci_workflow.get(True, {})
assert "pull_request" in ci_triggers
assert "push" in ci_triggers
ci_job = ci_workflow["jobs"]["build_release_artifacts"]
assert ci_job["uses"] == "./.github/workflows/release_build_artifacts.yaml"
assert ci_job.get("secrets") == "inherit"

assert workflow.get("permissions") == {"contents": "read"}

Expand Down
Loading