-
Notifications
You must be signed in to change notification settings - Fork 143
101 lines (84 loc) · 2.75 KB
/
ci.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
on:
pull_request:
push:
branches:
- main
name: CI
env:
CROSS_VER: '0.2.5'
CARGO_NET_RETRY: 3
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed to fetch the full commit history
- name: Run cargo fmt
env:
TERM: xterm-256color
run: |
cargo fmt --all
- name: Check for changes
id: git_diff
run: |
git diff --quiet HEAD || echo "::set-output name=changed::true"
- name: Commit and push changes
if: steps.git_diff.outputs.changed == 'true'
run: |
git config user.name github-actions
git config user.email [email protected]
git commit -am "Automatically format code with cargo fmt"
git push
main:
needs: fmt
name: ${{ matrix.target_name }} (check, clippy)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-linux-android
target_name: Android
use_cross: true
os: ubuntu-latest
- target: x86_64-unknown-freebsd
target_name: FreeBSD
use_cross: true
os: ubuntu-latest
- target: x86_64-unknown-linux-gnu
target_name: Linux
os: ubuntu-latest
- target: x86_64-apple-darwin
target_name: macOS-x86_64
os: macos-13
- target: aarch64-apple-darwin
target_name: macOS-aarch64
os: macos-latest
- target: x86_64-unknown-netbsd
target_name: NetBSD
use_cross: true
os: ubuntu-latest
- target: x86_64-pc-windows-msvc
target_name: Windows
os: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ matrix.target }}
- name: Setup cross
if: matrix.use_cross == true
run: curl -fL --retry 3 https://github.com/cross-rs/cross/releases/download/v${{ env.CROSS_VER }}/cross-x86_64-unknown-linux-musl.tar.gz | tar vxz -C /usr/local/bin
- name: Run cargo/cross check
run: ${{ matrix.use_cross == true && 'cross' || 'cargo' }} check --locked --target ${{ matrix.target }}
- name: Run cargo/cross clippy
run: ${{ matrix.use_cross == true && 'cross' || 'cargo' }} clippy --locked --target ${{ matrix.target }} --all-features -- -D warnings
- name: Run cargo test
# ONLY run test with cargo
if: matrix.use_cross == false
run: cargo test --locked --target ${{ matrix.target }}