Skip to content

Commit 1567015

Browse files
authored
ci: fix using sequences in job names (#980)
* ci: consolidate runner selection * ci: fix execution of integration tests * ci: make build-push and integration-test symmetrical * ci: use toJson in inputs that can be strings or arrays * ci: make sure we keep to our own conventions * ci: correct for array rendering * ci: process linter feedback
1 parent 4c4130c commit 1567015

File tree

6 files changed

+54
-35
lines changed

6 files changed

+54
-35
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ permissions: {}
1414

1515
jobs:
1616
build-push-test:
17-
name: 🛠️ Build → Push → Test (🍨 ${{ matrix.flavor }})
17+
name: Build → Push → Test (🍨 ${{ matrix.flavor }})
1818
strategy:
1919
matrix:
2020
flavor: [cpp, rust]

.github/workflows/wc-build-push-test.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,53 @@ on:
99
required: true
1010
type: string
1111
image-name:
12-
description: "Name of the Docker image to build, without registry or tag. E.g. 'my-image' or 'my-org/my-image'"
12+
description: >-
13+
Name of the Docker image to build, without registry or tag.
14+
15+
Examples:
16+
'my-image'
17+
'my-org/my-image'
1318
required: true
1419
type: string
1520
devcontainer-metadata-file:
16-
description: "Path to a JSON file containing devcontainer metadata to add as a label to the built image"
21+
description: >-
22+
Path to a JSON file containing devcontainer metadata to add as a label to the built image.
23+
24+
Examples:
25+
'.devcontainer/devcontainer-metadata.json'
26+
'.devcontainer/<flavor>/devcontainer-metadata.json'
1727
required: false
1828
type: string
1929
registry:
20-
description: "Docker registry to push built containers to, DOCKER_REGISTRY_USERNAME and DOCKER_REGISTRY_PASSWORD secrets must be set if not using GitHub Container Registry"
30+
description: >-
31+
Docker registry to push built containers to.
32+
`DOCKER_REGISTRY_USERNAME` and `DOCKER_REGISTRY_PASSWORD` secrets must be set if not using GitHub Container Registry (ghcr.io).
2133
required: false
2234
type: string
2335
default: "ghcr.io"
2436
build-test-runner-labels:
2537
description: >-
26-
JSON object passed to fromJson to become the build matrix. Example:
27-
'["ubuntu-latest", "ubuntu-24.04-arm"]'
38+
JSON array used to select multi-architecture runners for build and test jobs.
39+
Must be valid JSON.
40+
41+
Examples:
42+
'["ubuntu-latest"]'
43+
'["ubuntu-latest", "ubuntu-24.04-arm"]'
44+
'[["self-hosted", "linux", "x86_64"], ["self-hosted", "linux", "arm64"]]'
2845
required: false
2946
type: string
3047
default: '["ubuntu-latest", "ubuntu-24.04-arm"]'
3148
runner-labels:
3249
description: >-
33-
Single runner label OR JSON array of runner labels for non-build jobs.
50+
JSON array used to select the default linux runner for non-build jobs.
51+
Must be valid JSON.
52+
3453
Examples:
35-
ubuntu-latest
3654
'["ubuntu-latest"]'
3755
'["self-hosted", "linux", "x86_64"]'
38-
Provide a valid JSON array (starting with '[') to use multiple labels; any other value is treated as a single label string.
3956
required: false
4057
type: string
41-
default: ubuntu-latest
58+
default: '["ubuntu-latest"]'
4259
integration-test-file:
4360
description: "Path to the BATS test file to run for integration tests"
4461
required: false
@@ -94,19 +111,20 @@ jobs:
94111
integration-test:
95112
name: 🧪
96113
if: ${{ inputs.integration-test-file }}
97-
strategy:
98-
matrix:
99-
runner: ${{ (startsWith(inputs.build-test-runner-labels, '[') && endsWith(inputs.build-test-runner-labels, ']')) && fromJson(inputs.build-test-runner-labels) || inputs.build-test-runner-labels }}
100114
needs: build-push
101115
uses: ./.github/workflows/wc-integration-test.yml
102116
permissions:
103117
contents: read
118+
secrets:
119+
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
120+
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
104121
with:
122+
build-test-runner-labels: ${{ inputs.build-test-runner-labels }}
105123
fully-qualified-image-name: ${{ needs.build-push.outputs.fully-qualified-image-name }}
106124
image-basename: ${{ needs.build-push.outputs.image-basename }}
107125
image-digest: ${{ needs.build-push.outputs.digest }}
126+
registry: ${{ inputs.registry }}
108127
test-file: ${{ inputs.integration-test-file }}
109-
runner-labels: ${{ matrix.runner }}
110128

111129
acceptance-test:
112130
name: 🏗️

.github/workflows/wc-build-push.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ jobs:
5757
runner-labels: ${{ inputs.runner-labels }}
5858

5959
build-push:
60-
name: ${{ matrix.runner }}
60+
name: Build (${{ (startsWith(matrix.runner, '[') && endsWith(matrix.runner, ']')) && join(matrix.runner, ', ') || matrix.runner }})
6161
strategy:
6262
matrix:
63-
runner: ${{ (startsWith(inputs.build-test-runner-labels, '[') && endsWith(inputs.build-test-runner-labels, ']')) && fromJson(inputs.build-test-runner-labels) || inputs.build-test-runner-labels }}
63+
runner: ${{ fromJson(inputs.build-test-runner-labels) }}
6464
runs-on: ${{ matrix.runner }}
6565
needs: sanitize-image-name
6666
permissions:
@@ -137,9 +137,7 @@ jobs:
137137

138138
merge-image:
139139
name: 🔗 Merge Image
140-
# Support either a plain single label (e.g. ubuntu-latest) OR a JSON array of labels.
141-
# If the input starts & ends with brackets we attempt JSON parsing; otherwise we pass the raw string.
142-
runs-on: ${{ (startsWith(inputs.runner-labels, '[') && endsWith(inputs.runner-labels, ']')) && fromJson(inputs.runner-labels) || inputs.runner-labels }}
140+
runs-on: ${{ fromJson(inputs.runner-labels) }}
143141
needs:
144142
- build-push
145143
- sanitize-image-name
@@ -159,9 +157,6 @@ jobs:
159157
with:
160158
disable-sudo: true
161159
egress-policy: audit
162-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
163-
with:
164-
persist-credentials: false
165160
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
166161
with:
167162
path: ${{ runner.temp }}/digests

.github/workflows/wc-dependency-review.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@ on:
55
workflow_call:
66
inputs:
77
runner-labels:
8-
description: "Runner to use for the job, will be passed to `runs-on`"
8+
description: >-
9+
JSON array used to select the action runner.
10+
Must be valid JSON.
11+
12+
Examples:
13+
'["ubuntu-latest"]'
14+
'["self-hosted", "linux", "x86_64"]'
915
required: false
1016
type: string
11-
default: ubuntu-latest
17+
default: '["ubuntu-latest"]'
1218

1319
permissions: {}
1420

1521
jobs:
1622
dependency-review:
1723
name: Review
18-
runs-on: ${{ (startsWith(inputs.runner-labels, '[') && endsWith(inputs.runner-labels, ']')) && fromJson(inputs.runner-labels) || inputs.runner-labels }}
24+
runs-on: ${{ fromJson(inputs.runner-labels) }}
1925
permissions:
2026
contents: read
2127
pull-requests: write

.github/workflows/wc-integration-test.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ on:
1616
test-file:
1717
required: true
1818
type: string
19-
runner-labels:
20-
description: "Runner to use for the job, will be passed to `runs-on`"
19+
build-test-runner-labels:
2120
required: true
2221
type: string
2322
registry:
24-
description: "Docker registry to push built containers to, DOCKER_REGISTRY_USERNAME and DOCKER_REGISTRY_PASSWORD secrets must be set if not using GitHub Container Registry"
25-
required: false
23+
required: true
2624
type: string
27-
default: "ghcr.io"
2825
secrets:
2926
DOCKER_REGISTRY_USERNAME:
30-
required: false
27+
required: true
3128
DOCKER_REGISTRY_PASSWORD:
32-
required: false
29+
required: true
3330

3431
permissions: {}
3532

3633
jobs:
3734
run-test:
38-
name: 🧪 Integration Test
39-
runs-on: ${{ (startsWith(inputs.runner-labels, '[') && endsWith(inputs.runner-labels, ']')) && fromJson(inputs.runner-labels) || inputs.runner-labels }}
35+
name: Integration Test (${{ (startsWith(matrix.runner, '[') && endsWith(matrix.runner, ']')) && join(matrix.runner, ', ') || matrix.runner }})
36+
strategy:
37+
matrix:
38+
runner: ${{ fromJson(inputs.build-test-runner-labels) }}
39+
runs-on: ${{ matrix.runner }}
4040
container:
4141
image: ${{ inputs.fully-qualified-image-name }}@${{ inputs.image-digest }}
4242
credentials:

.github/workflows/wc-sanitize-image-name.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ permissions: {}
2929
jobs:
3030
sanitize:
3131
name: Sanitize Image Name
32-
runs-on: ${{ (startsWith(inputs.runner-labels, '[') && endsWith(inputs.runner-labels, ']')) && fromJson(inputs.runner-labels) || inputs.runner-labels }}
32+
runs-on: ${{ fromJson(inputs.runner-labels) }}
3333
outputs:
3434
image-basename: ${{ steps.sanitize-image-name.outputs.sanitized-basename }}
3535
image-name: ${{ steps.sanitize-image-name.outputs.sanitized-image-name }}

0 commit comments

Comments
 (0)