-
Notifications
You must be signed in to change notification settings - Fork 129
109 lines (94 loc) · 3.73 KB
/
pre-submit.units.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
# Copyright 2023 SLSA Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: unit tests
on:
push:
branches: [main, "*"]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
merge_group:
workflow_dispatch:
permissions: read-all
jobs:
pre-submit:
# NOTE: this name is used as the status check name and by protected
# branches for required status checks. It should have a unique name among
# other pre-submits.
name: unit tests
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: setup-go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: "go.mod"
- name: Set Node.js 16
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 16
- name: unit tests
run: |
sha256sum .github/actions/tscommon/tscommon-0.0.0.tgz
make unit-test
check-verifier:
name: verify slsa-verifier is latest
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
path: generator
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
path: verifier
repository: slsa-framework/slsa-verifier
- name: Check verifier references
shell: bash
run: |
set -euo pipefail
# The first sha in SHA256SUM.md for slsa-verifier-linux-amd64 is the latest verifier release sha
expected_sha=$(grep -m 1 -w -o -e '[0-9a-f]\{64\} *slsa-verifier-linux-amd64' verifier/SHA256SUM.md | awk '{ print $1 }')
echo "$expected_sha"
# The first vX.Y.Z in SHA256SUM.md is the latest verifier release version
expected_version=$(grep -e 'v[0-9].[0-9].[0-9]' -o -m 1 -w verifier/SHA256SUM.md | head -1)
echo "$expected_version"
# Check for expected verifier releases in the builders
cd generator
error=0
verifier_release_binary_sha256="$(grep -r -e 'VERIFIER_RELEASE_BINARY_SHA256: [0-9a-f]\{64\}' --include=*.yml)"
while read -r line ; do
sha=$(echo "$line" | grep -o -e '[0-9a-f]\{64\}')
file=$(echo "$line" | awk '{print $1;}')
if [ "$sha" != "$expected_sha" ]; then
echo "SHA out of date in file $file expected $expected_sha"
error=1
fi
done <<<"${verifier_release_binary_sha256}"
verifier_release="$(grep -r -e 'VERIFIER_RELEASE: v[0-9].[0-9].[0-9]' --include=*.yml)"
while read -r line ; do
version=$(echo "$line" | grep -o -e 'v[0-9].[0-9].[0-9]')
file=$(echo "$line" | awk '{print $1;}')
if [ "$version" != "$expected_version" ]; then
echo "Verifier version out of date in file $file expected $expected_version"
error=1
fi
done <<<"${verifier_release}"
if [ $error -ne 0 ]; then
exit 1
fi