Skip to content

Commit d07f6bd

Browse files
committed
Merge #291: ci: pin nightly compiler version
4ecb6e0 ci: update main workflow to use pinned nightly version (Andrew Poelstra) d543b39 copy nightly-version and cron-weekly-update-nightly.yml from rust-bitcoin (Andrew Poelstra) Pull request description: ...and add a weekly cronjob to update the pin. Fixes #211 ACKs for top commit: uncomputable: ACK 4ecb6e0 Tree-SHA512: 01d37ba2ce4733e295b7a86648f40051dc44e2457e0d246d9f1eb01f5c44d1a0ab98f8a00a0d033fb45a7e17ae6893c671addb10ee92183e89b2282d5e68b6aa
2 parents bef2d03 + 4ecb6e0 commit d07f6bd

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Update Nightly rustc
2+
on:
3+
schedule:
4+
- cron: "5 0 * * 6" # Saturday at 00:05
5+
workflow_dispatch: # allows manual triggering
6+
jobs:
7+
format:
8+
name: Update nightly rustc
9+
runs-on: ubuntu-24.04
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: dtolnay/rust-toolchain@nightly
13+
- name: Update rust.yml to use latest nightly
14+
run: |
15+
set -x
16+
# Not every night has a nightly, so extract the date from whatever
17+
# version of the compiler dtolnay/rust-toolchain gives us.
18+
NIGHTLY_DATE=$(rustc +nightly --verbose --version | sed -ne 's/^commit-date: //p')
19+
# Update the nightly version in the reference file.
20+
echo "nightly-${NIGHTLY_DATE}" > nightly-version
21+
echo "nightly_date=${NIGHTLY_DATE}" >> $GITHUB_ENV
22+
# Some days there is no new nightly. In this case don't make an empty PR.
23+
if ! git diff --exit-code > /dev/null; then
24+
echo "Updated nightly. Opening PR."
25+
echo "changes_made=true" >> $GITHUB_ENV
26+
else
27+
echo "Attempted to update nightly but the latest-nightly date did not change. Not opening any PR."
28+
echo "changes_made=false" >> $GITHUB_ENV
29+
fi
30+
- name: Create Pull Request
31+
if: env.changes_made == 'true'
32+
uses: peter-evans/create-pull-request@v7
33+
with:
34+
token: ${{ secrets.APOELSTRA_CREATE_PR_TOKEN }}
35+
author: Update Nightly Rustc Bot <[email protected]>
36+
committer: Update Nightly Rustc Bot <[email protected]>
37+
title: Automated daily update to rustc (to nightly-${{ env.nightly_date }})
38+
body: |
39+
Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action
40+
commit-message: Automated update to Github CI to rustc nightly-${{ env.nightly_date }}
41+
branch: create-pull-request/daily-nightly-update

.github/workflows/main.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ on: [push, pull_request]
33
name: Continuous integration
44

55
jobs:
6+
Prepare:
7+
runs-on: ubuntu-24.04
8+
outputs:
9+
nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }}
10+
steps:
11+
- name: "Checkout repo"
12+
uses: actions/checkout@v4
13+
- name: "Read nightly version"
14+
id: read_toolchain
15+
run: echo "nightly_version=$(cat nightly-version)" >> $GITHUB_OUTPUT
16+
617
fmt:
718
name: Rustfmt
819
runs-on: ubuntu-latest
@@ -46,14 +57,15 @@ jobs:
4657
4758
test:
4859
name: Tests
60+
needs: Prepare
4961
runs-on: ubuntu-latest
5062
strategy:
5163
fail-fast: false
5264
matrix:
5365
rust:
5466
- stable
5567
- beta
56-
- nightly
68+
- ${{ needs.Prepare.outputs.nightly_version }}
5769
- 1.78.0
5870
steps:
5971
- name: Checkout Crate
@@ -122,12 +134,15 @@ jobs:
122134
123135
docs:
124136
name: Docs
137+
needs: Prepare
125138
runs-on: ubuntu-latest
126139
steps:
127140
- name: Checkout Crate
128141
uses: actions/checkout@v4
129142
- name: Checkout Toolchain
130-
uses: dtolnay/rust-toolchain@nightly
143+
uses: dtolnay/rust-toolchain@v1
144+
with:
145+
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
131146
- name: Check that documentation builds without errors
132147
env:
133148
RUSTDOCFLAGS: "--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links"

nightly-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nightly-2025-04-11

0 commit comments

Comments
 (0)