Update Rust nightly #45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Rust nightly | |
| on: | |
| schedule: | |
| - cron: '17 2 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| actions: write | |
| contents: write | |
| issues: write | |
| concurrency: | |
| group: update-rust-nightly | |
| cancel-in-progress: false | |
| jobs: | |
| compatibility: | |
| name: Test latest nightly and update pin | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 180 | |
| env: | |
| PYTHONUTF8: '1' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Discover latest nightly | |
| id: latest | |
| shell: bash | |
| run: | | |
| latest_date=$(curl --fail --retry 3 --silent --show-error \ | |
| https://static.rust-lang.org/dist/channel-rust-nightly.toml \ | |
| | sed -n 's/^date = "\([0-9-]*\)"/\1/p' \ | |
| | head -n 1) | |
| if [[ ! "$latest_date" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then | |
| echo "Could not determine the latest Rust nightly date" >&2 | |
| exit 1 | |
| fi | |
| candidate="nightly-$latest_date" | |
| pinned=$(python - <<'PY' | |
| import tomllib | |
| with open("rust-toolchain.toml", "rb") as file: | |
| print(tomllib.load(file)["toolchain"]["channel"]) | |
| PY | |
| ) | |
| components=$(python - <<'PY' | |
| import tomllib | |
| with open("rust-toolchain.toml", "rb") as file: | |
| print(",".join(tomllib.load(file)["toolchain"].get("components", []))) | |
| PY | |
| ) | |
| echo "candidate=$candidate" >> "$GITHUB_OUTPUT" | |
| echo "components=$components" >> "$GITHUB_OUTPUT" | |
| if [[ "$candidate" == "$pinned" ]]; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| echo "$candidate is already pinned." | |
| exit 0 | |
| fi | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| CANDIDATE="$candidate" python - <<'PY' | |
| import os, pathlib, re | |
| path = pathlib.Path("rust-toolchain.toml") | |
| contents = path.read_text(encoding="utf-8") | |
| updated, count = re.subn( | |
| r'(?m)^channel = "[^"]+"$', | |
| f'channel = "{os.environ["CANDIDATE"]}"', | |
| contents, | |
| count=1, | |
| ) | |
| if count != 1: | |
| raise SystemExit("could not update the Rust toolchain channel") | |
| path.write_text(updated, encoding="utf-8") | |
| PY | |
| - name: Set up latest Rust nightly | |
| if: steps.latest.outputs.changed == 'true' | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ steps.latest.outputs.candidate }} | |
| components: ${{ steps.latest.outputs.components }} | |
| - name: Set up Java | |
| if: steps.latest.outputs.changed == 'true' | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '25' | |
| - name: Set up Kotlin | |
| if: steps.latest.outputs.changed == 'true' | |
| run: python tests/kotlin/install_kotlin.py --github-path | |
| - name: Cache Cargo dependencies | |
| if: steps.latest.outputs.changed == 'true' | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Build backend and tools | |
| if: steps.latest.outputs.changed == 'true' | |
| run: python build.py ci | |
| - name: Run compiler unit tests | |
| if: steps.latest.outputs.changed == 'true' | |
| run: cargo test | |
| - name: Check JVM binding macros | |
| if: steps.latest.outputs.changed == 'true' | |
| shell: bash | |
| run: | | |
| cargo fmt --manifest-path jvm/Cargo.toml --check | |
| cargo test --manifest-path jvm/Cargo.toml | |
| - name: Run self-tests (debug) | |
| if: steps.latest.outputs.changed == 'true' | |
| run: python Tester.py | |
| - name: Run self-tests (release) | |
| if: steps.latest.outputs.changed == 'true' | |
| run: python Tester.py --release | |
| - name: Run coretests (debug) | |
| if: steps.latest.outputs.changed == 'true' | |
| run: python Coretests.py --timeout 20 --build-timeout 1200 | |
| - name: Run coretests (release) | |
| if: steps.latest.outputs.changed == 'true' | |
| run: python Coretests.py --release --timeout 20 --build-timeout 1200 | |
| - name: Run alloctests (debug) | |
| if: steps.latest.outputs.changed == 'true' | |
| run: python Alloctests.py --timeout 120 --build-timeout 1200 | |
| - name: Commit updated nightly pin | |
| if: steps.latest.outputs.changed == 'true' && success() | |
| env: | |
| CANDIDATE: ${{ steps.latest.outputs.candidate }} | |
| shell: bash | |
| run: | | |
| git config user.name github-actions[bot] | |
| git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| git add rust-toolchain.toml | |
| git commit -m "chore: update Rust nightly to ${CANDIDATE#nightly-}" | |
| git push origin HEAD:main | |
| - name: Run full CI for the automated commit | |
| if: steps.latest.outputs.changed == 'true' && success() | |
| continue-on-error: true | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh workflow run ci.yml --ref main | |
| - name: Open or update compatibility issue | |
| if: failure() && steps.latest.outputs.changed == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| CANDIDATE: ${{ steps.latest.outputs.candidate }} | |
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| shell: bash | |
| run: | | |
| title="Rust $CANDIDATE compatibility failure" | |
| issue=$(gh issue list --state open --json number,title \ | |
| --jq ".[] | select(.title == \"$title\") | .number" \ | |
| | head -n 1) | |
| body=$(printf 'The automated compatibility suite failed for **%s**.\n\n[View the failed workflow run](%s). The pinned nightly was not changed.' "$CANDIDATE" "$RUN_URL") | |
| if [[ -n "$issue" ]]; then | |
| gh issue comment "$issue" --body "$body" | |
| else | |
| gh issue create --title "$title" --body "$body" | |
| fi |