Skip to content

Commit 5351af7

Browse files
committed
ci: add acceptance tests and reduce duplication
1 parent 0e40b83 commit 5351af7

File tree

6 files changed

+64
-151
lines changed

6 files changed

+64
-151
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
dockerfile: .devcontainer/${{ matrix.flavor }}/Dockerfile
3838
image-name: ${{ github.repository }}-${{ matrix.flavor }}
3939
integration-test-file: test/${{ matrix.flavor }}/integration-tests.bats
40+
acceptance-test-path: ${{ matrix.flavor == 'cpp' && 'test/cpp/features' || '' }}
41+
test-devcontainer-file: ${{ matrix.flavor == 'cpp' && '.devcontainer/cpp-test/devcontainer.json' || '' }}
4042

4143
dependency-review:
4244
needs: build-push-test-flavors

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ name: Acceptance Test
44
on:
55
workflow_call:
66
inputs:
7-
flavor:
7+
image-basename:
8+
required: true
9+
type: string
10+
devcontainer-file:
11+
required: true
12+
type: string
13+
acceptance-test-path:
814
required: true
915
type: string
1016
secrets:
@@ -49,9 +55,9 @@ jobs:
4955
gh secret set -a codespaces IMAGE_VERSION --body "edge"
5056
fi
5157
52-
echo CODESPACE_NAME="$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${CONTAINER_FLAVOR}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h)" >> "$GITHUB_ENV"
58+
echo CODESPACE_NAME="$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path "${DEVCONTAINER_FILE}" --idle-timeout 10m --retention-period 1h)" >> "$GITHUB_ENV"
5359
env:
54-
CONTAINER_FLAVOR: ${{ inputs.flavor }}
60+
DEVCONTAINER_FILE: ${{ inputs.devcontainer-file }}
5561
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
5662
HEAD_REF: ${{ github.head_ref }}
5763
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
@@ -82,17 +88,17 @@ jobs:
8288
done
8389
env:
8490
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
85-
- run: cd "test/${CONTAINER_FLAVOR}/features" && npm test
91+
- run: cd "${ACCEPTANCE_TEST_PATH}" && npm test
8692
env:
87-
CONTAINER_FLAVOR: ${{ inputs.flavor }}
93+
ACCEPTANCE_TEST_PATH: ${{ inputs.acceptance-test-path }}
8894
GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }}
8995
GITHUB_PASSWORD: ${{ secrets.TEST_GITHUB_PASSWORD }}
9096
GITHUB_TOTP_SECRET: ${{ secrets.TEST_GITHUB_TOTP_SECRET }}
91-
PLAYWRIGHT_JUNIT_OUTPUT_NAME: ${{ github.workspace }}/test-report-acceptance-${{ inputs.flavor }}.xml
97+
PLAYWRIGHT_JUNIT_OUTPUT_NAME: ${{ github.workspace }}/test-report-acceptance-${{ inputs.image-basename }}.xml
9298
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
9399
if: ${{ !cancelled() }}
94100
with:
95-
name: test-results-acceptance-${{ inputs.flavor }}
101+
name: test-results-acceptance-${{ inputs.image-basename }}
96102
path: |
97103
test-report-*.xml
98104
test-results/

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

Lines changed: 0 additions & 102 deletions
This file was deleted.

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ on:
4343
description: "Path to the BATS test file to run for integration tests"
4444
required: false
4545
type: string
46+
test-devcontainer-file:
47+
description: "Path to the devcontainer.json file to use for acceptance tests"
48+
required: false
49+
type: string
50+
acceptance-test-path:
51+
description: "Path to the Playwright acceptance tests (directory that contains playwright.config.ts)"
52+
required: false
53+
type: string
4654
secrets:
4755
TEST_GITHUB_TOKEN:
4856
required: false
@@ -92,6 +100,24 @@ jobs:
92100
permissions:
93101
contents: read
94102
with:
95-
image-name: ${{ inputs.image-name }}
103+
fully-qualified-image-name: ${{ needs.build-push.outputs.fully-qualified-image-name }}
104+
image-basename: ${{ needs.build-push.outputs.image-basename }}
105+
image-digest: ${{ needs.build-push.outputs.digest }}
96106
test-file: ${{ inputs.integration-test-file }}
97107
runner-labels: ${{ matrix.runner }}
108+
109+
acceptance-test:
110+
if: ${{ inputs.test-devcontainer-file && inputs.acceptance-test-path }}
111+
needs: build-push
112+
uses: ./.github/workflows/wc-acceptance-test.yml
113+
permissions:
114+
contents: read
115+
secrets:
116+
TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
117+
TEST_GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }}
118+
TEST_GITHUB_PASSWORD: ${{ secrets.TEST_GITHUB_PASSWORD }}
119+
TEST_GITHUB_TOTP_SECRET: ${{ secrets.TEST_GITHUB_TOTP_SECRET }}
120+
with:
121+
image-basename: ${{ needs.build-push.outputs.image-basename }}
122+
devcontainer-file: ${{ inputs.test-devcontainer-file }}
123+
acceptance-test-path: ${{ inputs.acceptance-test-path }}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ on:
3232
runner-labels:
3333
required: true
3434
type: string
35+
outputs:
36+
fully-qualified-image-name:
37+
value: ${{ jobs.sanitize-image-name.outputs.fully-qualified-image-name }}
38+
image-basename:
39+
value: ${{ jobs.sanitize-image-name.outputs.image-basename }}
40+
digest:
41+
value: ${{ jobs.merge-image.outputs.digest }}
3542
secrets:
3643
DOCKER_REGISTRY_USERNAME:
3744
required: true
@@ -142,6 +149,8 @@ jobs:
142149
id-token: write
143150
packages: write
144151
pull-requests: write
152+
outputs:
153+
digest: ${{ steps.inspect-manifest.outputs.digest }}
145154
steps:
146155
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
147156
with:

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

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ name: Integration Test
44
on:
55
workflow_call:
66
inputs:
7-
image-name:
7+
fully-qualified-image-name:
8+
required: true
9+
type: string
10+
image-basename:
11+
required: true
12+
type: string
13+
image-digest:
814
required: true
915
type: string
1016
test-file:
@@ -28,44 +34,10 @@ on:
2834
permissions: {}
2935

