-
Notifications
You must be signed in to change notification settings - Fork 2
154 lines (138 loc) · 5.2 KB
/
rust.yml
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
name: Rust
on:
push:
branches:
- main
pull_request:
release:
types: [published]
workflow_dispatch:
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true
env:
MSRV: "1.74"
PYTHON_VERSION: "3.10"
CARGO_TERM_COLOR: always
LIB_PACKAGE_NAME: pyo3_bindgen
CLI_PACKAGE_NAME: pyo3_bindgen_cli
ENGINE_PACKAGE_NAME: pyo3_bindgen_engine
MACROS_PROCEDURAL_PACKAGE_NAME: pyo3_bindgen_macros
jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
## cargo fmt
- name: cargo fmt
run: cargo fmt --all --check --verbose
cargo:
needs: rustfmt
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- MSRV
- stable
- beta
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name == 'push'}}
- uses: dtolnay/rust-toolchain@master
if: ${{ matrix.toolchain != 'MSRV' && matrix.toolchain != 'stable' }}
with:
toolchain: ${{ matrix.toolchain }}
- uses: dtolnay/rust-toolchain@master
if: ${{ matrix.toolchain == 'MSRV' }}
with:
toolchain: ${{ env.MSRV }}
- uses: dtolnay/rust-toolchain@master
if: ${{ matrix.toolchain == 'stable' }}
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
## cargo check
- name: cargo check
run: cargo check --workspace --all-targets --verbose
- name: cargo check --no-default-features
run: cargo check --workspace --all-targets --no-default-features --verbose
- name: cargo check --all-features
run: cargo check --workspace --all-targets --all-features --verbose
## cargo test
- name: cargo test
run: cargo test --workspace --all-targets --verbose
- name: cargo test --no-default-features
run: cargo test --workspace --all-targets --no-default-features --verbose
- name: cargo test --all-features
run: cargo test --workspace --all-targets --all-features --verbose
## cargo test --doc
- name: cargo test --doc
run: cargo test --workspace --doc --verbose
- name: cargo test --doc --no-default-features
run: cargo test --workspace --doc --no-default-features --verbose
- name: cargo test --doc --all-features
run: cargo test --workspace --doc --all-features --verbose
## [stable] cargo clippy
- name: stable | cargo clippy
if: ${{ matrix.toolchain == 'stable' }}
run: cargo clippy --workspace --all-targets --all-features --no-deps --verbose -- --deny warnings
## [stable] cargo doc
- name: stable | cargo doc --document-private-items
if: ${{ matrix.toolchain == 'stable' }}
run: cargo doc --workspace --all-features --no-deps --document-private-items --verbose
## [stable] Code coverage
- name: stable | Install cargo llvm-cov for code coverage
uses: taiki-e/install-action@cargo-llvm-cov
if: ${{ matrix.toolchain == 'stable' }}
## [stable] Generate coverage with cargo llvm-cov
- name: stable | Generate coverage
if: ${{ matrix.toolchain == 'stable' }}
run: cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info
## [stable] Upload coverage to codecov.io
- name: stable | Upload coverage
if: ${{ matrix.toolchain == 'stable' }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: false
deny:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check bans licenses sources
publish:
if: ${{ github.event_name == 'release' }}
needs:
- cargo
- deny
runs-on: ubuntu-latest
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
## Publish to crates.io
- name: Publish crate (engine)
if: ${{ env.CARGO_REGISTRY_TOKEN != '' }}
run: cargo publish --no-verify --package ${{ env.ENGINE_PACKAGE_NAME }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish crate (procedural macros)
if: ${{ env.CARGO_REGISTRY_TOKEN != '' }}
run: cargo publish --no-verify --package ${{ env.MACROS_PROCEDURAL_PACKAGE_NAME }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish crate (public API)
if: ${{ env.CARGO_REGISTRY_TOKEN != '' }}
run: cargo publish --no-verify --package ${{ env.LIB_PACKAGE_NAME }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish crate (CLI tool)
if: ${{ env.CARGO_REGISTRY_TOKEN != '' }}
run: cargo publish --no-verify --package ${{ env.CLI_PACKAGE_NAME }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}