-
Notifications
You must be signed in to change notification settings - Fork 1
145 lines (116 loc) · 3.46 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
name: 'Rust: Build and Test'
on:
push:
branches:
- master
workflow_dispatch:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
features:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: cargo install cargo-hack
- name: Run cargo check on all features
run: cargo hack check --each-feature --all-targets
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Run rustfmt
run: cargo fmt --all -- --check
- name: Run clippy
env:
RUSTFLAGS: -C debuginfo=0
run: |
cargo clippy --all-features
- name: Install audit
run: cargo install cargo-audit
- name: Run audit
run: cargo audit -f Cargo.lock
test:
runs-on: ${{ matrix.os }}
needs: ["lint", "features"]
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Run tests
env:
RUSTFLAGS: -C debuginfo=0
run: cargo test --all-features
coverage:
runs-on: ubuntu-latest
needs: ["lint", "features"]
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --codecov --output-path codecov.json
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: promised-ai/rv
semver-checks:
runs-on: ubuntu-latest
needs: ["features", "lint" ]
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
path: branch
- name: Checkout master
uses: actions/checkout@v4
with:
ref: master
path: master
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- 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/Cargo.toml --baseline-root master/ --verbose
release:
name: release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: ["features", "lint", "test", "semver-checks", "coverage"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Branch
env:
NEW_VERSION: ${{github.ref_name}}
run: |
git fetch origin master
git tag --merged origin/master | grep $NEW_VERSION
- uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: cargo install cargo-crate
- name: Publish Updated Library Crates to Crates.io
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
run: cargo publish --token "${CRATES_TOKEN}"