-
Notifications
You must be signed in to change notification settings - Fork 1
162 lines (133 loc) · 3.71 KB
/
rust-build-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: 'Rust: Build and Test'
on:
push:
branches:
- main
- master
workflow_dispatch:
pull_request:
paths:
- 'changepoint/**'
- '.github/workflows/rust-build-test.yaml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
features:
runs-on: ubuntu-latest
defaults:
run:
working-directory: changepoint
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: cargo install cargo-hack
- name: Run cargo hack
working-directory: changepoint
run: cargo hack check --each-feature --no-dev-deps
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: changepoint
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: changepoint
- name: Run rustfmt
run: cargo fmt --all -- --check
- name: Run clippy
env:
RUSTFLAGS: -C debuginfo=0
run: |
cargo clippy \
--all-features \
--workspace
test:
runs-on: ${{ matrix.os }}
needs: ["lint", "features"]
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
defaults:
run:
working-directory: changepoint
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: changepoint
- name: Run tests
env:
RUSTFLAGS: -C debuginfo=0
run: cargo test --workspace
# benchmark:
# name: Performance regression check
# runs-on: ubuntu-latest
# needs: ["test"]
# steps:
# - uses: actions/checkout@v3
# - name: Set up Rust
# uses: dtolnay/rust-toolchain@stable
# - name: Cache Rust
# uses: Swatinem/rust-cache@v2
# with:
# workspaces: changepoint
# - name: Run benchmark
# run: cargo bench -- --output-format bencher | tee output.txt
# - name: Store benchmark result
# uses: benchmark-action/github-action-benchmark@v1
# with:
# tool: 'cargo'
# output-file-path: output.txt
semver-checks:
runs-on: ubuntu-latest
needs: ["features", "lint", "test"]
steps:
- name: Checkout branch
uses: actions/checkout@v3
with:
path: branch
- name: Checkout master
uses: actions/checkout@v3
with:
ref: master
path: master
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Install extra cargo tools
run: cargo install cargo-semver-checks --locked
- name: Check for semver-incompatibilities
run: cargo semver-checks check-release --manifest-path branch/changepoint/Cargo.toml --baseline-root master/changepoint --verbose
release:
name: release
defaults:
run:
working-directory: changepoint
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/rust')
needs: ["semver-checks", "features", "lint", "test"]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Publish to Crates.io
run:
cargo publish --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}