-
Notifications
You must be signed in to change notification settings - Fork 270
66 lines (60 loc) · 2.24 KB
/
toolchain.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
name: rust-toolchain
on:
pull_request:
paths:
- rust-toolchain
- "**Dockerfile"
- ".github/workflows/*"
- ".github/**/Dockerfile"
permissions:
contents: read
jobs:
devcontainer:
runs-on: ubuntu-latest
container: ghcr.io/linkerd/dev:v43-rust
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- run: git config --global --add safe.directory "$PWD" # actions/runner#2033
- run: |
VERSION_REGEX='channel = "([0-9]+\.[0-9]+\.[0-9]+)"'
TOOLCHAIN=$(cat rust-toolchain.toml)
if [[ $TOOLCHAIN =~ $VERSION_REGEX ]]; then
VERSION=${BASH_REMATCH[1]}
if [ "$(cargo --version | cut -d' ' -f2)" != "$VERSION" ]; then
echo "::error file=rust-toolchain.toml::rust-toolchain channel '$VERSION' does not match devcontainer '$(cargo --version)'"
exit 1
fi
else
echo "::error file=rust-toolchain.toml::failed to parse rust-toolchain.toml"
exit 1
fi
shell: bash
workflows:
runs-on: ubuntu-latest
steps:
- uses: linkerd/dev/actions/setup-tools@v43
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- shell: bash
run: |
VERSION_REGEX='channel = "([0-9]+\.[0-9]+\.[0-9]+)"'
TOOLCHAIN=$(cat rust-toolchain.toml)
if [[ $TOOLCHAIN =~ $VERSION_REGEX ]]; then
VERSION=${BASH_REMATCH[1]}
else
echo "::error file=rust-toolchain.toml::failed to parse rust-toolchain.toml"
exit 1
fi
ex=0
while IFS= read -r file ; do
while IFS= read -r image ; do
if [[ "$image" =~ ^docker://(docker.io/library/)?rust: ]]; then
tag="${image##*rust:}"
v="${tag%%-*}"
if [[ "$v" != "$VERSION" ]]; then
echo "::warning file=$file::$file uses incorrect rust version: '$v' (rust-toolchain.toml contains '$VERSION')"
ex=$((ex + 1))
fi
fi
done < <(yq '.jobs[] | select(.container) | .container.image // .container' "$file")
done < <(find .github/workflows -name '*.yml')
exit $ex