Skip to content

Commit 6661ad0

Browse files
authored
ci: Add a toolchain workflow (#1484)
1 parent 0530c00 commit 6661ad0

File tree

7 files changed

+73
-22
lines changed

7 files changed

+73
-22
lines changed

.devcontainer/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ ARG CARGO_DENY_VERSION=0.11.1
1313
RUN curl --proto '=https' --tlsv1.3 -vsSfL "https://github.com/EmbarkStudios/cargo-deny/releases/download/${CARGO_DENY_VERSION}/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
1414
| tar zvxf - --strip-components=1 -C /usr/local/bin "cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl/cargo-deny"
1515

16+
FROM docker.io/rust:${RUST_VERSION}-bullseye as yq
17+
ARG YQ_VERSION=v4.2.0
18+
RUN curl --proto '=https' --tlsv1.3 -vsSfLo /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" \
19+
&& chmod +x /usr/local/bin/yq
20+
1621
#
1722
# Main image
1823
#
@@ -57,6 +62,7 @@ ENV PATH=$HOME/.linkerd2/bin:$PATH
5762
COPY --from=cargo-deny /usr/local/bin/cargo-deny /usr/local/bin/cargo-deny
5863
COPY --from=k3d /usr/local/bin/k3d /usr/local/bin/k3d
5964
COPY --from=kubectl /usr/local/bin/kubectl /usr/local/bin/kubectl
65+
COPY --from=yq /usr/local/bin/yq /usr/local/bin/yq
6066

6167
ENTRYPOINT ["/usr/local/share/docker-init.sh"]
6268
CMD ["sleep", "infinity"]

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "linkerd2-proxy",
3-
"image": "ghcr.io/linkerd/dev-proxy:v6",
3+
"image": "ghcr.io/linkerd/dev-proxy:v7",
44
// "dockerFile": "./Dockerfile",
55
"extensions": [
66
"matklad.rust-analyzer",

.github/actions/package/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
ARG BASE_IMAGE=rust:1.56.1-buster
1+
ARG RUST_VERSION=1.56.1
2+
ARG BASE_IMAGE=rust:${RUST_VERSION}-buster
23
FROM $BASE_IMAGE
34
WORKDIR /linkerd
45
RUN apt-get update && \

.github/workflows/devcontainer.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,6 @@ jobs:
1818
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
1919
- run: docker build .devcontainer
2020

21-
rust-version:
22-
runs-on: ubuntu-latest
23-
steps:
24-
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
25-
- run: |
26-
versions=$(sed -nE 's|^ARG +RUST_VERSION=([^ #]+)|\1|p' .devcontainer/Dockerfile)
27-
ex=0
28-
if [ -z "$versions" ]; then
29-
echo "::error file=.devcontainer/Dockerfile::No Rust versions specified in Dockerfile"
30-
ex=1
31-
fi
32-
for mismatch in $(echo "$versions" | grep -vF "$(cat rust-toolchain)" || true) ; do
33-
echo "::error file=.devcontainer/Dockerfile::Devcontainer uses incorrect rust version(s): $mismatch"
34-
ex=$((ex + 1))
35-
done
36-
exit $ex
37-
3821
devcontainer-image:
3922
runs-on: ubuntu-latest
4023
steps:

.github/workflows/toolchain.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: rust-toolchain
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- rust-toolchain
7+
- "**Dockerfile"
8+
- ".github/workflows/*"
9+
- ".github/**/Dockerfile"
10+
11+
permissions:
12+
contents: read
13+
14+
env:
15+
YQ_VERSION: v4.2.0
16+
17+
jobs:
18+
dockerfiles:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
22+
- run: |
23+
VERSION="$(cat rust-toolchain)"
24+
ex=0
25+
for f in $(find . -name Dockerfile -and -not -path './.github/actions/release-tag-meta/*'); do
26+
versions=$(sed -nE 's/^ARG RUST_VERSION=([^ ]+)/\1/p' $f)
27+
if [ -z "$versions" ]; then
28+
echo "::error file=$f::$f missing 'RUST_VERSION' argument"
29+
ex=$((ex + 1))
30+
fi
31+
for mismatch in $(echo "$version" | grep -vF "$VERSION" || true) ; do
32+
echo "::error file=$f::$f uses incorrect rust version(s): $mismatch"
33+
ex=$((ex + 1))
34+
done
35+
done
36+
exit $ex
37+
38+
workflows:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
42+
- run: |
43+
curl --proto '=https' --tlsv1.3 -vsSfLo /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" \
44+
&& chmod +x /usr/local/bin/yq
45+
- run: |
46+
VERSION="$(cat rust-toolchain)"
47+
ex=0
48+
for f in $(find .github/workflows -name '*.yml') ; do
49+
echo "# $f"
50+
for image in $(yq eval '.jobs[].container.image' $f) ; do
51+
if [[ "$image" =~ "^docker://(docker.io/library/)?rust:" ]]; then
52+
v="${${image##*rust:}%%-*}"
53+
if [[ "$v" != "$VERSION" ]]; then
54+
echo "::warning file=$f::$f uses incorrect rust version: $v"
55+
ex=$((ex + 1))
56+
fi
57+
fi
58+
done
59+
done
60+
exit $ex

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
# :; docker buildx build . --load
1818

1919
# Please make changes via update-rust-version.sh
20-
ARG RUST_IMAGE=rust:1.56.1-buster
20+
ARG RUST_VERSION=1.56.1
21+
ARG RUST_IMAGE=rust:${RUST_VERSION}-buster
2122

2223
# Use an arbitrary ~recent edge release image to get the proxy
2324
# identity-initializing and linkerd-await wrappers.

update-rust-version.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$' ; then
1414
fi
1515

1616
echo "$VERSION" > rust-toolchain
17-
find . -name Dockerfile\* \
18-
-exec sed -i'' -Ee "s|rust:[0-9]+\.[0-9]+\.[0-9]+|rust:$VERSION|" '{}' \;
17+
find . -name Dockerfile \
18+
-exec sed -i'' -Ee "s|RUST_VERSION=[0-9]+\.[0-9]+\.[0-9]+|RUST_VERSION=$VERSION|" '{}' \;
1919
find .github -name \*.yml \
2020
-exec sed -i'' -Ee "s|rust:[0-9]+\.[0-9]+\.[0-9]+|rust:$VERSION|" '{}' \;

0 commit comments

Comments
 (0)