Skip to content

Commit 978ef7b

Browse files
committed
Add cross tests
1 parent cbd6849 commit 978ef7b

File tree

4 files changed

+177
-66
lines changed

4 files changed

+177
-66
lines changed
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "cross-tests"
2+
3+
inputs:
4+
rust:
5+
required: true
6+
package:
7+
required: true
8+
target:
9+
required: true
10+
features:
11+
required: true
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions-rs/toolchain@v1
18+
with:
19+
profile: minimal
20+
toolchain: ${{ inputs.rust }}
21+
target: ${{ inputs.target }}
22+
override: true
23+
- name: Install precompiled cross
24+
run: |
25+
export URL=$(curl -s https://api.github.com/repos/rust-embedded/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url')
26+
wget -O /tmp/binaries.tar.gz $URL
27+
tar -C /tmp -xzf /tmp/binaries.tar.gz
28+
mv /tmp/cross ~/.cargo/bin
29+
shell: bash
30+
- run: |
31+
cd ${{ inputs.package }}
32+
cross test --target ${{ inputs.target }} --no-default-features \
33+
--features ${{ inputs.features }}
34+
shell: bash

.github/workflows/sha1.yml

+56-34
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: sha1
33
on:
44
pull_request:
55
paths:
6+
- ".github/workflows/sha1.yml"
67
- "sha1/**"
78
- "Cargo.*"
89
push:
@@ -13,17 +14,28 @@ defaults:
1314
working-directory: sha1
1415

1516
env:
16-
CARGO_INCREMENTAL: 0
17+
MSRV: 1.41.0
1718
RUSTFLAGS: "-Dwarnings"
19+
CARGO_INCREMENTAL: 0
1820

1921
jobs:
22+
set-msrv:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
msrv: ${{ steps.msrv.outputs.msrv }}
26+
steps:
27+
- uses: actions/checkout@v2
28+
- id: msrv
29+
run: echo "::set-output name=msrv::$(echo $MSRV)"
30+
2031
# Builds for no_std platforms
2132
build:
33+
needs: set-msrv
2234
runs-on: ubuntu-latest
2335
strategy:
2436
matrix:
2537
rust:
26-
- 1.41.0 # MSRV
38+
- ${{needs.set-msrv.outputs.msrv}}
2739
- stable
2840
target:
2941
- thumbv7em-none-eabi
@@ -40,28 +52,29 @@ jobs:
4052

4153
# Linux tests
4254
linux:
55+
needs: set-msrv
4356
strategy:
4457
matrix:
4558
include:
4659
# 32-bit Linux/x86
4760
# *** NOTE: Currently broken with `asm` feature enabled! See:
4861
# https://github.com/RustCrypto/hashes/issues/251
4962
#- target: i686-unknown-linux-gnu
50-
# rust: 1.41.0 # MSRV
63+
# rust: ${{needs.set-msrv.outputs.msrv}}
5164
# deps: sudo apt update && sudo apt install gcc-multilib
5265
#- target: i686-unknown-linux-gnu
5366
# rust: stable
5467
# deps: sudo apt update && sudo apt install gcc-multilib
5568

5669
# 64-bit Linux/x86_64
5770
- target: x86_64-unknown-linux-gnu
58-
rust: 1.41.0 # MSRV
71+
rust: ${{needs.set-msrv.outputs.msrv}}
5972
- target: x86_64-unknown-linux-gnu
6073
rust: stable
6174

6275
runs-on: ubuntu-latest
6376
steps:
64-
- uses: actions/checkout@v1
77+
- uses: actions/checkout@v2
6578
- uses: actions-rs/toolchain@v1
6679
with:
6780
profile: minimal
@@ -76,15 +89,16 @@ jobs:
7689

7790
# macOS tests
7891
macos:
92+
needs: set-msrv
7993
strategy:
8094
matrix:
8195
toolchain:
82-
- 1.41.0 # MSRV
96+
- ${{needs.set-msrv.outputs.msrv}}
8397
- stable
8498

8599
runs-on: macos-latest
86100
steps:
87-
- uses: actions/checkout@v1
101+
- uses: actions/checkout@v2
88102
- uses: actions-rs/toolchain@v1
89103
with:
90104
profile: minimal
@@ -98,19 +112,20 @@ jobs:
98112

99113
# Windows tests
100114
windows:
115+
needs: set-msrv
101116
strategy:
102117
matrix:
103118
include:
104119
# 64-bit Windows (GNU)
105120
# TODO(tarcieri): try re-enabling this when we bump MSRV
106121
#- target: x86_64-pc-windows-gnu
107-
# toolchain: 1.41.0 # MSRV
122+
# toolchain: ${{needs.set-msrv.outputs.msrv}}
108123
- target: x86_64-pc-windows-gnu
109124
toolchain: stable
110125

111126
runs-on: windows-latest
112127
steps:
113-
- uses: actions/checkout@v1
128+
- uses: actions/checkout@v2
114129
- uses: actions-rs/toolchain@v1
115130
with:
116131
profile: minimal
@@ -121,28 +136,35 @@ jobs:
121136
- run: cargo test --target ${{ matrix.target }}
122137

123138
# Cross-compiled tests
124-
# *** NOTE: Currently broken with `asm` feature enabled! See:
125-
# https://github.com/RustCrypto/hashes/issues/251
126-
#
127-
# cross:
128-
# strategy:
129-
# matrix:
130-
# include:
131-
# # ARM64
132-
# - target: aarch64-unknown-linux-gnu
133-
# rust: 1.41.0 # MSRV
134-
# - target: aarch64-unknown-linux-gnu
135-
# rust: stable
136-
#
137-
# runs-on: ubuntu-latest
138-
# steps:
139-
# - uses: actions/checkout@v1
140-
# - uses: actions-rs/toolchain@v1
141-
# with:
142-
# profile: minimal
143-
# toolchain: ${{ matrix.rust }}
144-
# target: ${{ matrix.target }}
145-
# override: true
146-
# - run: cargo install cross
147-
# - run: cross test --target ${{ matrix.target }}
148-
# - run: cross test --target ${{ matrix.target }} --features asm
139+
cross:
140+
needs: set-msrv
141+
strategy:
142+
matrix:
143+
rust:
144+
- ${{needs.set-msrv.outputs.msrv}}
145+
- stable
146+
target:
147+
- aarch64-unknown-linux-gnu
148+
- mips-unknown-linux-gnu
149+
features:
150+
- default
151+
# **** NOTE: Currently broken with `asm` feature enabled! See:
152+
# https://github.com/RustCrypto/hashes/issues/251
153+
# include:
154+
# - rust: stable
155+
# target: aarch64-unknown-linux-gnu
156+
# features: asm
157+
158+
runs-on: ubuntu-latest
159+
defaults:
160+
run:
161+
# Cross mounts only current package, i.e. by default it ignores workspace's Cargo.toml
162+
working-directory: .
163+
steps:
164+
- uses: actions/checkout@v2
165+
- uses: ./.github/actions/cross-tests
166+
with:
167+
rust: ${{ matrix.rust }}
168+
package: ${{ github.workflow }}
169+
target: ${{ matrix.target }}
170+
features: ${{ matrix.features }}

.github/workflows/sha2.yml

+41-27
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: sha2
33
on:
44
pull_request:
55
paths:
6+
- ".github/workflows/sha2.yml"
67
- "sha2/**"
78
- "Cargo.*"
89
push:
@@ -13,23 +14,34 @@ defaults:
1314
working-directory: sha2
1415

1516
env:
16-
CARGO_INCREMENTAL: 0
17+
MSRV: 1.41.0
1718
RUSTFLAGS: "-Dwarnings"
19+
CARGO_INCREMENTAL: 0
1820

1921
jobs:
22+
set-msrv:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
msrv: ${{ steps.msrv.outputs.msrv }}
26+
steps:
27+
- uses: actions/checkout@v2
28+
- id: msrv
29+
run: echo "::set-output name=msrv::$(echo $MSRV)"
30+
2031
# Builds for no_std platforms
2132
build:
33+
needs: set-msrv
2234
runs-on: ubuntu-latest
2335
strategy:
2436
matrix:
2537
rust:
26-
- 1.41.0 # MSRV
38+
- ${{needs.set-msrv.outputs.msrv}}
2739
- stable
2840
target:
2941
- thumbv7em-none-eabi
3042
- wasm32-unknown-unknown
3143
steps:
32-
- uses: actions/checkout@v1
44+
- uses: actions/checkout@v2
3345
- uses: actions-rs/toolchain@v1
3446
with:
3547
profile: minimal
@@ -40,26 +52,27 @@ jobs:
4052

4153
# Linux tests
4254
linux:
55+
needs: set-msrv
4356
strategy:
4457
matrix:
4558
include:
4659
# 32-bit Linux/x86
4760
- target: i686-unknown-linux-gnu
48-
rust: 1.41.0 # MSRV
61+
rust: ${{needs.set-msrv.outputs.msrv}}
4962
deps: sudo apt update && sudo apt install gcc-multilib
5063
- target: i686-unknown-linux-gnu
5164
rust: stable
5265
deps: sudo apt update && sudo apt install gcc-multilib
5366

5467
# 64-bit Linux/x86_64
5568
- target: x86_64-unknown-linux-gnu
56-
rust: 1.41.0 # MSRV
69+
rust: ${{needs.set-msrv.outputs.msrv}}
5770
- target: x86_64-unknown-linux-gnu
5871
rust: stable
5972

6073
runs-on: ubuntu-latest
6174
steps:
62-
- uses: actions/checkout@v1
75+
- uses: actions/checkout@v2
6376
- uses: actions-rs/toolchain@v1
6477
with:
6578
profile: minimal
@@ -74,15 +87,16 @@ jobs:
7487

7588
# macOS tests
7689
macos:
90+
needs: set-msrv
7791
strategy:
7892
matrix:
7993
toolchain:
80-
- 1.41.0 # MSRV
94+
- ${{needs.set-msrv.outputs.msrv}}
8195
- stable
8296

8397
runs-on: macos-latest
8498
steps:
85-
- uses: actions/checkout@v1
99+
- uses: actions/checkout@v2
86100
- uses: actions-rs/toolchain@v1
87101
with:
88102
profile: minimal
@@ -95,6 +109,7 @@ jobs:
95109

96110
# Windows tests
97111
windows:
112+
needs: set-msrv
98113
strategy:
99114
matrix:
100115
include:
@@ -107,7 +122,7 @@ jobs:
107122

108123
runs-on: windows-latest
109124
steps:
110-
- uses: actions/checkout@v1
125+
- uses: actions/checkout@v2
111126
- uses: actions-rs/toolchain@v1
112127
with:
113128
profile: minimal
@@ -119,33 +134,32 @@ jobs:
119134

120135
# Cross-compiled tests
121136
cross:
137+
needs: set-msrv
122138
strategy:
123139
matrix:
140+
rust:
141+
- ${{needs.set-msrv.outputs.msrv}}
142+
- stable
143+
target:
144+
- aarch64-unknown-linux-gnu
145+
- mips-unknown-linux-gnu
146+
features:
147+
- default
124148
include:
125-
# ARM64
126-
#- target: aarch64-unknown-linux-gnu
127-
# rust: 1.41.0 # MSRV
128-
- target: aarch64-unknown-linux-gnu
129-
rust: stable
149+
- rust: stable
150+
target: aarch64-unknown-linux-gnu
151+
features: asm
130152

131153
runs-on: ubuntu-latest
132154
defaults:
133155
run:
134156
# Cross mounts only current package, i.e. by default it ignores workspace's Cargo.toml
135157
working-directory: .
136158
steps:
137-
- uses: actions/checkout@v1
138-
- uses: actions-rs/toolchain@v1
159+
- uses: actions/checkout@v2
160+
- uses: ./.github/actions/cross-tests
139161
with:
140-
profile: minimal
141-
toolchain: ${{ matrix.rust }}
162+
rust: ${{ matrix.rust }}
163+
package: ${{ github.workflow }}
142164
target: ${{ matrix.target }}
143-
override: true
144-
- name: Install precompiled cross
145-
run: |
146-
export URL=$(curl -s https://api.github.com/repos/rust-embedded/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url')
147-
wget -O /tmp/binaries.tar.gz $URL
148-
tar -C /tmp -xzf /tmp/binaries.tar.gz
149-
mv /tmp/cross ~/.cargo/bin
150-
- run: cross test --package sha2 --target ${{ matrix.target }}
151-
- run: cross test --package sha2 --target ${{ matrix.target }} --features asm
165+
features: ${{ matrix.features }}

0 commit comments

Comments
 (0)