Skip to content

Commit 57a3c03

Browse files
committed
ci: add lockfile and use rust-bitcoin-maintainer-tools CI setup
1 parent 58db4c4 commit 57a3c03

8 files changed

Lines changed: 1124 additions & 96 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Checkout Maintainer Tools
2+
description: Checks out the rust-bitcoin maintainer tools repo
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Checkout maintainer tools
7+
uses: actions/checkout@v4
8+
with:
9+
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
10+
ref: f92b2766865ce5327eca5cf72f86ceaa6be58ca4
11+
path: maintainer-tools
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 * * 1,4" # runs every Monday and Thursday at 00:05 UTC
5+
workflow_dispatch: # allows manual triggering
6+
jobs:
7+
format:
8+
name: Update nightly rustc
9+
runs-on: ubuntu-latest
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@v6
33+
with:
34+
token: ${{ secrets.APOELSTRA_CREATE_PR_TOKEN }}
35+
author: Update Nightly Rustc Bot <bot@example.com>
36+
committer: Update Nightly Rustc Bot <bot@example.com>
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: 126 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,167 @@
1-
on:
1+
on: # yamllint disable-line rule:truthy
2+
pull_request:
23
push:
34
branches:
45
- master
5-
pull_request: {}
6+
- 'test-ci/**'
67

78
name: Continuous integration
89

910
jobs:
11+
Prepare:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }}
15+
msrv_version: ${{ steps.read_msrv.outputs.msrv_version }}
16+
steps:
17+
- name: "Checkout repo"
18+
uses: actions/checkout@v4
19+
- name: "Read nightly version"
20+
id: read_toolchain
21+
run: |
22+
set -euo pipefail
23+
version=$(cat nightly-version)
24+
echo "nightly_version=$version" >> $GITHUB_OUTPUT
25+
- name: Read MSRV from clippy.toml
26+
id: read_msrv
27+
run: |
28+
set -euo pipefail
29+
msrv=$(grep '^msrv *= *"' clippy.toml | sed -E 's/.*"([^"]+)".*/\1/')
30+
echo "msrv_version=$msrv" >> "$GITHUB_OUTPUT"
31+
1032
Stable:
1133
name: Test - stable toolchain
1234
runs-on: ubuntu-latest
1335
strategy:
1436
fail-fast: false
37+
matrix:
38+
dep: [minimal, recent]
1539
steps:
16-
- name: Checkout Crate
17-
uses: actions/checkout@v3
18-
- name: Checkout Toolchain
19-
# https://github.com/dtolnay/rust-toolchain
40+
- name: "Checkout repo"
41+
uses: actions/checkout@v4
42+
- name: "Checkout maintainer tools"
43+
uses: ./.github/actions/checkout-maintainer-tools
44+
- name: "Select toolchain"
2045
uses: dtolnay/rust-toolchain@stable
21-
- name: Running test script
22-
env:
23-
DO_DOCS: true
24-
DO_DOCSRS: false
25-
DO_FUZZ: false
26-
DO_INTEGRATION: false
27-
DO_LINT: true
28-
DO_FEATURE_MATRIX: true
29-
run: ./contrib/test.sh
46+
- name: "Run test script"
47+
run: ./maintainer-tools/ci/run_task.sh stable
3048

3149
Nightly:
3250
name: Test - nightly toolchain
51+
needs: Prepare
3352
runs-on: ubuntu-latest
3453
strategy:
3554
fail-fast: false
55+
matrix:
56+
dep: [minimal, recent]
3657
steps:
37-
- name: Checkout Crate
38-
uses: actions/checkout@v3
39-
- name: Checkout Toolchain
40-
uses: dtolnay/rust-toolchain@nightly
41-
- name: Running test script
42-
env:
43-
DO_DOCS: true
44-
DO_DOCSRS: true
45-
DO_FUZZ: false
46-
DO_INTEGRATION: false
47-
DO_LINT: false
48-
DO_FEATURE_MATRIX: true
49-
run: ./contrib/test.sh
58+
- name: "Checkout repo"
59+
uses: actions/checkout@v4
60+
- name: "Checkout maintainer tools"
61+
uses: ./.github/actions/checkout-maintainer-tools
62+
- name: "Select toolchain"
63+
uses: dtolnay/rust-toolchain@v1
64+
with:
65+
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
66+
- name: "Run test script"
67+
run: ./maintainer-tools/ci/run_task.sh nightly
5068

