Skip to content

Commit 6b26ab7

Browse files
committed
Merge rust-bitcoin#66: Share github setup action
76c80a2 github action (Nick Johnson) Pull request description: I learned that you can reference github composite actions from other repos, so figured I'd centralize this setup action that is starting to gain some dependencies. ACKs for top commit: tcharding: ACK 76c80a2 Tree-SHA512: 1a234212ac61a81dfae87978f06e2ea7dcf55a363c8f2f2543b3f012b0924e4ff661ab45f1e74ac9d489436487abd46f8af9cd0890731b043aed891cf81c30ad
2 parents 57cbfbd + 76c80a2 commit 6b26ab7

File tree

3 files changed

+72
-6
lines changed

3 files changed

+72
-6
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: 'Setup rbmt'
2+
description: |
3+
Install environment dependencies for cargo-rbmt testing including cargo-rbmt itself.
4+
inputs:
5+
toolchains:
6+
description: 'Rust toolchain versions, comma-separated (nightly,1.74.0)'
7+
required: false
8+
default: 'stable'
9+
components:
10+
description: 'Additional Rust components, comma-separated (clippy,rustfmt)'
11+
required: false
12+
default: ''
13+
rbmt-version:
14+
description: 'Git ref (commit, tag, or branch) of cargo-rbmt to install'
15+
required: false
16+
default: 'master'
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
# Cache ARM toolchain apt packages for faster subsequent runs.
22+
- name: Cache ARM toolchain packages
23+
uses: actions/cache@v5
24+
with:
25+
path: /var/cache/apt/archives
26+
key: ${{ runner.os }}-apt-arm-toolchain-v1
27+
restore-keys: |
28+
${{ runner.os }}-apt-arm-toolchain-
29+
30+
# Setup Rust with automatic caching of toolchains and build artifacts.
31+
# Always install stable for cargo-rbmt, plus the requested toolchain.
32+
- name: Setup Rust toolchain
33+
uses: actions-rust-lang/setup-rust-toolchain@v1
34+
with:
35+
toolchain: stable,${{ inputs.toolchains }}
36+
components: rust-src,${{ inputs.components }}
37+
# ARM target to test no-std build.
38+
target: thumbv7m-none-eabi
39+
40+
# Install ARM cross-compiler for no-std testing.
41+
- name: Install ARM cross-compiler
42+
shell: bash
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get install -y gcc-arm-none-eabi
46+
echo "CC_thumbv7m_none_eabi=arm-none-eabi-gcc" >> $GITHUB_ENV
47+
48+
# Install cargo-rbmt using stable toolchain.
49+
- name: Install cargo-rbmt
50+
shell: bash
51+
run: |
52+
cargo +stable install --git https://github.com/rust-bitcoin/rust-bitcoin-maintainer-tools.git --rev ${{ inputs.rbmt-version }} cargo-rbmt --locked

.github/workflows/ci.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v6
1313

14-
- name: Install Rust toolchains
15-
uses: actions-rust-lang/setup-rust-toolchain@v1
14+
- name: Dogfood the setup-rbmt action
15+
uses: ./.github/actions/setup-rbmt
1616
with:
17-
toolchain: nightly,1.85.0,stable
17+
toolchains: nightly,1.85.0
1818
components: clippy,rustfmt
19-
20-
- name: Install cargo-rbmt from current commit
21-
run: cargo install --locked --path cargo-rbmt
19+
rbmt-version: ${{ github.sha }}
2220

2321
- name: Run lint on workspace
2422
run: cargo +nightly rbmt --lock-file existing lint

cargo-rbmt/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Maintainer tools for Rust-based projects in the Bitcoin domain. Built with [xshe
1515
- [Workspace Integration](#workspace-integration)
1616
- [1. Install on system](#1-install-on-system)
1717
- [2. Add as a dev-dependency](#2-add-as-a-dev-dependency)
18+
- [GitHub Action](#github-action)
1819

1920
## Environment Variables
2021

@@ -188,3 +189,18 @@ cargo run --bin cargo-rbmt -- lint
188189
```
189190

190191
It might be worth wrapping in an [xtask](https://github.com/matklad/cargo-xtask) package for a clean interface.
192+
193+
## GitHub Action
194+
195+
A composite action is provided to make it easy to use `cargo-rbmt` in Github Actions CI.
196+
197+
```yaml
198+
steps:
199+
- uses: actions/checkout@v6
200+
- uses: rust-bitcoin/rust-bitcoin-maintainer-tools/.github/actions/setup-rbmt@master
201+
with:
202+
toolchains: stable
203+
- run: cargo rbmt test stable
204+
```
205+
206+
See the [action](../.github/actions/setup-rbmt/action.yml) for more details.

0 commit comments

Comments
 (0)