2021-11-08 14:20:26 +00:00
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 :
2023-10-11 01:00:22 +00:00
branches : [ main, 1.x]
2022-09-01 19:30:21 +00:00
pull_request :
2023-10-11 01:00:22 +00:00
branches : [ main, 1.x]
2021-11-08 14:20:26 +00:00
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch :
2024-02-05 05:47:57 +00:00
concurrency :
2024-02-29 21:45:10 +00:00
# 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' }}
2024-08-21 23:25:00 +00:00
env :
HEAD_REF : ${{ github.head_ref }}
2021-11-08 14:20:26 +00:00
jobs :
2024-05-14 06:51:10 +00:00
# Prepares dynamic test matrix values
matrix-prep :
2023-02-17 19:56:56 +00:00
runs-on : ubuntu-latest
steps :
2023-09-16 01:18:05 +00:00
- uses : actions/checkout@v4
2024-05-14 06:51:10 +00:00
- id : bazel-version
name : Prepare 'bazel-version' matrix axis
run : |
v=$(head -n 1 .bazelversion)
m=${v::1}
a=(
"major:$m, version:\"$v\""
"major:6, version:\"6.5.0\""
)
printf -v j '{%s},' "${a[@]}"
echo "res=[${j%,}]" | tee -a $GITHUB_OUTPUT
- id : os
name : Prepare 'os' matrix axis
# Only run MacOS and Windows on main branch (not PRs) to minimize minutes (billed at 10X and 2X respectively)
2023-02-17 19:56:56 +00:00
# https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#included-storage-and-minutes
2024-05-14 06:51:10 +00:00
run : |
a=( ubuntu )
2024-08-21 23:25:00 +00:00
if [[ "${{ github.ref_name }}" == "main" ]] || [[ "$HEAD_REF" == *"macos"* ]]; then
2024-05-14 06:51:10 +00:00
a+=( macos )
fi
2024-08-21 23:25:00 +00:00
if [[ "${{ github.ref_name }}" == "main" ]] || [[ "$HEAD_REF" == *"windows"* ]]; then
2024-05-14 06:51:10 +00:00
a+=( windows )
fi
printf -v j '"%s",' "${a[@]}"
echo "res=[${j%,}]" | tee -a $GITHUB_OUTPUT
2023-02-17 19:56:56 +00:00
outputs :
2024-05-14 06:51:10 +00:00
bazel-version : ${{ steps.bazel-version.outputs.res }}
os : ${{ steps.os.outputs.res }}
2021-11-08 14:20:26 +00:00
test :
2024-05-14 06:51:10 +00:00
runs-on : ${{ matrix.os }}-latest
2022-10-26 22:05:27 +00:00
needs :
2024-05-14 06:51:10 +00:00
- matrix-prep
2022-04-27 04:07:17 +00:00
strategy :
2022-08-26 03:44:07 +00:00
fail-fast : false
2022-04-27 04:07:17 +00:00
matrix :
2024-05-14 06:51:10 +00:00
bazel-version : ${{ fromJSON(needs.matrix-prep.outputs.bazel-version) }}
2024-05-14 04:28:28 +00:00
bzlmod : [ 1 , 0 ]
2024-05-14 06:51:10 +00:00
os : ${{ fromJSON(needs.matrix-prep.outputs.os) }}
2022-04-27 04:07:17 +00:00
folder :
- "."
2023-11-19 03:00:40 +00:00
- "e2e/copy_action"
2022-08-11 23:25:51 +00:00
- "e2e/copy_to_directory"
2023-11-19 03:00:40 +00:00
- "e2e/coreutils"
2023-10-10 14:16:13 +00:00
- "e2e/external_copy_to_directory"
2023-03-10 17:37:57 +00:00
- "e2e/smoke"
2023-11-19 03:00:40 +00:00
- "e2e/write_source_files"
2022-09-13 03:52:13 +00:00
exclude :
2024-09-02 16:32:38 +00:00
# Root workspace is bzlmod-only
2024-08-20 17:37:52 +00:00
- folder : .
bzlmod : 0
2024-05-14 06:51:10 +00:00
# Don't test MacOS and Windows against secondary bazel version to minimize minutes (billed at 10X and 2X respectively)
# https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#included-storage-and-minutes
- os : macos
bazel-version :
major : 6
- os : windows
bazel-version :
major : 6
# Don't run bzlmod tests with Bazel 6 to reduce the size of the test matrix
- bazel-version :
major : 6
bzlmod : 1
2024-05-14 04:28:28 +00:00
# TODO: green up root Workspace on MacOS & Windows
- folder : .
2024-05-14 06:51:10 +00:00
os : macos
2024-05-14 04:28:28 +00:00
- folder : .
2024-05-14 06:51:10 +00:00
os : windows
2021-11-08 14:20:26 +00:00
steps :
2023-09-16 01:18:05 +00:00
- uses : actions/checkout@v4
2022-01-21 16:48:43 +00:00
- name : Mount bazel caches
2024-02-27 01:31:31 +00:00
uses : actions/cache@v4
2021-11-08 14:20:26 +00:00
with :
2022-01-21 16:48:43 +00:00
path : |
2024-05-14 06:51:10 +00:00
~/.cache/bazel-disk-cache
~/.cache/bazel-repository-cache
key : bazel-cache-${{ matrix.bazel-version.version }}-${{ matrix.bzlmod }}-${{ matrix.os }}-${{ matrix.folder }}-${{ hashFiles('.bazelrc', '.bazelversion', '.bazeliskrc', '**/BUILD', '**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', 'WORKSPACE.bazel', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}
restore-keys : bazel-cache-${{ matrix.bazel-version.version }}-${{ matrix.bzlmod }}-${{ matrix.os }}-${{ matrix.folder }}-
2022-10-26 22:05:27 +00:00
- name : Configure Bazel version
working-directory : ${{ matrix.folder }}
2024-05-14 04:28:28 +00:00
shell : bash
2023-02-17 00:59:21 +00:00
run : |
2024-05-14 04:28:28 +00:00
# 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.
2024-05-14 06:51:10 +00:00
echo "${{ matrix.bazel-version.version }}" > .bazelversion
2024-05-14 04:28:28 +00:00
# Delete all the version specific bazelrc files that are used for local development
# since the version we're testing against is dynamic. These are just symlinks and the
# root .bazelrc brings these in with try-imports. In this CI workflows, we explicitly
# bring in the version specific bazelrc file with --bazelrc when we invoke bazel.
rm ${GITHUB_WORKSPACE//\\/\/}/.aspect/bazelrc/local/*.bazelrc
# TODO: remove this block once we have Aspect CLI Windows releases
- name : Don't use Aspect CLI on Windows
2024-05-14 06:51:10 +00:00
if : matrix.os == 'windows'
2022-10-26 22:05:27 +00:00
working-directory : ${{ matrix.folder }}
2024-05-14 04:28:28 +00:00
shell : bash
run : rm -f .bazeliskrc
- name : bazel test //...
2023-02-17 19:56:56 +00:00
working-directory : ${{ matrix.folder }}
2024-05-14 04:28:28 +00:00
shell : bash
2023-02-17 19:56:56 +00:00
run : |
2024-05-14 04:28:28 +00:00
bazel \
2024-05-14 06:51:10 +00:00
--bazelrc=${GITHUB_WORKSPACE//\\/\/}/.aspect/bazelrc/bazel${{ matrix.bazel-version.major }}.bazelrc \
2024-05-14 04:28:28 +00:00
--bazelrc=${GITHUB_WORKSPACE//\\/\/}/.aspect/bazelrc/ci.bazelrc \
--bazelrc=${GITHUB_WORKSPACE//\\/\/}/.github/workflows/ci.bazelrc \
test \
2024-05-14 06:51:10 +00:00
--test_tag_filters=-skip-on-bazel${{ matrix.bazel-version.major }} \
--build_tag_filters=-skip-on-bazel${{ matrix.bazel-version.major }} \
2024-05-14 04:28:28 +00:00
--enable_bzlmod=${{ matrix.bzlmod }} \
//...
2024-05-14 06:51:10 +00:00
- name : Integration tests
2023-02-17 19:56:56 +00:00
# Don't run integration tests on Windows since they are bash scripts and Windows runs Powershell
2024-05-14 06:51:10 +00:00
if : matrix.folder == '.' && matrix.os != 'windows' && matrix.bazel-version.major != '6'
2022-03-31 00:01:16 +00:00
# Find all shell scripts within e2e, echo the filename, execute, fail on error
2023-11-15 23:07:03 +00:00
run : find e2e/*.sh -maxdepth 1 -type f -exec sh -c 'echo "\n\n------------------------------- $0 -------------------------------" && BZLMOD_FLAG=${{ steps.set_bzlmod_flag.outputs.bzlmod_flag }} "$0" || kill $PPID' \{\} \;
2024-05-14 06:51:10 +00:00
- name : Verify bcr patches
if : matrix.folder == '.' && matrix.bzlmod == '1' && matrix.os == 'ubuntu' && matrix.bazel-version.major != '6'
2023-09-27 17:26:38 +00:00
run : patch --dry-run -p1 < .bcr/patches/*.patch