Skip to content

Commit 053727c

Browse files
bors[bot]burrbull
andauthored
Merge #580
580: more ci actions r=Emilgardis a=burrbull Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2 parents 0c18cb1 + 8693510 commit 053727c

File tree

7 files changed

+142
-114
lines changed

7 files changed

+142
-114
lines changed

.github/bors.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ block_labels = ["needs-decision", "S-waiting-on-team"]
22
delete_merged_branches = true
33
required_approvals = 1
44
status = [
5+
"Rustfmt",
56
"CI",
67
]
78
timeout_sec = 14400

.github/workflows/changelog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout sources
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v3
1313

1414
- name: Changelog updated
1515
uses: Zomzog/changelog-checker@v1.2.0

.github/workflows/ci.yml

Lines changed: 125 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,73 @@ jobs:
99
ci:
1010
name: CI
1111
runs-on: ubuntu-latest
12-
needs: [ci-linux]
13-
steps:
12+
needs: [check, ci-linux, ci-clippy, ci-serde]
13+
steps:
1414
- name: Done
1515
run: exit 0
16+
17+
check:
18+
name: Cargo check
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
TARGET: [x86_64-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc]
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
27+
- uses: actions-rs/toolchain@v1
28+
with:
29+
profile: minimal
30+
toolchain: stable
31+
override: true
32+
target: ${{ matrix.TARGET }}
33+
34+
- name: Cache Dependencies
35+
uses: Swatinem/rust-cache@v1
36+
with:
37+
key: ${{ matrix.TARGET }}
38+
39+
- uses: actions-rs/cargo@v1
40+
with:
41+
command: check
42+
args: --target ${{ matrix.TARGET }}
43+
44+
prebuild:
45+
name: Prebuild
46+
runs-on: ubuntu-latest
47+
strategy:
48+
matrix:
49+
rust: [stable, nightly, 1.46.0]
50+
51+
steps:
52+
- uses: actions/checkout@v3
53+
54+
- uses: actions-rs/toolchain@v1
55+
with:
56+
profile: minimal
57+
toolchain: ${{ matrix.rust }}
58+
override: true
59+
60+
- name: Cache
61+
uses: Swatinem/rust-cache@v1
62+
with:
63+
sharedKey: prebuilded-${{ matrix.rust }}
64+
65+
- name: Self install
66+
run: |
67+
cargo install svd2rust --path .
68+
1669
ci-linux:
1770
runs-on: ubuntu-latest
71+
needs: [check, prebuild]
1872
strategy:
19-
fail-fast: false
2073
matrix:
2174
# All generated code should be running on stable now
2275
rust: [stable]
2376

2477
# All vendor files we want to test on stable
25-
vendor: [rustfmt, Atmel, Freescale, Fujitsu, Holtek, Microchip, Nordic, Nuvoton, NXP, RISC-V, SiliconLabs, Spansion, STMicro, Toshiba]
26-
27-
# The default target we're compiling on and for
28-
TARGET: [x86_64-unknown-linux-gnu]
29-
30-
# Temporary hack as long as we use the current CI script
31-
TRAVIS_OS_NAME: [linux]
32-
33-
FEATURES: [""]
78+
vendor: [Atmel, Freescale, Fujitsu, Holtek, Microchip, Nordic, Nuvoton, NXP, RISC-V, SiliconLabs, Spansion, STMicro, Toshiba]
3479

3580
# Options are all, none, strict and const
3681
options: [all, none]
@@ -51,68 +96,103 @@ jobs:
5196
# Test MSRV
5297
- rust: 1.46.0
5398
vendor: Nordic
54-
TARGET: x86_64-unknown-linux-gnu
55-
TRAVIS_OS_NAME: linux
5699

57100
# Use nightly for architectures which don't support stable
58101
- rust: nightly
59-
experimental: true
60102
vendor: OTHER
61-
TARGET: x86_64-unknown-linux-gnu
62-
TRAVIS_OS_NAME: linux
63103

