Skip to content

Commit 4c4130c

Browse files
authored
chore: refactor re-usable workflows to enable re-use in derived repositories (#968)
* ci: refactor wc-build-push for better re-use * chore: make runner labels configurable * chore: decouple flavor from wc-build-push-test * chore: fix issues with image name * chore: fix duplicate env * chore: fix more duplicate env's * chore: fix findings * chore: start with fixing integration tests * chore: split-off image name sanitization * chore: fix path to integration tests * chore: enable docker credentials for integration test * ci: change secret names * ci: enable multiple labels for single runner selection * ci: try to fix syntax for fromJson * ci: try to fix runner selection * ci: handle devcontainer metadata properly * ci: don't escape '=' * ci: fix linter feedback * ci: fix more runs-on * chore: retry merge-image in bash * ci: various fixes and improvements * ci: fix document upload for release * ci: integrate changes from main * ci: more refactoring * ci: fix cancellation and metadata label * ci: fix cancellation * ci: refactor to multiple re-usable layers * ci: fix internal scenario * ci: fix permissions * ci: fix issues with secrets and refactor further * ci: fix permissions * ci: suppress invalid linter finding * ci: make acceptance test secrest optional * chore: refactor copilot instructions * ci: block network access when not required * ci: add acceptance tests and reduce duplication * ci: fix release build * ci: add requirement and change some naming * ci: refactor naming * ci: fix zizmore findings * ci: more name refactoring * ci: less emoji is sometimes better * ci: more name juggling * ci: silence step-security warning * ci: get rid of defaults * ci: disable errors for lychee * ci: remove xwin cache * ci: don't use bash-isms to convert to lowercase * ci: make sure we do interpolation * ci: heredoc syntax "<<<" also seems to be a bash-ism --------- Signed-off-by: Ron <45816308+rjaegers@users.noreply.github.com>
1 parent d800a0b commit 4c4130c

25 files changed

Lines changed: 464 additions & 181 deletions
File renamed without changes.
File renamed without changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
applyTo: ".github/workflows/*.yml"
3+
---
4+
5+
# GitHub Workflows Guidelines
6+
7+
When writing GitHub Action workflows, ensure that:
8+
9+
- Workflows that have a workflow_call trigger have their filename prefixed with `wc-`.
10+
- For all re-usable workflows, only the top-level workflow (workflows that are not called themselves by other workflows with workflow_call) has defaults and descriptions for inputs to avoid duplication.
11+
- All workflows and action definitions have a name that is descriptive and concise, using emoji where appropriate.
12+
- The sorting order for inputs, secrets, and outputs is alphabetical.
13+
- The sorting order of other keys is consistent across the repository.

.github/workflows/continuous-integration.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Continuous Integration
2+
name: CI
33

44
on:
55
merge_group:
@@ -14,6 +14,10 @@ permissions: {}
1414

1515
jobs:
1616
build-push-test:
17+
name: 🛠️ Build → Push → Test (🍨 ${{ matrix.flavor }})
18+
strategy:
19+
matrix:
20+
flavor: [cpp, rust]
1721
uses: ./.github/workflows/wc-build-push-test.yml
1822
secrets:
1923
TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
@@ -28,3 +32,45 @@ jobs:
2832
id-token: write
2933
packages: write
3034
pull-requests: write
35+
with:
36+
devcontainer-metadata-file: .devcontainer/${{ matrix.flavor }}/devcontainer-metadata.json
37+
dockerfile: .devcontainer/${{ matrix.flavor }}/Dockerfile
38+
image-name: ${{ github.repository }}-${{ matrix.flavor }}
39+
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' || '' }}
42+
43+
dependency-review:
44+
name: 🔍 Dependency Review
45+
needs: build-push-test
46+
uses: ./.github/workflows/wc-dependency-review.yml
47+
permissions:
48+
contents: read
49+
pull-requests: write
50+
51+
publish-test-results:
52+
name: 📊 Publish Test Results
53+
runs-on: ubuntu-latest
54+
permissions:
55+
checks: write
56+
pull-requests: write
57+
needs: build-push-test
58+
if: ${{ !cancelled() }}
59+
steps:
60+
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
61+
with:
62+
disable-sudo: true
63+
egress-policy: audit
64+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
65+
with:
66+
merge-multiple: true
67+
pattern: test-results-*
68+
- uses: EnricoMi/publish-unit-test-result-action@3a74b2957438d0b6e2e61d67b05318aa25c9e6c6 # v2.20.0
69+
with:
70+
files: test-report-*.xml
71+
72+
generate-documents:
73+
name: 📄 Documentation
74+
uses: ./.github/workflows/wc-document-generation.yml
75+
permissions:
76+
contents: read

.github/workflows/image-cleanup.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ on:
99
permissions: {}
1010

1111
jobs:
12-
delete-images:
12+
cleanup-images:
13+
name: 🧹 Clean Images
1314
runs-on: ubuntu-latest
1415
permissions:
1516
# dataaxiom/ghcr-cleanup-action needs packages write permission
@@ -19,7 +20,6 @@ jobs:
1920
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
2021
with:
2122
disable-sudo: true
22-
egress-policy: block
2323
allowed-endpoints: >
2424
api.github.com:443
2525
ghcr.io:443

.github/workflows/issue-cleanup.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ permissions: {}
99

1010
jobs:
1111
close-issues:
12+
name: ♻️ Close Stale Issues & PRs
1213
runs-on: ubuntu-latest
1314
permissions:
1415
issues: write

.github/workflows/linting-formatting.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ permissions:
1919

2020
jobs:
2121
linter:
22+
name: 🧹 Lint & Format
2223
runs-on: ubuntu-latest
2324
permissions:
2425
contents: read

.github/workflows/ossf-scorecard.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ permissions: read-all
1313

1414
jobs:
1515
ossf-scorecard:
16+
name: 🛡️ OpenSSF Scorecard
1617
runs-on: ubuntu-latest
1718
permissions:
1819
security-events: write

.github/workflows/pr-conventional-title.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ permissions: {}
1212

1313
jobs:
1414
validate-pr-title:
15+
name: ✅ Validate PR Title
1516
runs-on: ubuntu-latest
1617
permissions:
1718
pull-requests: write
1819
steps:
1920
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
2021
with:
2122
disable-sudo-and-containers: true
22-
egress-policy: block
2323
allowed-endpoints: >
2424
api.github.com:443
2525
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
@@ -33,7 +33,7 @@ jobs:
3333
env:
3434
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3535
- uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
36-
if: always() && steps.pr-title.outputs.error_message != null
36+
if: ${{ !cancelled() && steps.pr-title.outputs.error_message != null }}
3737
with:
3838
header: pr-title-lint-error
3939
message: |

.github/workflows/pr-image-cleanup.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ permissions: {}
99

1010
jobs:
1111
delete-images:
12+
name: 🗑️ Delete PR Images
1213
runs-on: ubuntu-latest
1314
permissions:
1415
packages: write
@@ -22,6 +23,7 @@ jobs:
2223
delete-tags: pr-${{ github.event.pull_request.number }}
2324
packages: amp-devcontainer,amp-devcontainer-cpp,amp-devcontainer-rust
2425
cleanup-cache:
26+
name: 🧹 Cleanup Cache
2527
runs-on: ubuntu-latest
2628
permissions:
2729
# actions: write permission is required to delete the cache

0 commit comments

Comments
 (0)