3036
jobs:
31-
sanitize-image-name:
32-
uses: ./.github/workflows/wc-sanitize-image-name.yml
33-
with:
34-
image-name: ${{ inputs.image-name }}
35-
registry: ${{ inputs.registry }}
36-
runner-labels: ${{ inputs.runner-labels }}
37-
38-
determine-container:
39-
runs-on: ${{ (startsWith(inputs.runner-labels, '[') && endsWith(inputs.runner-labels, ']')) && fromJson(inputs.runner-labels) || inputs.runner-labels }}
40-
needs: sanitize-image-name
41-
outputs:
42-
container: ${{ steps.set-container.outputs.container }}
43-
runner-arch: ${{ steps.runner-arch.outputs.arch }}
44-
steps:
45-
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
46-
with:
47-
disable-sudo: true
48-
egress-policy: audit
49-
- run: echo "arch=${RUNNER_ARCH@L}" >> "$GITHUB_OUTPUT"
50-
id: runner-arch
51-
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
52-
with:
53-
path: ${{ runner.temp }}/digests-${{ needs.sanitize-image-name.outputs.image-basename }}-${{ steps.runner-arch.outputs.arch }}
54-
pattern: digests-${{ needs.sanitize-image-name.outputs.image-basename }}-${{ steps.runner-arch.outputs.arch }}
55-
- run: echo "container=$(printf "${FULLY_QUALIFIED_IMAGE_NAME}@sha256:%s " *)" >> "$GITHUB_OUTPUT"
56-
working-directory: ${{ runner.temp }}/digests-${{ needs.sanitize-image-name.outputs.image-basename }}-${{ steps.runner-arch.outputs.arch }}
57-
env:
58-
FULLY_QUALIFIED_IMAGE_NAME: ${{ needs.sanitize-image-name.outputs.fully-qualified-image-name }}
59-
GH_REPO: ${{ github.repository }}
60-
id: set-container
61-
6237
run-test:
63-
needs:
64-
- determine-container
65-
- sanitize-image-name
6638
runs-on: ${{ (startsWith(inputs.runner-labels, '[') && endsWith(inputs.runner-labels, ']')) && fromJson(inputs.runner-labels) || inputs.runner-labels }}
6739
container:
68-
image: ${{ needs.determine-container.outputs.container }} # zizmor: ignore[unpinned-images] This image is actually pinned by sha256 digest
40+
image: ${{ inputs.fully-qualified-image-name }}@${{ inputs.image-digest }}
6941
credentials:
7042
username: ${{ secrets.DOCKER_REGISTRY_USERNAME || github.actor }}
7143
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD || github.token }}
@@ -82,16 +54,16 @@ jobs:
8254
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
8355
with:
8456
path: test/cpp/.xwin-cache
85-
key: xwin-cache-${{ needs.determine-container.outputs.runner-arch }}
57+
key: xwin-cache-${{ runner.arch }}
8658
restore-keys: |
87-
xwin-cache-${{ needs.determine-container.outputs.runner-arch }}
59+
xwin-cache-${{ runner.arch }}
8860
- run: bats --formatter junit "${TEST_FILE}" | tee "test-report-${IMAGE_BASENAME}-${RUNNER_ARCH}.xml"
8961
env:
90-
IMAGE_BASENAME: ${{ needs.sanitize-image-name.outputs.image-basename }}
62+
IMAGE_BASENAME: ${{ inputs.image-basename }}
9163
TEST_FILE: ${{ inputs.test-file }}
92-
RUNNER_ARCH: ${{ needs.determine-container.outputs.runner-arch }}
64+
RUNNER_ARCH: ${{ runner.arch }}
9365
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
9466
if: ${{ !cancelled() }}
9567
with:
96-
name: test-results-integration-${{ needs.sanitize-image-name.outputs.image-basename }}-${{ needs.determine-container.outputs.runner-arch }}
68+
name: test-results-integration-${{ inputs.image-basename }}-${{ runner.arch }}
9769
path: test-report-*.xml

0 commit comments

Comments
 (0)