Skip to content

Commit

Permalink
Merge rust-bitcoin#2489: ci: pin nightly compiler, add CI cronjob to …
Browse files Browse the repository at this point in the history
…update it.

ee113aa ci: add daily job to update nightly rustc (Andrew Poelstra)
f82567f ci: rename a couple .yml files to indicate that they're scheduled (Andrew Poelstra)
85ead84 ci: pin nightly in current CI (Andrew Poelstra)
c97f2cc ci: require a nightly compiler rather than using +nightly (Andrew Poelstra)
e386cbf ci: delete *test.sh files (Andrew Poelstra)

Pull request description:

  We should be pinning our nightly compiler in CI so that
  * running CI on old release branches will continue to work (not quite -- we'd want to do the same thing for Cargo.lock, but ok, one PR at a time)
  * when CI breaks due to nightly updates (usually new Clippy lints), we can address that in a dedicated "update nightly" PR rather than having every other PR suddenly break on us

  Co-authored with ChatGPT which found several typos and suggested most of the error-handling logic.

ACKs for top commit:
  tcharding:
    ACK ee113aa
  Kixunil:
    ACK ee113aa

Tree-SHA512: f198349291a7654f4e6f03998d02c1f7d2c7f999e0b5a89a915beb3e7c741148c2c65367b107c54c34d6669e6f0972699401ef85e76e76e5900c1fb5c844db4f
  • Loading branch information
apoelstra committed Mar 1, 2024
2 parents 6f14a10 + ee113aa commit b93397d
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 290 deletions.
6 changes: 4 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ test:
- any-glob-to-any-file: fuzz/**
- any-glob-to-any-file: '*/tests/**'
- any-glob-to-any-file: 'dep_test'
- any-glob-to-any-file: 'contrib/test.sh'
- any-glob-to-any-file: '*/contrib/test.sh'
- any-glob-to-any-file: 'contrib/run_task.sh'
- any-glob-to-any-file: 'contrib/test_vars.sh'
- any-glob-to-any-file: '*/contrib/extra_tests.sh'
- any-glob-to-any-file: '*/contrib/test_vars.sh'
doc:
- changed-files:
- any-glob-to-any-file: '**/*.md'
1 change: 1 addition & 0 deletions .github/nightly-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly-2024-02-18
File renamed without changes.
38 changes: 38 additions & 0 deletions .github/workflows/cron-daily-update-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Update Nightly rustc
on:
schedule:
- cron: "0 0 * * *" # runs daily at 00:00
workflow_dispatch: # allows manual triggering
jobs:
format:
name: Update nightly rustc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Update rust.yml to use latest nightly
run: |
set -x
# Not every night has a nightly, so extract the date from whatever
# version of the compiler dtolnay/rust-toolchain gives us.
NIGHTLY_DATE=$(rustc +nightly --verbose --version | sed -ne 's/^commit-date: //p')
# Update the nightly version in the reference file.
echo "nightly-${NIGHTLY_DATE}" > .github/nightly-version
echo "nightly_date=${NIGHTLY_DATE}" >> $GITHUB_ENV
# Some days there is no new nightly. In this case don't make an empty PR.
if ! git diff --exit-code > /dev/null; then
echo "Updated nightly. Opening PR."
echo "changes_made=true" >> $GITHUB_ENV
else
echo "Attempted to update nightly but the latest-nightly date did not change. Not opening any PR."
echo "changes_made=false" >> $GITHUB_ENV
fi
- name: Create Pull Request
if: env.changes_made == 'true'
uses: peter-evans/create-pull-request@v6
with:
author: Update Nightly Rustc Bot <[email protected]>
title: Automated daily update to rustc (to nightly-${{ env.nightly_date }})
body: |
Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action
commit-message: Automated update to Github CI to rustc nightly-${{ env.nightly_date }}
File renamed without changes.
16 changes: 13 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ jobs:
outputs:
crates: ${{ steps.get_matrix.outputs.crates }}
deps: ${{ steps.get_matrix.outputs.deps }}
nightly_version: ${{ steps.read_toolchain.outputs.nightly_version }}
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Read nightly version
id: read_toolchain
run: echo "nightly_version=$(cat .github/nightly-version)" >> $GITHUB_OUTPUT
- name: Prepare tests
id: get_matrix
run: contrib/get_matrix.sh
Expand Down Expand Up @@ -75,7 +79,9 @@ jobs:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Checkout Toolchain
uses: dtolnay/rust-toolchain@nightly
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
- name: Install clippy
run: rustup component add clippy
- name: Set dependencies
Expand Down Expand Up @@ -139,6 +145,7 @@ jobs:
run: cross test --target s390x-unknown-linux-gnu

Embedded:
needs: Prepare
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C link-arg=-Tlink.x"
Expand All @@ -149,8 +156,9 @@ jobs:
- name: Set up QEMU
run: sudo apt update && sudo apt install -y qemu-system-arm gcc-arm-none-eabi
- name: Checkout Toolchain
uses: dtolnay/rust-toolchain@nightly
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
targets: thumbv7m-none-eabi
- name: Install src
run: rustup component add rust-src
Expand All @@ -175,7 +183,9 @@ jobs:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Checkout Toolchain
uses: dtolnay/rust-toolchain@nightly
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ needs.Prepare.outputs.nightly_version }}
- name: Install src
run: rustup component add rust-src
- name: Running address sanitizer
Expand Down
13 changes: 0 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,6 @@ NB: reviewers may run more complex test/CI scripts, thus, satisfying all the
requirements above is just a preliminary, but not necessary sufficient step for
getting the PR accepted as a valid candidate PR for the `master` branch.

PR authors may also find it useful to run the following script locally in order
to check that each of the commits within the PR satisfies the requirements
above, before submitting the PR to review:
```shell script
RUSTUP_TOOLCHAIN=1.41.1 ./contrib/test.sh
```
Please replace the value in `RUSTUP_TOOLCHAIN=1.41.1` with the current MSRV from
[README.md].

NB: Please keep in mind that the script above replaces `Cargo.lock` file, which
is necessary to support current MSRV, incompatible with `stable` and newer cargo
versions.

### Peer review

Anyone may participate in peer review which is expressed by comments in the pull
Expand Down
131 changes: 0 additions & 131 deletions bitcoin/contrib/test.sh

This file was deleted.

14 changes: 12 additions & 2 deletions contrib/run_task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ loop_features() {

# Lint the workspace then the individual crate examples.
do_lint() {
need_nightly

# Use the current (recent/minimal) lock file.
local cargo="cargo +nightly --locked"
local cargo="cargo --locked"

$cargo clippy --workspace -- -D warnings

Expand Down Expand Up @@ -181,7 +183,8 @@ do_dup_deps() {
# Build the docs with a nightly toolchain, in unison with the function
# below this checks that we feature guarded docs imports correctly.
build_docs_with_nightly_toolchain() {
local cargo="cargo +nightly --locked"
need_nightly
local cargo="cargo --locked"

RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" $cargo doc --all-features
}
Expand Down Expand Up @@ -242,6 +245,13 @@ need_cmd() {
fi
}

need_nightly() {
cargo_ver=$(cargo --version)
if echo "$cargo_ver" | grep -q -v nightly; then
err "Need a nightly compiler; have $(cargo --version)"
fi
}

err() {
echo "$1" >&2
exit 1
Expand Down
31 changes: 0 additions & 31 deletions contrib/test.sh

This file was deleted.

44 changes: 0 additions & 44 deletions fuzz/contrib/test.sh

This file was deleted.

Loading

0 comments on commit b93397d

Please sign in to comment.