5169
MSRV:
52-
name: Test - 1.63.0 toolchain
70+
name: Test - MSRV
71+
needs: Prepare
5372
runs-on: ubuntu-latest
5473
strategy:
5574
fail-fast: false
75+
matrix:
76+
dep: [minimal, recent]
5677
steps:
57-
- name: Checkout Crate
58-
uses: actions/checkout@v3
59-
- name: Checkout Toolchain
60-
uses: dtolnay/rust-toolchain@1.63.0
61-
- name: Running test script
62-
env:
63-
DO_DOCS: false
64-
DO_DOCSRS: false
65-
DO_FUZZ: false
66-
DO_INTEGRATION: false
67-
DO_LINT: false
68-
DO_FEATURE_MATRIX: true
69-
run: ./contrib/test.sh
78+
- name: "Checkout repo"
79+
uses: actions/checkout@v4
80+
- name: "Checkout maintainer tools"
81+
uses: ./.github/actions/checkout-maintainer-tools
82+
- name: "Select toolchain"
83+
uses: dtolnay/rust-toolchain@stable
84+
with:
85+
toolchain: ${{ needs.Prepare.outputs.msrv_version }}
86+
- name: "Run test script"
87+
run: ./maintainer-tools/ci/run_task.sh msrv
7088

71-
Fuzz:
72-
name: Fuzztests - 1.63.0 toolchain
89+
Lint:
90+
name: Lint - nightly toolchain
91+
needs: Prepare
7392
runs-on: ubuntu-latest
7493
strategy:
7594
fail-fast: false
95+
matrix:
96+
dep: [recent]
7697
steps:
77-
- name: Checkout Crate
78-
uses: actions/checkout@v3
79-
- name: Checkout Toolchain
80-
uses: dtolnay/rust-toolchain@1.63.0
81-
- name: Install test dependencies
82-
run: sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev
83-
- name: Running test script
84-
env:
85-
DO_DOCS: false
86-
DO_DOCSRS: false
87-
DO_FUZZ: true
88-
DO_INTEGRATION: false
89-
DO_LINT: false
90-
DO_FEATURE_MATRIX: false
91-
run: ./contrib/test.sh
98+
- name: "Checkout repo"
99+
uses: actions/checkout@v4
100+
- name: "Checkout maintainer tools"
101+
uses: ./.github/actions/checkout-maintainer-tools
102+
- name: "Select toolchain"
103+
uses: dtolnay/rust-toolchain@v1
104+
with:
105+
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
106+
- name: Install clippy
107+
run: rustup component add clippy
108+
- name: "Run test script"
109+
run: ./maintainer-tools/ci/run_task.sh lint
92110

93-
Integration:
94-
name: Integration tests - stable
111+
Docs:
112+
name: Docs - stable toolchain
95113
runs-on: ubuntu-latest
96114
strategy:
97115
fail-fast: false
116+
matrix:
117+
dep: [recent]
98118
steps:
99-
- name: Checkout Crate
100-
uses: actions/checkout@v3
101-
- name: Checkout Toolchain
119+
- name: "Checkout repo"
120+
uses: actions/checkout@v4
121+
- name: "Checkout maintainer tools"
122+
uses: ./.github/actions/checkout-maintainer-tools
123+
- name: "Select toolchain"
102124
uses: dtolnay/rust-toolchain@stable
103-
- name: Running test script
104-
env:
105-
DO_DOCS: false
106-
DO_DOCSRS: false
107-
DO_FUZZ: false
108-
DO_INTEGRATION: true
109-
DO_LINT: false
110-
DO_FEATURE_MATRIX: false
111-
run: ./contrib/test.sh
125+
- name: "Run test script"
126+
run: ./maintainer-tools/ci/run_task.sh docs
127+
128+
Docsrs:
129+
name: Docs - nightly toolchain
130+
needs: Prepare
131+
runs-on: ubuntu-latest
132+
strategy:
133+
fail-fast: false
134+
matrix:
135+
dep: [recent]
136+
steps:
137+
- name: "Checkout repo"
138+
uses: actions/checkout@v4
139+
- name: "Checkout maintainer tools"
140+
uses: ./.github/actions/checkout-maintainer-tools
141+
- name: "Select toolchain"
142+
uses: dtolnay/rust-toolchain@v1
143+
with:
144+
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
145+
- name: "Run test script"
146+
run: ./maintainer-tools/ci/run_task.sh docsrs
147+
148+
Format:
149+
name: Format - nightly toolchain
150+
needs: Prepare
151+
runs-on: ubuntu-latest
152+
strategy:
153+
fail-fast: false
154+
steps:
155+
- name: "Checkout repo"
156+
uses: actions/checkout@v4
157+
- name: "Select toolchain"
158+
uses: dtolnay/rust-toolchain@v1
159+
with:
160+
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
161+
- name: "Install rustfmt"
162+
run: rustup component add rustfmt
163+
- name: "Check formatting"
164+
run: cargo fmt --all -- --check
112165

113166
Wasm:
114167
name: Check WASM

0 commit comments

Comments
 (0)