Repository navigation
170 lines (162 loc) · 6.74 KB
/
Copy pathci.yml
File metadata and controls
170 lines (162 loc) · 6.74 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
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
name: CI
on:
pull_request:
push:
branches: [main]
schedule:
# Every Monday: find vulnerabilities that became known since the last push.
- cron: "17 5 * * 1"
permissions:
contents: read
concurrency:
# A new push to a pull request cancels the older run for it.
# Each push to main gets its own group, so those runs are never cancelled.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
test:
name: test (${{ matrix.go }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# go.mod: the oldest Go we support (the go line in go.mod).
# stable: the newest Go release.
go: [go.mod, stable]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: ${{ matrix.go == 'go.mod' && 'go.mod' || '' }}
go-version: ${{ matrix.go == 'stable' && 'stable' || '' }}
- name: Install ssh and sshd for the SSH tests
# The tests of internal/sshauth run the real ssh and sshd. GitHub
# sets CI=true, and then these tests fail instead of skip when a
# program is missing.
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends openssh-client openssh-server
# The package starts the system ssh service; the tests run their
# own sshd, so stop it and keep port 22 closed.
sudo systemctl disable --now ssh.socket ssh.service || true
- name: Check formatting
run: |
unformatted="$(gofmt -l .)"
if [ -n "$unformatted" ]; then
echo "These files are not formatted with gofmt:"
echo "$unformatted"
exit 1
fi
- run: go vet ./...
- run: go test -race ./...
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: shellcheck install.sh
# A fixed release of ShellCheck, checked by its SHA-256. Dependabot
# does not update it. Update it by hand: the version and the SHA-256
# of shellcheck-VERSION.linux.x86_64.tar.xz together.
env:
SHELLCHECK_VERSION: v0.11.0
SHELLCHECK_SHA256: 8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198
run: |
set -euo pipefail
dir="${RUNNER_TEMP}/shellcheck"
mkdir -p "$dir"
curl --proto '=https' --tlsv1.2 -fsSL --retry 3 -o "$dir/shellcheck.tar.xz" \
"https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz"
echo "${SHELLCHECK_SHA256} $dir/shellcheck.tar.xz" | sha256sum --strict -c -
tar -xJf "$dir/shellcheck.tar.xz" -C "$dir"
"$dir/shellcheck-${SHELLCHECK_VERSION}/shellcheck" --version
"$dir/shellcheck-${SHELLCHECK_VERSION}/shellcheck" --shell=sh install.sh
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
# Dependabot does not update this version. Update it by hand.
version: v2.14.0
# With the tag e2e, the files of the end-to-end test are checked
# too. No file needs the tag to be missing, so nothing is left out.
args: --build-tags e2e
e2e:
name: end-to-end test
runs-on: ubuntu-latest
# The test itself takes about 10 seconds; without caches, building
# the image and the binaries takes a few minutes more.
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
- name: Show the programs that the test uses
# The runner has Docker, the OpenSSH client and git. The test
# needs OpenSSH 8.9 or newer.
run: |
docker version
ssh -V
git --version
- run: go vet -tags e2e ./test/e2e/...
- name: End-to-end test
# See DESIGN.md section 17. The test builds nodkey and the image
# of test/e2e/testdata/sshd, and removes every container, network
# and image that it makes. It fails if one is left.
run: go test -race -tags e2e ./test/e2e/...
vuln:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
# Release binaries are built with the newest Go (see release.yml),
# so check the standard library of that version.
go-version: stable
- name: govulncheck
# Dependabot does not update this version. Update it by hand.
run: go run golang.org/x/vuln/cmd/govulncheck@v1.9.0 ./...
vuln-release:
name: vuln (latest release)
# Weekly only. The published binaries contain the Go standard library
# they were built with, so check the binaries themselves. A finding here
# needs a new release (see docs/releasing.md).
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: stable
cache: false
- name: govulncheck on the binaries of the latest release
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
tag="$(gh release list --repo "$GITHUB_REPOSITORY" --exclude-drafts \
--exclude-pre-releases --limit 1 --json tagName --jq '.[0].tagName // empty')"
if [ -z "$tag" ]; then
echo "No release yet. Nothing to check."
exit 0
fi
dir="${RUNNER_TEMP}/release"
gh release download "$tag" --repo "$GITHUB_REPOSITORY" --dir "$dir" \
--pattern 'nodkey_*_linux_*.tar.gz'
status=0
for tarball in "$dir"/*.tar.gz; do
out="${tarball%.tar.gz}"
mkdir -p "$out"
tar -xzf "$tarball" -C "$out" nodkey
echo "== ${tag}: $(basename "$tarball")"
go run golang.org/x/vuln/cmd/govulncheck@v1.9.0 -mode=binary "$out/nodkey" || status=1
done
exit "$status"