fix: permit more label syntax when pre-computing outputs #1475
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [main, 2.x] | |
pull_request: | |
branches: [main, 2.x] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
concurrency: | |
# Cancel previous actions from the same PR or branch except 'main' branch. | |
# See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info. | |
group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}} | |
cancel-in-progress: ${{ github.ref_name != 'main' }} | |
jobs: | |
# matrix-prep-* steps dynamically generate a bit of JSON depending on whether our action has | |
# access to repository secrets. When running on a pull_request from a fork, the author is | |
# untrusted so the secret will be absent. Insanely complex for how simple this requirement is... | |
# inspired from | |
# https://stackoverflow.com/questions/65384420/how-to-make-a-github-action-matrix-element-conditional | |
matrix-prep-config: | |
# Prepares the 'config' axis of the test matrix | |
runs-on: ubuntu-latest | |
env: | |
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} | |
steps: | |
- id: local | |
run: echo "config=local" >> $GITHUB_OUTPUT | |
- id: rbe | |
run: echo "config=rbe" >> $GITHUB_OUTPUT | |
# Don't run RBE if there is no API token which is the case on forks | |
if: ${{ env.BUILDBUDDY_API_KEY != '' }} | |
outputs: | |
# Will look like ["local", "rbe"] | |
configs: ${{ toJSON(steps.*.outputs.config) }} | |
matrix-prep-bazelversion: | |
# Prepares the 'bazelversion' axis of the test matrix | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- id: bazel_6 | |
run: echo "bazelversion=$(head -n 1 .bazelversion)" >> $GITHUB_OUTPUT | |
- id: bazel_7 | |
run: echo "bazelversion=7.0.0-pre.20230530.3" >> $GITHUB_OUTPUT | |
outputs: | |
# Will look like ["<version from .bazelversion>", "7.0.0-pre.*", "6.3.1"] | |
bazelversions: ${{ toJSON(steps.*.outputs.bazelversion) }} | |
matrix-prep-os: | |
# Prepares the 'os' axis of the test matrix | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- id: linux | |
run: echo "os=ubuntu-latest" >> $GITHUB_OUTPUT | |
- id: macos | |
run: echo "os=macos-latest" >> $GITHUB_OUTPUT | |
# Only run on main branch (not PRs) to minimize macOS minutes (billed at 10X) | |
# https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#included-storage-and-minutes | |
if: ${{ github.ref == 'refs/heads/main' }} | |
outputs: | |
# Will look like ["ubuntu-latest", "macos-latest"] | |
os: ${{ toJSON(steps.*.outputs.os) }} | |
test: | |
# The type of runner that the job will run on | |
runs-on: ${{ matrix.os }} | |
needs: | |
- matrix-prep-config | |
- matrix-prep-bazelversion | |
- matrix-prep-os | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ${{ fromJSON(needs.matrix-prep-os.outputs.os) }} | |
config: ${{ fromJSON(needs.matrix-prep-config.outputs.configs) }} | |
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions) }} | |
bzlmodEnabled: [true, false] | |
folder: | |
- '.' | |
- 'e2e/bzlmod' | |
- 'e2e/external_dep' | |
- 'e2e/external_dep/app' | |
- 'e2e/worker' | |
- 'e2e/workspace' | |
exclude: | |
# Don't test MacOS with Bazel 7 to minimize MacOS minutes (billed at 10X) | |
- os: macos-latest | |
bazelversion: 7.0.0-pre.20230530.3 | |
# Don't test RBE with on MacOS (not configured) | |
- os: macos-latest | |
config: rbe | |
# TODO(https://github.com/aspect-build/rules_ts/issues/432): re-enable | |
- folder: e2e/bzlmod | |
config: rbe | |
# TODO: combine bzlmod and workspace into a single 'smoke' e2e | |
- folder: e2e/bzlmod | |
bzlmodEnabled: false | |
- folder: e2e/workspace | |
bzlmodEnabled: true | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
# Cache build and external artifacts so that the next ci build is incremental. | |
# Because github action caches cannot be updated after a build, we need to | |
# store the contents of each build in a unique cache key, then fall back to loading | |
# it on the next ci run. We use hashFiles(...) in the key and restore-keys- with | |
# the prefix to load the most recent cache for the branch on a cache miss. You | |
# should customize the contents of hashFiles to capture any bazel input sources, | |
# although this doesn't need to be perfect. If none of the input sources change | |
# then a cache hit will load an existing cache and bazel won't have to do any work. | |
# In the case of a cache miss, you want the fallback cache to contain most of the | |
# previously built artifacts to minimize build time. The more precise you are with | |
# hashFiles sources the less work bazel will have to do. | |
- name: Mount bazel caches | |
uses: actions/cache@v3 | |
with: | |
path: | | |
"~/.cache/bazel" | |
"~/.cache/bazel-repo" | |
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }} | |
restore-keys: bazel-cache- | |
- name: Configure Bazel version | |
working-directory: ${{ matrix.folder }} | |
# Overwrite the .bazelversion instead of using USE_BAZEL_VERSION so that Bazelisk | |
# still bootstraps Aspect CLI from configuration in .bazeliskrc. Aspect CLI will | |
# then use .bazelversion to determine which Bazel version to use | |
run: echo "${{ matrix.bazelversion }}" > .bazelversion | |
- name: Set bzlmod flag | |
# Store the --enable_bzlmod flag that we add to the test command below | |
# only when we're running bzlmod in our test matrix. | |
id: set_bzlmod_flag | |
if: matrix.bzlmodEnabled | |
run: echo "bzlmod_flag=--enable_bzlmod" >> $GITHUB_OUTPUT | |
- name: Write RBE credentials | |
if: ${{ matrix.config == 'rbe' }} | |
working-directory: ${{ matrix.folder }} | |
run: | | |
touch $HOME/.bazelrc | |
chmod 0600 $HOME/.bazelrc | |
echo "build --remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY" > $HOME/.bazelrc | |
env: | |
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} | |
- name: bazel test //... | |
env: | |
# Bazelisk will download bazel to here, ensure it is cached between runs. | |
XDG_CACHE_HOME: ~/.cache/bazel-repo | |
working-directory: ${{ matrix.folder }} | |
run: | | |
bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc \ | |
--bazelrc=.bazelrc \ | |
test \ | |
--config=${{ matrix.config }} \ | |
//... \ | |
${{ steps.set_bzlmod_flag.outputs.bzlmod_flag }} | |
test-worker: | |
runs-on: ubuntu-latest | |
needs: | |
- matrix-prep-bazelversion | |
strategy: | |
fail-fast: false | |
matrix: | |
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions) }} | |
exclude: | |
- bazelversion: 7.0.0-pre.20230530.3 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Configure Bazel version | |
working-directory: e2e/test | |
# Overwrite the .bazelversion instead of using USE_BAZEL_VERSION so that Bazelisk | |
# still bootstraps Aspect CLI from configuration in .bazeliskrc. Aspect CLI will | |
# then use .bazelversion to determine which Bazel version to use | |
run: echo "${{ matrix.bazelversion }}" > .bazelversion | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: '7.14.2' | |
- name: Setup bats | |
uses: mig4/setup-bats@v1 | |
with: | |
bats-version: '1.8.2' | |
- name: Setup bats helpers | |
uses: brokenpip3/[email protected] | |
with: | |
support-path: /usr/lib/bats/bats-support | |
support-version: '0.3.0' | |
assert-path: /usr/lib/bats/bats-assert | |
assert-version: '2.1.0' | |
- name: bats -r . | |
working-directory: e2e/test | |
run: | | |
echo "import $GITHUB_WORKSPACE/.github/workflows/ci.bazelrc" > .bazelrc | |
bats -r . | |
- name: bats -r . --noexperimental_allow_unresolved_symlinks | |
working-directory: e2e/test | |
run: | | |
echo "import $GITHUB_WORKSPACE/.github/workflows/ci.bazelrc" > .bazelrc | |
echo "build --noexperimental_allow_unresolved_symlinks" >> .bazelrc | |
bats -r . |