Repository navigation
80 lines (69 loc) · 2.17 KB
/
Copy pathrust.yml
File metadata and controls
80 lines (69 loc) · 2.17 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
name: Rust Checks
on:
pull_request:
types: [opened, synchronize]
branches:
- main
permissions:
contents: read
concurrency:
group: rust-checks-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
changed-files:
name: Check Changed Files
runs-on: ubuntu-latest
outputs:
any_changed: ${{ steps.changed.outputs.any_changed }}
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Check if any Rust files have changed
id: changed
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: |
**.rs
**Cargo.toml
**Cargo.lock
lint-and-test:
runs-on: ubuntu-latest
needs: changed-files
if: needs.changed-files.outputs.any_changed == 'true'
strategy:
fail-fast: false
matrix:
job: [format, lint, test]
include:
- job: format
command: cargo fmt --all -- --check
- job: lint
command: cargo clippy --all-targets --all-features -- -D warnings
- job: test
command: cargo test --all-targets --all-features
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Problem Matchers
run: echo "::add-matcher::${{ github.workspace }}/.github/matchers.json"
- name: Cache Rust Workspace
uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Run ${{ matrix.job }}
run: ${{ matrix.command }}
aggregate:
name: Lint and Test Rust
runs-on: ubuntu-latest
needs: lint-and-test
if: ${{ !cancelled() }}
steps:
- name: All checks have passed
if: ${{ !contains(needs.*.result, 'failure') }}
run: |
echo "All Rust checks have passed successfully."
exit 0
- name: Some checks failed
if: ${{ contains(needs.*.result, 'failure') }}
run: |
echo "Some Rust checks failed. Please review the logs above."
exit 1