Repository navigation
58 lines (55 loc) · 2.29 KB
/
Copy pathtest-scripts.yaml
File metadata and controls
58 lines (55 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
name: "Test Scripts"
# Runs the bats suites for scripts/ and verifies the inline copies embedded in
# the release workflows match the scripts byte for byte.
on:
pull_request:
push:
branches: [main]
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read # Clone the repository
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install bats
uses: bats-core/bats-action@3566550e0f594451ac0f58fcbfdeca93aa29a45e # 4.1.0
with:
support-install: false
assert-install: false
detik-install: false
file-install: false
- name: Lint scripts
run: shellcheck scripts/*.sh
- name: Run bats
run: bats scripts/tests/
- name: Check inline copies match scripts
run: |
status=0
check() {
local workflow="$1" job="$2" step="$3" script="$4"
# Command substitution trims trailing newlines; printf adds back exactly one.
if ! diff -u "$script" <(printf '%s\n' "$(yq ".jobs.$job.steps[] | select(.name == \"$step\") | .run" "$workflow")"); then
echo "::error file=$workflow::inline '$step' step drifted from $script"
status=1
fi
}
for workflow in .github/workflows/release-draft.yaml .github/workflows/release.yaml; do
check "$workflow" check_release "Evaluate release conditions" scripts/check-release.sh
check "$workflow" create_release "Pin to the merge commit" scripts/pin-merge-commit.sh
check "$workflow" create_release "Read version from file" scripts/resolve-version.sh
check "$workflow" create_release "Check release tag" scripts/check-tag.sh
check "$workflow" create_release "Find the first-release baseline" scripts/first-release-base.sh
done
exit "$status"