Skip to content

Commit e583794

Browse files
committed
ci: introduce CI system based on that from rust-secp
Removed benchmarks, asan etc, wasm stuff; removed lockfile logic; cleaned up some things with chatgpt; emptied the scripts in contrib/ but left enough of the framework in place that we should understand how to update them.
1 parent dc217dc commit e583794

File tree

7 files changed

+294
-0
lines changed

7 files changed

+294
-0
lines changed
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 <[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: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
on: # yamllint disable-line rule:truthy
2+
pull_request:
3+
push:
4+
branches:
5+
- master
6+
- 'test-ci/**'
7+
8+
name: Continuous integration
9+
10+
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+
32+
Stable:
33+
name: Test - stable toolchain
34+
runs-on: ubuntu-latest
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
dep: [minimal, recent]
39+
steps:
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"
45+
uses: dtolnay/rust-toolchain@stable
46+
- name: "Run test script"
47+
run: ./maintainer-tools/ci/run_task.sh stable
48+
49+
Nightly:
50+
name: Test - nightly toolchain
51+
needs: Prepare
52+
runs-on: ubuntu-latest
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
dep: [minimal, recent]
57+
steps:
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
68+
69+
MSRV:
70+
name: Test - MSRV
71+
needs: Prepare
72+
runs-on: ubuntu-latest
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
dep: [minimal, recent]
77+
steps:
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
88+
89+
Lint:
90+
name: Lint - nightly toolchain
91+
needs: Prepare
92+
runs-on: ubuntu-latest
93+
strategy:
94+
fail-fast: false
95+
matrix:
96+
dep: [recent]
97+
steps:
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
110+
111+
Docs:
112+
name: Docs - stable toolchain
113+
runs-on: ubuntu-latest
114+
strategy:
115+
fail-fast: false
116+
matrix:
117+
dep: [recent]
118+
steps:
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"
124+
uses: dtolnay/rust-toolchain@stable
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

contrib/crates.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# No shebang, this file should not be executed.
2+
# shellcheck disable=SC2148
3+
#
4+
# disable verify unused vars, despite the fact that they are used when sourced
5+
# shellcheck disable=SC2034
6+
7+
# Dot for single crate in workspace to test.
8+
CRATES=(".")

contrib/extra_tests.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
REPO_DIR=$(git rev-parse --show-toplevel)
6+
7+
# Make all cargo invocations verbose.
8+
export CARGO_TERM_VERBOSE=true
9+
10+
# Set to false to turn off verbose output.
11+
flag_verbose=true
12+
13+
# Use the current `Cargo.lock` file without updating it.
14+
cargo="cargo --locked"
15+
16+
main() {
17+
source_test_vars # Get feature list.
18+
# FIXME add cargo insta here?
19+
}
20+
21+
# ShellCheck can't follow non-constant source, `test_vars_script` is correct.
22+
# shellcheck disable=SC1090
23+
source_test_vars() {
24+
local test_vars_script="$REPO_DIR/contrib/test_vars.sh"
25+
26+
verbose_say "Sourcing $test_vars_script"
27+
28+
if [ -e "$test_vars_script" ]; then
29+
# Set crate specific variables.
30+
. "$test_vars_script"
31+
else
32+
err "Missing $test_vars_script"
33+
fi
34+
}
35+
36+
say() {
37+
echo "extra_tests: $1"
38+
}
39+
40+
verbose_say() {
41+
if [ "$flag_verbose" = true ]; then
42+
say "$1"
43+
fi
44+
}
45+
46+
err() {
47+
echo "$1" >&2
48+
exit 1
49+
}
50+
51+
#
52+
# Main script
53+
#
54+
main "$@"
55+
exit 0

contrib/test_vars.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# No shebang, this file should not be executed.
2+
# shellcheck disable=SC2148
3+
#
4+
# disable verify unused vars, despite the fact that they are used when sourced
5+
# shellcheck disable=SC2034
6+
7+
# Test all these features with "std" enabled.
8+
FEATURES_WITH_STD=""
9+
10+
# Test all these features without "std" enabled.
11+
FEATURES_WITHOUT_STD=""
12+
13+
# Run these examples.
14+
EXAMPLES=""

nightly-version

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

0 commit comments

Comments
 (0)