-
-
Notifications
You must be signed in to change notification settings - Fork 156
134 lines (121 loc) · 4.95 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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]
pull_request:
branches: [main]
# 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-bazelversion:
# Prepares the 'bazelversion' axis of the test matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: bazel_7
run: echo "bazelversion=$(head -n 1 .bazelversion)" >> $GITHUB_OUTPUT
- id: bazel_6
run: echo "bazelversion=6.4.0" >> $GITHUB_OUTPUT
outputs:
# Will look like ["<version from .bazelversion>", "6.4.0"]
bazelversions: ${{ toJSON(steps.*.outputs.bazelversion) }}
matrix-prep-os:
# Prepares the 'os' axis of the test matrix
runs-on: ubuntu-latest
env:
TC_CLOUD_TOKEN: ${{ secrets.TC_CLOUD_TOKEN }}
steps:
- id: linux
run: echo "os=ubuntu-latest" >> $GITHUB_OUTPUT
- id: macos
run: echo "os=macos-latest" >> $GITHUB_OUTPUT
# Don't run MacOS if there is no TestContainers API token which is the case on forks. We need it for container tests.
if: ${{ env.TC_CLOUD_TOKEN != '' }}
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-bazelversion
- matrix-prep-os
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(needs.matrix-prep-os.outputs.os) }}
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions) }}
folder:
- .
- e2e/custom_registry
- e2e/wasm
- e2e/smoke
- e2e/crane_as_registry
- e2e/pull
bzlmodEnabled: [true, false]
exclude:
# macos is expensive (billed at 10X) so don't test these
- os: macos-latest
folder: e2e/custom_registry
- os: macos-latest
folder: e2e/wasm
- os: macos-latest
folder: e2e/crane_as_registry
- os: macos-latest
folder: e2e/pull
- os: macos-latest
bazelversion: 6.4.0
# e2e/pull is bzlmod only but it has test for both cases.
- folder: e2e/pull
bzlmodEnabled: false
# TODO: fix
- folder: e2e/custom_registry
bzlmodEnabled: true
# TODO: fix
- folder: e2e/wasm
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
- name: Mount bazel caches
uses: actions/cache@v3
with:
path: |
~/.cache/bazel-repo
key: bazel-cache-${{ matrix.os }}-${{ matrix.folder }}-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
restore-keys: |
bazel-cache-${{ matrix.os }}-${{ matrix.folder }}
bazel-cache-${{ matrix.os }}
bazel-cache-
- 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: Configure Bazel version
working-directory: ${{ matrix.folder }}
run: echo "${{ matrix.bazelversion }}" > .bazelversion
- name: Configure TestContainers cloud
if: ${{ matrix.os == 'macos-latest' }}
uses: atomicjar/testcontainers-cloud-setup-action@main
with:
wait: true
token: ${{ secrets.TC_CLOUD_TOKEN }}
- name: Configure Remote Docker Host
if: ${{ matrix.os == 'macos-latest' }}
run: echo "DOCKER_HOST=$(grep 'tc.host' ~/.testcontainers.properties | cut -d '=' -f2 | xargs)" >> $GITHUB_ENV
- name: bazel test //...
working-directory: ${{ matrix.folder }}
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.bazelrc test ${{ steps.set_bzlmod_flag.outputs.bzlmod_flag }} //...