Skip to content

Commit 4e7878e

Browse files
committed
clean up build.yml
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent 7de207d commit 4e7878e

File tree

1 file changed

+43
-38
lines changed

1 file changed

+43
-38
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,62 +23,64 @@ env:
2323
GO_VERSION: '1.21.10'
2424

2525
jobs:
26-
test-on-codebuild:
27-
if: github.repository == 'awslabs/soci-snapshotter'
28-
runs-on: codebuild-soci-snapshotter-instance-dev-new-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.os }}
26+
setup:
27+
# This job sets up the runners to be used in the matrix for the build workflow.
28+
# It provides a list of available runners with stable, human-friendly names and a mapping
29+
# from those names to the actual `runs-on` value for each runner type. This allows us to
30+
# use codebuild-hosted runners for awslabs/soci-snapshotter without requiring forks to also
31+
# have codebuild-hosted runners.
32+
#
33+
# If you want to use codebuild runners for your personal fork, follow the instructions to set
34+
# up a codebuild project. https://docs.aws.amazon.com/codebuild/latest/userguide/action-runner.html
35+
# Then, replace 'soci-snapshotter-instance' with the name of the project you created.
36+
name: Setup Build Matrix
37+
runs-on: ubuntu-latest
38+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'awslabs/soci-snapshotter'
2939
strategy:
3040
matrix:
31-
os: [arm-3.0-large]
32-
timeout-minutes: 15
41+
# We're using a matrix with a single entry so that we can define some config as YAML rather than
42+
# having to write escaped json in a string.
43+
include:
44+
- use-codebuild: ${{ github.repository_owner == 'coderbirju' }}
45+
runs-on-names-cb: [ubuntu-x86, al2-arm]
46+
runs-on-names: [ubuntu]
47+
runner-labels:
48+
ubuntu: ubuntu-22.04
49+
ubuntu-x86: "codebuild-soci-snapshotter-instance-dev-new-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-7.0-xlarge"
50+
al2-arm: "codebuild-soci-snapshotter-instance-dev-new-${{ github.run_id }}-${{ github.run_attempt }}-arm-3.0-large"
51+
outputs:
52+
available-runners: ${{ matrix.use-codebuild && toJSON(matrix.runs-on-names-cb) || toJSON(matrix.runs-on-names) }}
53+
runner-labels: ${{ toJSON(matrix.runner-labels) }}
3354
steps:
34-
- uses: actions/checkout@v4
35-
- uses: actions/setup-go@v5
36-
with:
37-
go-version: ${{ env.GO_VERSION }}
38-
- run: make
39-
- run: make test
55+
- name: Dump Config
56+
run: echo '${{ toJSON(matrix) }}'
4057

41-
test-on-fork:
42-
if: github.repository != 'awslabs/soci-snapshotter'
43-
runs-on: codebuild-soci-snapshotter-instance-dev-new-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.os }}
58+
59+
test:
60+
needs: setup
61+
runs-on: ${{ fromJSON(needs.setup.outputs.runner-labels)[matrix.os] }}
4462
strategy:
4563
matrix:
46-
os: [arm-3.0-large]
64+
os: ${{ fromJSON(needs.setup.outputs.available-runners) }}
4765
timeout-minutes: 15
4866
steps:
4967
- uses: actions/checkout@v4
5068
- uses: actions/setup-go@v5
5169
with:
5270
go-version: ${{ env.GO_VERSION }}
53-
- run: dnf list --installed
54-
- run: dnf install zlib-static.aarch64 -y
71+
- name: Install zlib static on AL2
72+
if: matrix.os == 'al2-arm'
73+
run: dnf install zlib-static.aarch64 -y
5574
- run: make
5675
- run: make test
5776

58-
integration-on-codebuild:
59-
if: github.repository == 'awslabs/soci-snapshotter'
60-
runs-on: codebuild-soci-snapshotter-instance-dev-new-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-7.0-xlarge
61-
timeout-minutes: 40
62-
strategy:
63-
fail-fast: false
64-
matrix:
65-
containerd: ["1.6.30", "1.7.14"]
66-
env:
67-
DOCKER_BUILD_ARGS: "CONTAINERD_VERSION=${{ matrix.containerd }}"
68-
steps:
69-
- uses: actions/checkout@v4
70-
- uses: actions/setup-go@v5
71-
with:
72-
go-version: ${{ env.GO_VERSION }}
73-
- run: make integration
74-
75-
integration-on-fork:
76-
if: github.repository != 'awslabs/soci-snapshotter'
77-
runs-on: codebuild-soci-snapshotter-instance-dev-new-${{ github.run_id }}-${{ github.run_attempt }}-ubuntu-7.0-xlarge
77+
integration:
78+
needs: setup
79+
runs-on: ${{ fromJSON(needs.setup.outputs.runner-labels)[matrix.os] }}
7880
timeout-minutes: 40
7981
strategy:
80-
fail-fast: false
8182
matrix:
83+
os: ${{ fromJSON(needs.setup.outputs.available-runners) }}
8284
containerd: ["1.6.30", "1.7.14"]
8385
env:
8486
DOCKER_BUILD_ARGS: "CONTAINERD_VERSION=${{ matrix.containerd }}"
@@ -87,4 +89,7 @@ jobs:
8789
- uses: actions/setup-go@v5
8890
with:
8991
go-version: ${{ env.GO_VERSION }}
92+
- name: Install zlib static on AL2
93+
if: matrix.os == 'al2-arm'
94+
run: dnf install zlib-static.aarch64 -y
9095
- run: make integration

0 commit comments

Comments
 (0)