Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 2406ebf

Browse files
committed
Auto merge of #309 - dario23:nightly-version-script, r=JohnTitor
Add script to update and check nightly version consistency fixes #308
2 parents 3884350 + d6fd3b8 commit 2406ebf

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

.github/workflows/style.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Shellcheck
2222
run: |
2323
shellcheck --version
24-
shellcheck ci/*.sh
24+
shellcheck ci/*.sh scripts/toolchain-version
2525
2626
- name: Update nightly
2727
run: |
@@ -38,3 +38,12 @@ jobs:
3838
if rustup component add clippy rustc-dev; then
3939
cargo clippy --all
4040
fi
41+
42+
version_consistency_check:
43+
name: Toolchain version consistency check
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v3
47+
- name: Toolchain version consistency check
48+
run: scripts/toolchain-version -c
49+

scripts/toolchain-version

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
6+
NIGHTLY_RE="nightly-[0-9]{4}-[0-9]{2}-[0-9]{2}"
7+
8+
nightly_mentions() {
9+
grep -Eo "$NIGHTLY_RE" "$1" | sort --unique
10+
}
11+
12+
check_versions_match() {
13+
readarray -t versions_readme < <(nightly_mentions README.md)
14+
if [[ "${#versions_readme[@]}" -gt 1 ]]; then
15+
echo "Multiple different nightly versions mentioned in README.md: ${versions_readme[*]}"
16+
exit 1
17+
fi
18+
19+
version_toolchain=$(nightly_mentions rust-toolchain)
20+
if [[ "${versions_readme[0]}" != "${version_toolchain}" ]]; then
21+
echo "Toolchain nightly version does not match README.md: ${version_toolchain} vs. ${versions_readme[0]}"
22+
exit 1
23+
fi
24+
}
25+
26+
update_version_everywhere() {
27+
if ! echo "$1" | grep -Eq "$NIGHTLY_RE"; then
28+
echo "That doesn't look like a nightly version to me: '$1'"
29+
exit 1
30+
fi
31+
32+
sed -i -E -e "s#${NIGHTLY_RE}#$1#g" README.md rust-toolchain
33+
}
34+
35+
36+
while getopts "cu:" opt; do
37+
case $opt in
38+
c)
39+
check_versions_match
40+
;;
41+
u)
42+
update_version_everywhere "$OPTARG"
43+
;;
44+
*)
45+
echo "Usage: $0 [-c | -u <nightly version> ]"
46+
exit 1
47+
;;
48+
esac
49+
done

0 commit comments

Comments
 (0)