-
Notifications
You must be signed in to change notification settings - Fork 49
217 lines (196 loc) · 7.65 KB
/
e2e.schedule.installer.yml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: verifier action
on:
# Daily run.
schedule:
- cron: "0 4 * * *"
workflow_dispatch:
inputs:
version:
type: string
description: The version to to test for pre-release.
required: false
permissions: read-all
env:
GH_TOKEN: ${{ github.token }}
ISSUE_REPOSITORY: ${{ github.repository }}
MINIMUM_INSTALLER_VERSION: v2.0.1
jobs:
list-verifiers:
runs-on: ubuntu-latest
outputs:
# NOTE: version output is a JSON list of version numbers.
# https://github.blog/changelog/2020-04-15-github-actions-new-workflow-features/#new-fromjson-method-in-expressions
# https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson
version: ${{ steps.generate-versions.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
# NOTE: the example-package needs to be checked out in the default workspace.
repository: slsa-framework/example-package
ref: main
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
path: __THIS_REPO__
- name: Generate verifier list
if: inputs.version == ''
id: generate-list
run: ./__THIS_REPO__/.github/workflows/scripts/schedule.actions/verifier-installer.sh
- name: Generate pre-release list
if: inputs.version != ''
id: generate-prerelease
env:
PRE_RELEASE_VERSION: ${{ inputs.version }}
run: echo "version=[\"$PRE_RELEASE_VERSION\"]" >> "$GITHUB_OUTPUT"
- name: Generate pre-release list
id: generate-versions
env:
PRE_RELEASE_VERSION: ${{ steps.generate-prerelease.outputs.version }}
LIST_VERSION: ${{ steps.generate-list.outputs.version }}
run: |
if [[ -n $PRE_RELEASE_VERSION ]]; then
echo "version=$PRE_RELEASE_VERSION" >> "$GITHUB_OUTPUT"
else
echo "version=$LIST_VERSION" >> "$GITHUB_OUTPUT"
fi
verifier-run:
needs: list-verifiers
runs-on: ubuntu-latest
strategy:
matrix:
version: ${{ fromJson(needs.list-verifiers.outputs.version) }}
steps:
- name: Debug
env:
VERSION: ${{ matrix.version }}
run: echo "version is '$VERSION'"
- name: Checkout this repository
# Skip release candidates unless specified explicitly.
if: ${{ inputs.version != '' || ! contains(matrix.version, '-rc' ) }}
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: ${{ matrix.version }}
# Install at tag.
# ==============
- name: Run the Action at tag
if: ${{ inputs.version != '' || ! contains(matrix.version, '-rc' ) }}
env:
SLSA_VERIFIER_CI_ACTION_REF: ${{ matrix.version }}
uses: ./actions/installer
- name: Verify the version
env:
VERSION: ${{ matrix.version }}
if: ${{ inputs.version != '' || ! contains(matrix.version, '-rc' ) }}
run: |
version=$(slsa-verifier version 2>&1 | grep GitVersion | cut -d ':' -f2 | tr -d "[:space:]")
slsa-verifier version
echo "version: $version"
echo "VERSION: $VERSION"
# NOTE: the version reported by the slsa-verifier does not contain the leading `v`.
[ "$version" == "${VERSION:1}" ]
- name: Delete the binary
if: ${{ inputs.version != '' || ! contains(matrix.version, '-rc' ) }}
run: |
binary_path=$(which slsa-verifier)
echo "binary_path: $binary_path"
rm -rf "$binary_path"
# Install at commit sha.
# =====================
- name: Get sha1
if: ${{ inputs.version != '' || ! contains(matrix.version, '-rc' ) }}
id: commit
env:
VERSION: ${{ matrix.version }}
run: |
commit_sha=$(gh api -H "Accept: application/vnd.github+json" "/repos/$GITHUB_REPOSITORY/git/ref/tags/$VERSION" | jq -r '.object.sha')
echo "commit_sha=$commit_sha" >> "$GITHUB_OUTPUT"
- name: Run the Action at commit
if: ${{ inputs.version != '' || ! contains(matrix.version, '-rc' ) }}
env:
SLSA_VERIFIER_CI_ACTION_REF: ${{ steps.commit.outputs.commit_sha }}
uses: ./actions/installer
- name: Verify the version
env:
VERSION: ${{ matrix.version }}
if: ${{ inputs.version != '' || ! contains(matrix.version, '-rc' ) }}
run: |
version=$(slsa-verifier version 2>&1 | grep GitVersion | cut -d ':' -f2 | tr -d "[:space:]")
slsa-verifier version
echo "version: $version"
echo "VERSION: $VERSION"
# NOTE: the version reported by the slsa-verifier does not contain the leading `v`.
[ "$version" == "${VERSION:1}" ]
- name: Delete the binary
if: ${{ inputs.version != '' || ! contains(matrix.version, '-rc' ) }}
run: |
binary_path=$(which slsa-verifier)
echo "binary_path: $binary_path"
rm -rf "$binary_path"
# Install at invalid commit.
# =========================
- name: Install invalid commit
id: invalid-commit
if: ${{ inputs.version != '' || ! contains(matrix.version, '-rc' ) }}
continue-on-error: true
env:
SLSA_VERIFIER_CI_ACTION_REF: 55ca6286e3e4f4fba5d0448333fa99fc5a404a73
uses: ./actions/installer
- env:
SUCCESS: ${{ steps.invalid-commit.outcome == 'failure' }}
run: |
[ "$SUCCESS" == "true" ]
# Install at non-existent tag.
# =========================
- name: Install non-existent tag
id: nonexistent-tag
if: ${{ inputs.version != '' || ! contains(matrix.version, '-rc' ) }}
continue-on-error: true
env:
# NOTE: actions/installer checks for valid semantic version numbers.
SLSA_VERIFIER_CI_ACTION_REF: v100.3.5
uses: ./actions/installer
- env:
SUCCESS: ${{ steps.nonexistent-tag.outcome == 'failure' }}
run: |
[ "$SUCCESS" == "true" ]
# Install at empty tag.
# =====================
- name: Install empty tag
id: empty-tag
if: ${{ inputs.version != '' || ! contains(matrix.version, '-rc' ) }}
continue-on-error: true
env:
SLSA_VERIFIER_CI_ACTION_REF:
uses: ./actions/installer
- env:
SUCCESS: ${{ steps.empty-tag.outcome == 'failure' }}
run: |
[ "$SUCCESS" == "true" ]
if-succeed:
needs: [verifier-run, list-verifiers]
runs-on: ubuntu-latest
# We use `== 'failure'` instead of ` != 'success'` because we want to ignore skipped jobs, if there are any.
if: inputs.version == '' && needs.verifier-run.result != 'failure' && needs.list-verifiers.result != 'failure'
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: slsa-framework/example-package
ref: main
- run: ./.github/workflows/scripts/e2e-report-success.sh
if-failed:
needs: [verifier-run, list-verifiers]
runs-on: ubuntu-latest
if: always() && inputs.version == '' && (needs.verifier-run.result == 'failure' || needs.list-verifiers.result == 'failure')
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: slsa-framework/example-package
ref: main
- run: ./.github/workflows/scripts/e2e-report-failure.sh