Skip to content

Commit 67ebf2d

Browse files
committed
Merge #799: ci: pin nightly rust compiler version
6df8cad ci: add weekly cronjob to update nightly compiler pin (Andrew Poelstra) 0977f73 ci: pin rustc nightly version (Andrew Poelstra) 08de687 ci: update maintainer-tools version (Andrew Poelstra) Pull request description: Turns out we were most of the way there already. I added `secrets.APOELSTRA_CREATE_PR_TOKEN` to this repo so the weekly cronjob should work. I just copy/pasted the code from rust-bitcoin. ACKs for top commit: sanket1729: utACK 6df8cad Tree-SHA512: 88dde6504287f4d708345b4721ea932ad6a99221bbd2b88a3871dde0368a3b6d42ec5cf36cc128c87d8bf2df836ae49091600eb8f63d8ca27bdea90df5f543bb
2 parents a39725d + 6df8cad commit 67ebf2d

File tree

3 files changed

+81
-13
lines changed

3 files changed

+81
-13
lines changed
Lines changed: 41 additions & 0 deletions
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/rust.yml

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ on: # yamllint disable-line rule:truthy
99
name: Continuous integration
1010

1111
jobs:
12+
Prepare:
13+
runs-on: ubuntu-24.04
14+
outputs:
15+
nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }}
16+
steps:
17+
- name: "Checkout repo"
18+
uses: actions/checkout@v4
19+
- name: "Read nightly version"
20+
id: read_toolchain
21+
run: echo "nightly_version=$(cat nightly-version)" >> $GITHUB_OUTPUT
22+
1223
Stable: # 2 jobs, one per lock file.
1324
name: Test - stable toolchain
1425
runs-on: ubuntu-latest
@@ -23,7 +34,7 @@ jobs:
2334
uses: actions/checkout@v4
2435
with:
2536
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
26-
rev: b2ac115
37+
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
2738
path: maintainer-tools
2839
- name: "Select toolchain"
2940
uses: dtolnay/rust-toolchain@stable
@@ -34,6 +45,7 @@ jobs:
3445

3546
Nightly: # 2 jobs, one per lock file.
3647
name: Test - nightly toolchain
48+
needs: Prepare
3749
runs-on: ubuntu-latest
3850
strategy:
3951
fail-fast: false
@@ -46,10 +58,12 @@ jobs:
4658
uses: actions/checkout@v4
4759
with:
4860
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
49-
rev: b2ac115
61+
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
5062
path: maintainer-tools
5163
- name: "Select toolchain"
52-
uses: dtolnay/rust-toolchain@nightly
64+
uses: dtolnay/rust-toolchain@v1
65+
with:
66+
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
5367
- name: "Set dependencies"
5468
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
5569
- name: "Run test script"
@@ -69,7 +83,7 @@ jobs:
6983
uses: actions/checkout@v4
7084
with:
7185
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
72-
rev: b2ac115
86+
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
7387
path: maintainer-tools
7488
- name: "Select toolchain"
7589
uses: dtolnay/rust-toolchain@stable
@@ -82,6 +96,7 @@ jobs:
8296

8397
Lint:
8498
name: Lint - nightly toolchain
99+
needs: Prepare
85100
runs-on: ubuntu-latest
86101
strategy:
87102
fail-fast: false
@@ -94,10 +109,12 @@ jobs:
94109
uses: actions/checkout@v4
95110
with:
96111
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
97-
rev: b2ac115
112+
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
98113
path: maintainer-tools
99114
- name: "Select toolchain"
100-
uses: dtolnay/rust-toolchain@nightly
115+
uses: dtolnay/rust-toolchain@v1
116+
with:
117+
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
101118
- name: "Install clippy"
102119
run: rustup component add clippy
103120
- name: "Set dependencies"
@@ -119,7 +136,7 @@ jobs:
119136
uses: actions/checkout@v4
120137
with:
121138
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
122-
rev: b2ac115
139+
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
123140
path: maintainer-tools
124141
- name: "Select toolchain"
125142
uses: dtolnay/rust-toolchain@stable
@@ -130,6 +147,7 @@ jobs:
130147

131148
Docsrs:
132149
name: Docs - nightly toolchain
150+
needs: Prepare
133151
runs-on: ubuntu-latest
134152
strategy:
135153
fail-fast: false
@@ -142,17 +160,20 @@ jobs:
142160
uses: actions/checkout@v4
143161
with:
144162
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
145-
rev: b2ac115
163+
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
146164
path: maintainer-tools
147165
- name: "Select toolchain"
148-
uses: dtolnay/rust-toolchain@nightly
166+
uses: dtolnay/rust-toolchain@v1
167+
with:
168+
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
149169
- name: "Set dependencies"
150170
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
151171
- name: "Run test script"
152172
run: ./maintainer-tools/ci/run_task.sh docsrs
153173

154174
Bench:
155175
name: Bench - nightly toolchain
176+
needs: Prepare
156177
runs-on: ubuntu-latest
157178
strategy:
158179
fail-fast: false
@@ -165,29 +186,34 @@ jobs:
165186
uses: actions/checkout@v4
166187
with:
167188
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
168-
rev: b2ac115
189+
ref: c3324024ced9bb1eb854397686919c3ff7d97e1e
169190
path: maintainer-tools
170191
- name: "Select toolchain"
171-
uses: dtolnay/rust-toolchain@nightly
192+
uses: dtolnay/rust-toolchain@v1
193+
with:
194+
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
172195
- name: "Set dependencies"
173196
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
174197
- name: "Run test script"
175198
run: ./maintainer-tools/ci/run_task.sh bench
176199

177200
Format: # 1 job, run cargo fmt directly.
178201
name: Format - nightly toolchain
202+
needs: Prepare
179203
runs-on: ubuntu-latest
180204
strategy:
181205
fail-fast: false
182206
steps:
183207
- name: "Checkout repo"
184208
uses: actions/checkout@v4
185209
- name: "Select toolchain"
186-
uses: dtolnay/rust-toolchain@nightly
210+
uses: dtolnay/rust-toolchain@v1
211+
with:
212+
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
187213
- name: "Install rustfmt"
188214
run: rustup component add rustfmt
189215
- name: "Check formatting"
190-
run: cargo +nightly fmt --all -- --check
216+
run: cargo fmt --all -- --check
191217

192218
Integration: # 1 job for each bitcoind version we support.
193219
name: Integration tests - stable toolchain

nightly-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nightly-2025-03-21

0 commit comments

Comments
 (0)