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:
|
|
|
|
branches: [main]
|
2022-09-01 19:30:21 +00:00
|
|
|
pull_request:
|
2021-11-08 14:20:26 +00:00
|
|
|
branches: [main]
|
|
|
|
|
|
|
|
# Allows you to run this workflow manually from the Actions tab
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
2022-10-26 22:05:27 +00:00
|
|
|
# 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
|
2022-08-31 21:05:11 +00:00
|
|
|
# https://stackoverflow.com/questions/65384420/how-to-make-a-github-action-matrix-element-conditional
|
2022-10-26 22:05:27 +00:00
|
|
|
|
|
|
|
matrix-prep-config:
|
|
|
|
# Prepares the 'config' axis of the test matrix
|
2022-08-31 21:05:11 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
|
|
ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }}
|
|
|
|
steps:
|
|
|
|
- id: local
|
2022-10-28 13:59:37 +00:00
|
|
|
run: echo "config=local" >> $GITHUB_OUTPUT
|
2022-10-26 22:05:27 +00:00
|
|
|
- id: rbe
|
2022-10-28 13:59:37 +00:00
|
|
|
run: echo "config=rbe" >> $GITHUB_OUTPUT
|
2022-10-26 22:05:27 +00:00
|
|
|
# Don't run RBE if there are no EngFlow creds which is the case on forks
|
|
|
|
if: ${{ env.ENGFLOW_PRIVATE_KEY != '' }}
|
2022-08-31 21:05:11 +00:00
|
|
|
outputs:
|
|
|
|
# Will look like '["local", "rbe"]'
|
|
|
|
configs: ${{ toJSON(steps.*.outputs.config) }}
|
|
|
|
|
2022-10-26 22:05:27 +00:00
|
|
|
matrix-prep-bazelversion:
|
|
|
|
# Prepares the 'bazelversion' axis of the test matrix
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- id: bazel_6
|
2022-10-28 13:59:37 +00:00
|
|
|
run: echo "bazelversion=$(head -n 1 .bazelversion)" >> $GITHUB_OUTPUT
|
2022-10-26 22:05:27 +00:00
|
|
|
- id: bazel_5
|
2023-05-08 14:52:38 +00:00
|
|
|
run: echo "bazelversion=5.4.0" >> $GITHUB_OUTPUT
|
2022-10-26 22:05:27 +00:00
|
|
|
outputs:
|
2023-05-08 14:52:38 +00:00
|
|
|
# Will look like '["6.0.0", "5.4.0"]'
|
2022-10-26 22:05:27 +00:00
|
|
|
bazelversions: ${{ toJSON(steps.*.outputs.bazelversion) }}
|
|
|
|
|
2023-02-17 19:56:56 +00:00
|
|
|
matrix-prep-os:
|
|
|
|
# Prepares the 'os' axis of the test matrix
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- id: linux
|
|
|
|
run: echo "os=ubuntu-latest" >> $GITHUB_OUTPUT
|
|
|
|
- id: macos
|
|
|
|
run: echo "os=macos-latest" >> $GITHUB_OUTPUT
|
|
|
|
# Only run on main branch (or PR branches that contain 'macos') 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' || contains(github.ref, 'macos') }}
|
|
|
|
- id: windows
|
|
|
|
run: echo "os=windows-latest" >> $GITHUB_OUTPUT
|
|
|
|
# Only run on main branch (or PR branches that contain 'windows') to minimize Windows minutes (billed at 2X)
|
|
|
|
# https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#included-storage-and-minutes
|
2023-03-11 01:15:52 +00:00
|
|
|
if: ${{ github.ref == 'refs/heads/main' || contains(github.head_ref, 'windows') }}
|
2023-02-17 19:56:56 +00:00
|
|
|
outputs:
|
|
|
|
# Will look like ["ubuntu-latest", "macos-latest", "windows-latest"]
|
|
|
|
os: ${{ toJSON(steps.*.outputs.os) }}
|
|
|
|
|
2021-11-08 14:20:26 +00:00
|
|
|
test:
|
|
|
|
# The type of runner that the job will run on
|
2023-02-17 19:56:56 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
2022-10-26 22:05:27 +00:00
|
|
|
|
|
|
|
needs:
|
|
|
|
- matrix-prep-config
|
|
|
|
- matrix-prep-bazelversion
|
2023-02-17 19:56:56 +00:00
|
|
|
- matrix-prep-os
|
2021-11-08 14:20:26 +00:00
|
|
|
|
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:
|
2022-10-26 22:05:27 +00:00
|
|
|
config: ${{ fromJSON(needs.matrix-prep-config.outputs.configs) }}
|
|
|
|
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions) }}
|
2023-02-17 19:56:56 +00:00
|
|
|
os: ${{ fromJSON(needs.matrix-prep-os.outputs.os) }}
|
2023-03-10 17:37:57 +00:00
|
|
|
bzlmodEnabled: [true, false]
|
2022-04-27 04:07:17 +00:00
|
|
|
folder:
|
|
|
|
- "."
|
2023-03-10 17:37:57 +00:00
|
|
|
- "e2e/coreutils"
|
2022-08-11 23:25:51 +00:00
|
|
|
- "e2e/copy_to_directory"
|
2023-03-10 17:37:57 +00:00
|
|
|
- "e2e/smoke"
|
2022-09-13 03:52:13 +00:00
|
|
|
exclude:
|
2023-03-10 17:37:57 +00:00
|
|
|
# this e2e meant to work under bzlmod
|
|
|
|
- bzlmodEnabled: false
|
|
|
|
folder: bzlmod_write_source_files_external
|
|
|
|
|
|
|
|
# Don't test Bazel 5.3 with bzlmod. (Unrecognized option: --enable_bzlmod)
|
|
|
|
- bzlmodEnabled: true
|
2023-05-08 14:52:38 +00:00
|
|
|
bazelversion: 5.4.0
|
2023-02-17 19:56:56 +00:00
|
|
|
# Don't test MacOS with RBE to minimize MacOS minutes (billed at 10X)
|
|
|
|
- config: rbe
|
|
|
|
os: macos-latest
|
|
|
|
# Don't test MacOS with Bazel 5 to minimize MacOS minutes (billed at 10X)
|
2023-05-08 14:52:38 +00:00
|
|
|
- bazelversion: 5.4.0
|
2023-02-17 19:56:56 +00:00
|
|
|
os: macos-latest
|
|
|
|
# Don't test Windows with RBE to minimize Windows minutes (billed at 2X)
|
|
|
|
- config: rbe
|
|
|
|
os: windows-latest
|
|
|
|
# Don't test Windows with Bazel 5 to minimize Windows minutes (billed at 2X)
|
2023-05-08 14:52:38 +00:00
|
|
|
- bazelversion: 5.4.0
|
2023-02-17 19:56:56 +00:00
|
|
|
os: windows-latest
|
|
|
|
# TODO: fix or disable the following build & test on Windows
|
|
|
|
# //lib/tests/coreutils:test_sha256sum FAILED in 2 out of 2 in 0.2s
|
|
|
|
# //lib/tests/coreutils:test_sha512sum FAILED in 2 out of 2 in 0.2s
|
|
|
|
# //docs:update_0_test FAILED TO BUILD
|
|
|
|
# //docs:update_10_test FAILED TO BUILD
|
|
|
|
# //docs:update_11_test FAILED TO BUILD
|
|
|
|
# //docs:update_12_test FAILED TO BUILD
|
|
|
|
# //docs:update_13_test FAILED TO BUILD
|
|
|
|
- folder: .
|
|
|
|
os: windows-latest
|
2022-04-27 04:07:17 +00:00
|
|
|
|
2021-11-08 14:20:26 +00:00
|
|
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
|
|
steps:
|
2023-02-17 19:56:56 +00:00
|
|
|
# Checks-out your repository under ${{ github.workspace }} , so your job can access it
|
2022-06-10 20:00:59 +00:00
|
|
|
- uses: actions/checkout@v3
|
2022-10-26 22:05:27 +00:00
|
|
|
|
2022-01-21 16:48:43 +00:00
|
|
|
- name: Mount bazel caches
|
2022-06-10 20:00:44 +00:00
|
|
|
uses: actions/cache@v3
|
2021-11-08 14:20:26 +00:00
|
|
|
with:
|
2022-01-21 16:48:43 +00:00
|
|
|
path: |
|
2022-08-04 00:05:22 +00:00
|
|
|
~/.cache/bazel
|
|
|
|
~/.cache/bazel-repo
|
2022-01-21 16:48:43 +00:00
|
|
|
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
|
|
|
|
restore-keys: bazel-cache-
|
2022-10-26 22:05:27 +00:00
|
|
|
|
|
|
|
- name: Configure Bazel version
|
2023-02-17 19:56:56 +00:00
|
|
|
if: ${{ matrix.os != 'windows-latest' }}
|
2022-10-26 22:05:27 +00:00
|
|
|
working-directory: ${{ matrix.folder }}
|
2022-11-12 15:31:19 +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
|
2023-02-17 00:59:21 +00:00
|
|
|
# then use .bazelversion to determine which Bazel version to use.
|
|
|
|
# Also delete the .aspect/bazelrc/bazel6.bazelrc file if we are not testing
|
|
|
|
# against Bazel 6 which has a try-import in the root .bazelrc for local development.
|
|
|
|
run: |
|
|
|
|
BAZEL_VERSION=${{ matrix.bazelversion }}
|
|
|
|
echo "${{ matrix.bazelversion }}" > .bazelversion
|
|
|
|
if [ ${BAZEL_VERSION::1} != "6" ]; then rm -f .aspect/bazelrc/bazel6.bazelrc; fi
|
2022-10-26 22:05:27 +00:00
|
|
|
|
2023-02-17 19:56:56 +00:00
|
|
|
- name: Configure Bazel version (Windows)
|
|
|
|
if: ${{ matrix.os == 'windows-latest' }}
|
|
|
|
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.
|
|
|
|
# Also delete the .aspect/bazelrc/bazel6.bazelrc file if we are not testing
|
|
|
|
# against Bazel 6 which has a try-import in the root .bazelrc for local development.
|
|
|
|
run: |
|
|
|
|
echo "${{ matrix.bazelversion }}" > .bazelversion
|
|
|
|
$BAZEL_MAJOR_VERSION = "${{ matrix.bazelversion }}".substring(0, 1)
|
|
|
|
if ($BAZEL_MAJOR_VERSION -ne "6") {
|
|
|
|
rm -Force .aspect/bazelrc/bazel6.bazelrc
|
|
|
|
}
|
|
|
|
|
2023-03-10 17:37:57 +00:00
|
|
|
- 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
|
2023-03-11 00:31:54 +00:00
|
|
|
|
2022-08-18 21:18:33 +00:00
|
|
|
- name: Write engflow credentials
|
|
|
|
if: ${{ matrix.config == 'rbe' }}
|
|
|
|
working-directory: ${{ matrix.folder }}
|
|
|
|
run: |
|
2022-08-22 14:07:00 +00:00
|
|
|
touch engflow.crt engflow.key
|
|
|
|
chmod 0600 engflow.crt engflow.key
|
2022-08-18 21:18:33 +00:00
|
|
|
echo "$ENGFLOW_CLIENT_CRT" > engflow.crt
|
|
|
|
echo "$ENGFLOW_PRIVATE_KEY" > engflow.key
|
|
|
|
env:
|
|
|
|
ENGFLOW_CLIENT_CRT: ${{ secrets.ENGFLOW_CLIENT_CRT }}
|
|
|
|
ENGFLOW_PRIVATE_KEY: ${{ secrets.ENGFLOW_PRIVATE_KEY }}
|
2022-10-26 22:05:27 +00:00
|
|
|
|
2021-11-08 14:20:26 +00:00
|
|
|
- name: bazel test //...
|
2023-02-17 19:56:56 +00:00
|
|
|
if: ${{ matrix.os != 'windows-latest' }}
|
2022-10-26 22:05:27 +00:00
|
|
|
working-directory: ${{ matrix.folder }}
|
2023-02-17 00:59:21 +00:00
|
|
|
run: |
|
|
|
|
BAZEL_VERSION=${{ matrix.bazelversion }}
|
2023-02-17 19:56:56 +00:00
|
|
|
bazel --bazelrc=${{ github.workspace }}/.aspect/bazelrc/ci.bazelrc \
|
|
|
|
--bazelrc=${{ github.workspace }}/.github/workflows/ci.bazelrc \
|
|
|
|
--bazelrc=${{ github.workspace }}/.aspect/bazelrc/bazel${BAZEL_VERSION::1}.bazelrc \
|
2023-02-17 00:59:21 +00:00
|
|
|
--bazelrc=.bazelrc \
|
|
|
|
test --config=${{ matrix.config }} //...
|
2021-11-08 14:20:26 +00:00
|
|
|
env:
|
|
|
|
# Bazelisk will download bazel to here
|
|
|
|
XDG_CACHE_HOME: ~/.cache/bazel-repo
|
2022-10-26 22:05:27 +00:00
|
|
|
|
2023-02-17 19:56:56 +00:00
|
|
|
- name: bazel test //... (Windows)
|
|
|
|
# A different run command is needed on Windows to account for differences between bash and Powershell
|
|
|
|
if: ${{ matrix.os == 'windows-latest' }}
|
|
|
|
working-directory: ${{ matrix.folder }}
|
|
|
|
run: |
|
|
|
|
$BAZEL_MAJOR_VERSION = "${{ matrix.bazelversion }}".substring(0, 1)
|
|
|
|
bazel --bazelrc=${{ github.workspace }}/.aspect/bazelrc/ci.bazelrc `
|
|
|
|
--bazelrc=${{ github.workspace }}/.github/workflows/ci.bazelrc `
|
|
|
|
--bazelrc=${{ github.workspace }}/.aspect/bazelrc/bazel$BAZEL_MAJOR_VERSION.bazelrc `
|
|
|
|
--bazelrc=.bazelrc `
|
2023-03-12 02:36:10 +00:00
|
|
|
${{ steps.set_bzlmod_flag.outputs.bzlmod_flag }} `
|
2023-02-17 19:56:56 +00:00
|
|
|
test --config=${{ matrix.config }} //...
|
|
|
|
env:
|
|
|
|
# Bazelisk will download bazel to here
|
|
|
|
XDG_CACHE_HOME: ~/.cache/bazel-repo
|
|
|
|
|
2022-03-31 00:01:16 +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
|
|
|
|
if: ${{ matrix.folder == '.' && matrix.os != 'windows-latest' }}
|
2022-03-31 00:01:16 +00:00
|
|
|
# Find all shell scripts within e2e, echo the filename, execute, fail on error
|
|
|
|
run: find e2e/*.sh -maxdepth 1 -type f -exec sh -c 'echo "\n\n------------------------------- $0 -------------------------------" && "$0" || kill $PPID' \{\} \;
|