64-
# Use nightly for architectures which don't support stable
104+
# Use nightly for architectures which don't support stable
65105
- rust: nightly
66-
experimental: true
67106
vendor: Espressif
68-
TARGET: x86_64-unknown-linux-gnu
69-
TRAVIS_OS_NAME: linux
70-
71-
# OSX
72-
- rust: stable
73-
TARGET: x86_64-apple-darwin
74-
TRAVIS_OS_NAME: osx
75-
76-
# Windows
77-
- rust: stable
78-
TARGET: x86_64-pc-windows-msvc
79-
TRAVIS_OS_NAME: windows
80107

81108
steps:
82-
- uses: actions/checkout@v2
109+
- uses: actions/checkout@v3
110+
83111
- uses: actions-rs/toolchain@v1
84112
with:
85113
profile: minimal
86114
toolchain: ${{ matrix.rust }}
87-
target: ${{ matrix.TARGET }}
88115
override: true
89-
components: rustfmt
116+
117+
- name: Cache
118+
uses: Swatinem/rust-cache@v1
119+
with:
120+
sharedKey: prebuilded-${{ matrix.rust }}
121+
90122
- name: Run CI script for `${{ matrix.vendor }}` under rust `${{ matrix.rust }}` with options=`${{ matrix.options }}`
91123
env:
92-
TARGET: ${{ matrix.TARGET }}
93124
VENDOR: ${{ matrix.vendor }}
94-
FEATURES: ${{ matrix.FEATURES }}
95-
OPTIONS: ${{ matrix.options }}
96-
TRAVIS_OS_NAME: ${{ matrix.TRAVIS_OS_NAME }}
125+
OPTIONS: ${{ matrix.options }}
126+
COMMAND: check
97127
run: bash ci/script.sh
128+
129+
ci-clippy:
130+
runs-on: ubuntu-latest
131+
needs: [check, prebuild]
132+
steps:
133+
- uses: actions/checkout@v3
134+
135+
- uses: actions-rs/toolchain@v1
136+
with:
137+
profile: minimal
138+
toolchain: stable
139+
override: true
140+
141+
- name: Cache
142+
uses: Swatinem/rust-cache@v1
143+
with:
144+
sharedKey: prebuilded-stable
145+
146+
- name: Run CI script
147+
env:
148+
VENDOR: RISC-V
149+
OPTIONS: all
150+
COMMAND: clippy
151+
run: bash ci/script.sh
152+
98153
ci-serde:
99154
runs-on: ubuntu-latest
100155
steps:
101-
- uses: actions/checkout@v2
156+
- uses: actions/checkout@v3
157+
102158
- uses: actions-rs/toolchain@v1
103159
with:
104160
profile: minimal
105161
toolchain: stable
106162
override: true
107-
components: rustfmt
108-
- name: Install svdtools
109-
uses: actions-rs/install@v0.1
163+
164+
- name: Cache
165+
uses: Swatinem/rust-cache@v1
110166
with:
111-
crate: svdtools
112-
version: 0.2.0
113-
use-tool-cache: true
167+
key: svdtools-0.2.1
168+
169+
- name: Install svdtools
170+
run: |
171+
cargo install svdtools --version 0.2.1 --target-dir target
172+
114173
- name: Run CI script
115174
run: |
116175
wget https://stm32-rs.github.io/stm32-rs/stm32f411.svd.patched
117176
svdtools convert --input-format xml stm32f411.svd.patched stm32f411.yaml
118177
cargo run --release -- -i stm32f411.yaml
178+
179+
fmt:
180+
name: Rustfmt
181+
runs-on: ubuntu-latest
182+
steps:
183+
- uses: actions/checkout@v3
184+
185+
- uses: actions-rs/toolchain@v1
186+
with:
187+
profile: minimal
188+
toolchain: stable
189+
override: true
190+
components: rustfmt
191+
192+
- name: Cache Dependencies
193+
uses: Swatinem/rust-cache@v1
194+
195+
- uses: actions-rs/cargo@v1
196+
with:
197+
command: fmt
198+
args: --all -- --check

