From c2db54eaae2bc2bba5a76efc11ed84bdf88b609f Mon Sep 17 00:00:00 2001 From: Johannes Schilling Date: Sat, 28 May 2022 12:21:49 +0200 Subject: [PATCH 1/2] Add script to update toolchain version everywhere This should keep toolchain versions consistent, and prevent forgetting to update it in one of the places. --- .github/workflows/style.yml | 2 +- scripts/toolchain-version | 49 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 scripts/toolchain-version diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index c7b90e1e..f9b0bd08 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -21,7 +21,7 @@ jobs: - name: Shellcheck run: | shellcheck --version - shellcheck ci/*.sh + shellcheck ci/*.sh scripts/toolchain-version - name: Update nightly run: | diff --git a/scripts/toolchain-version b/scripts/toolchain-version new file mode 100755 index 00000000..2bc1233f --- /dev/null +++ b/scripts/toolchain-version @@ -0,0 +1,49 @@ +#!/bin/bash + +set -eu + + +NIGHTLY_RE="nightly-[0-9]{4}-[0-9]{2}-[0-9]{2}" + +nightly_mentions() { + grep -Eo "$NIGHTLY_RE" "$1" | sort --unique +} + +check_versions_match() { + readarray -t versions_readme < <(nightly_mentions README.md) + if [[ "${#versions_readme[@]}" -gt 1 ]]; then + echo "Multiple different nightly versions mentioned in README.md: ${versions_readme[*]}" + exit 1 + fi + + version_toolchain=$(nightly_mentions rust-toolchain) + if [[ "${versions_readme[0]}" != "${version_toolchain}" ]]; then + echo "Toolchain nightly version does not match README.md: ${version_toolchain} vs. ${versions_readme[0]}" + exit 1 + fi +} + +update_version_everywhere() { + if ! echo "$1" | grep -Eq "$NIGHTLY_RE"; then + echo "That doesn't look like a nightly version to me: '$1'" + exit 1 + fi + + sed -i -E -e "s#${NIGHTLY_RE}#$1#g" README.md rust-toolchain +} + + +while getopts "cu:" opt; do + case $opt in + c) + check_versions_match + ;; + u) + update_version_everywhere "$OPTARG" + ;; + *) + echo "Usage: $0 [-c | -u ]" + exit 1 + ;; + esac +done From d6fd3b859bf99fe3897e04ca30f3dd8004416b60 Mon Sep 17 00:00:00 2001 From: Johannes Schilling Date: Sat, 28 May 2022 12:25:46 +0200 Subject: [PATCH 2/2] Add github workflow for toolchain consistency check Implements #308 --- .github/workflows/style.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index f9b0bd08..7dfaf353 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -38,3 +38,12 @@ jobs: if rustup component add clippy rustc-dev; then cargo clippy --all fi + + version_consistency_check: + name: Toolchain version consistency check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Toolchain version consistency check + run: scripts/toolchain-version -c +