Skip to content

Commit e0d51f9

Browse files
authored
chore: fix acceptance tests on default branch (#824)
Signed-off-by: Ron <[email protected]>
1 parent 66aec0a commit e0d51f9

File tree

7 files changed

+58
-13
lines changed

7 files changed

+58
-13
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
uses: ./.github/workflows/wc-build-push-test.yml
1919
secrets: inherit
2020
permissions:
21+
actions: read
2122
attestations: write
2223
checks: write
2324
contents: write

.github/workflows/release-build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
uses: ./.github/workflows/wc-build-push-test.yml
2020
secrets: inherit
2121
permissions:
22+
actions: read
2223
attestations: write
2324
checks: write
2425
contents: write
@@ -49,6 +50,9 @@ jobs:
4950
env:
5051
REGISTRY: ghcr.io
5152
steps:
53+
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
54+
with:
55+
egress-policy: audit
5256
- name: Inspect manifest and extract digest
5357
id: inspect-manifest
5458
run: |

.github/workflows/update-dependencies.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
contents: write
2222
pull-requests: write
2323
steps:
24+
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
25+
with:
26+
egress-policy: audit
2427
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2528
with:
2629
persist-credentials: false

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ jobs:
3030
- name: Start Codespace
3131
run: |
3232
set -Eeuo pipefail
33-
gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}"
33+
34+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
35+
gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}"
36+
elif [[ "${{ github.event_name }}" == "push" && "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
37+
gh secret set -a codespaces IMAGE_VERSION --body "${GITHUB_REF#refs/tags/}"
38+
else
39+
gh secret set -a codespaces IMAGE_VERSION --body "edge"
40+
fi
41+
3442
echo CODESPACE_NAME="$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ inputs.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h)" >> "$GITHUB_ENV"
3543
env:
3644
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
uses: ./.github/workflows/wc-build-push.yml
1616
secrets: inherit
1717
permissions:
18+
actions: read
1819
attestations: write
1920
contents: write
2021
id-token: write
@@ -23,6 +24,25 @@ jobs:
2324
with:
2425
flavor: ${{ matrix.flavor }}
2526

27+
dependency-review:
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: read
31+
pull-requests: write
32+
needs: build-push
33+
if: github.event_name == 'pull_request'
34+
steps:
35+
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
36+
with:
37+
egress-policy: audit
38+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
39+
with:
40+
persist-credentials: false
41+
- uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1
42+
with:
43+
comment-summary-in-pr: on-failure
44+
fail-on-severity: critical
45+
2646
integration-test:
2747
strategy:
2848
matrix:

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ jobs:
8181
runs-on: ubuntu-latest
8282
needs: build-push
8383
permissions:
84+
actions: read
8485
attestations: write
8586
# dependency-submission needs contents write permission.
8687
contents: write
@@ -123,12 +124,25 @@ jobs:
123124
type=semver,pattern={{major}}
124125
- name: Create manifest list and push
125126
working-directory: ${{ runner.temp }}/digests
127+
shell: python
126128
run: |
127-
set -Eeuo pipefail
128-
# shellcheck disable=SC2046
129-
docker buildx imagetools create \
130-
$(echo '${{ steps.metadata.outputs.json }}' | jq -r '.tags | map("--tag " + .) | join(" ")') \
131-
$(printf '${{ env.REGISTRY }}/${{ github.repository }}-${{ inputs.flavor }}@sha256:%s ' *)
129+
import os
130+
import json
131+
import subprocess
132+
133+
CONTAINER = '${{ env.REGISTRY }}/${{ github.repository }}-${{ inputs.flavor }}'
134+
METADATA = json.loads('${{ steps.metadata.outputs.json }}')
135+
136+
digests = [f for f in os.listdir('.') if f.startswith('sha256:') or len(f) == 64]
137+
138+
command = ['docker', 'buildx', 'imagetools', 'create',
139+
*[annotation for annotation in METADATA.get('annotations', []) for annotation in ('--annotation', annotation)],
140+
*[tag for tag in METADATA.get('tags', []) for tag in ('--tag', tag)],
141+
*[f"{CONTAINER}@sha256:{digest}" for digest in digests]
142+
]
143+
144+
print(' '.join(command))
145+
subprocess.run(command, check=True)
132146
- name: Inspect manifest and extract digest
133147
id: inspect-manifest
134148
run: |
@@ -149,11 +163,6 @@ jobs:
149163
with:
150164
image: ${{ env.REGISTRY }}/${{ github.repository }}-${{ inputs.flavor }}@${{ steps.inspect-manifest.outputs.digest }}
151165
dependency-snapshot: true
152-
- uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1
153-
if: github.event_name == 'pull_request'
154-
with:
155-
comment-summary-in-pr: on-failure
156-
fail-on-severity: critical
157166
- uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
158167
with:
159168
subject-name: ${{ env.REGISTRY }}/${{ github.repository }}-${{ inputs.flavor }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ The amp-devcontainer repository follows a [semantic versioning](https://semver.o
8888

8989
Released containers will never be cleaned-up, pull request builds are cleaned up when the pull request is merged, and edge builds may be cleaned up after being stale for a while.
9090

91-
The release notes always contain an overview of the corresponding image versions that included the full SHA next to the version number. This makes it possible for humans to easily see what version is used while still pinning to an exact version. This is the recommended way to refer to an image.
91+
The release notes always contain an overview of the corresponding image versions that include the full SHA next to the version number. This makes it possible for humans to easily see what version is used while still pinning to an exact version. This is the recommended way to refer to an image.
9292

9393
All container images are included in a release. This might change in the future when the need arises to have separate releases per container.
9494

@@ -217,5 +217,5 @@ See [security](.github/SECURITY.md) for more information.
217217

218218
## Licenses
219219

220-
amp-devcontainer is licensed under the MIT license
220+
amp-devcontainer is licensed under the MIT license.
221221
See [license](./LICENSE) for more information.

0 commit comments

Comments
 (0)