.github/workflows/clippy.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ jobs:
55
clippy_check:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v2
8+
- uses: actions/checkout@v3
9+
910
- uses: actions-rs/toolchain@v1
1011
with:
1112
profile: minimal
1213
toolchain: stable
1314
override: true
1415
components: clippy
16+
17+
- name: Cache Dependencies
18+
uses: Swatinem/rust-cache@v1
19+
1520
- uses: actions-rs/clippy-check@v1
1621
with:
1722
token: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
- GHA: rust dependency caching
1011
- remove unnedded fields clone
1112
- Use reexport instead of type aliases in `derive_from_base`
1213

ci/install.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

ci/script.sh

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,67 +8,36 @@ test_svd() {
88
)
99

1010
# NOTE we care about errors in svd2rust, but not about errors / warnings in rustfmt
11-
local cwd=$(pwd)
1211
pushd $td
13-
RUST_BACKTRACE=1 $cwd/target/$TARGET/release/svd2rust $strict $const_generic -i ${1}.svd
12+
RUST_BACKTRACE=1 svd2rust $strict $const_generic -i ${1}.svd
1413

1514
mv lib.rs src/lib.rs
1615

1716
popd
1817

19-
cargo check --manifest-path $td/Cargo.toml
18+
cargo $COMMAND --manifest-path $td/Cargo.toml
2019
}
2120

2221
test_svd_for_target() {
2322
curl -L --output $td/input.svd $2
2423

2524
# NOTE we care about errors in svd2rust, but not about errors / warnings in rustfmt
26-
local cwd=$(pwd)
2725
pushd $td
28-
RUST_BACKTRACE=1 $cwd/target/$TARGET/release/svd2rust $strict $const_generic --target $1 -i input.svd
26+
RUST_BACKTRACE=1 svd2rust --target $1 -i input.svd
2927

3028
mv lib.rs src/lib.rs
3129

3230
popd
3331

34-
cargo check --manifest-path $td/Cargo.toml
32+
cargo $COMMAND --manifest-path $td/Cargo.toml
3533
}
3634

3735
main() {
38-
# Ensure that `cargo test` works to avoid surprising people, though it
39-
# doesn't help with our actual coverage.
40-
cargo test
41-
42-
if [ $TRAVIS_OS_NAME = windows ]; then
43-
cargo check --target $TARGET
44-
return
45-
fi
46-
47-
cargo check --target $TARGET
48-
4936
if [ -z ${VENDOR-} ]; then
5037
return
5138
fi
5239

53-
if [ $VENDOR = rustfmt ]; then
54-
cargo fmt --all -- --check
55-
return
56-
fi
57-
58-
if [ -z ${FEATURES-} ]; then
59-
cargo build --target $TARGET --release
60-
else
61-
cargo build --target $TARGET --release --features $FEATURES
62-
fi
63-
64-
case $TRAVIS_OS_NAME in
65-
linux)
66-
td=$(mktemp -d)
67-
;;
68-
osx)
69-
td=$(mktemp -d -t tmp)
70-
;;
71-
esac
40+
td=$(mktemp -d)
7241

7342
case $OPTIONS in
7443
all)
@@ -91,9 +60,9 @@ main() {
9160

9261
# test crate
9362
cargo init --name foo $td
94-
echo 'cortex-m = "0.7.0"' >> $td/Cargo.toml
95-
echo 'cortex-m-rt = "0.6.13"' >> $td/Cargo.toml
96-
echo 'vcell = "0.1.2"' >> $td/Cargo.toml
63+
echo 'cortex-m = "0.7.4"' >> $td/Cargo.toml
64+
echo 'cortex-m-rt = "0.7.1"' >> $td/Cargo.toml
65+
echo 'vcell = "0.1.3"' >> $td/Cargo.toml
9766
echo '[profile.dev]' >> $td/Cargo.toml
9867
echo 'incremental = false' >> $td/Cargo.toml
9968

0 commit comments

Comments
 (0)