-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (116 loc) · 3.65 KB
/
Copy pathci.yml
File metadata and controls
139 lines (116 loc) · 3.65 KB
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
name: CI
on:
push:
branches: [ main, develop ]
paths:
- '**.rs'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/ci.yml'
pull_request:
branches: [ main, develop ]
paths:
- '**.rs'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/ci.yml'
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint with prek
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache prek binary
id: cache-prek
uses: actions/cache@v4
with:
path: ~/.local/bin/prek
key: prek-${{ runner.os }}-latest
- name: Install prek
if: steps.cache-prek.outputs.cache-hit != 'true'
run: |
curl -LsSf https://github.com/j178/prek/releases/latest/download/prek-installer.sh | sh
- name: Add prek to PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Run prek
run: prek run --all-files
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable]
include:
# Only run on Linux for PR, all platforms for push to main
- os: ubuntu-latest
rust: stable
steps:
- uses: actions/checkout@v4
# Skip macOS and Windows tests on pull requests
- name: Check if should run
id: should-run
run: |
if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ matrix.os }}" != "ubuntu-latest" ]; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Install Rust
if: steps.should-run.outputs.skip != 'true'
uses: dtolnay/rust-toolchain@stable
- name: Rust Cache
if: steps.should-run.outputs.skip != 'true'
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.os }}-${{ matrix.rust }}
- name: Build
if: steps.should-run.outputs.skip != 'true'
run: cargo build --verbose
- name: Run tests
if: steps.should-run.outputs.skip != 'true'
run: cargo test --verbose
coverage:
name: Code Coverage
runs-on: ubuntu-latest
# Only run coverage on push to main branch
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Cache tarpaulin binary
id: cache-tarpaulin
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cargo-tarpaulin
key: tarpaulin-${{ runner.os }}-0.31.2
- name: Install tarpaulin
if: steps.cache-tarpaulin.outputs.cache-hit != 'true'
run: cargo install cargo-tarpaulin --version 0.31.2
- name: Run tarpaulin
run: cargo tarpaulin --verbose --all-features --workspace --timeout 120 --out xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run cargo audit
uses: rustsec/audit-check@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}