-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (146 loc) · 4.64 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
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
155
156
157
158
159
160
161
162
163
164
on:
workflow_dispatch:
pull_request:
push:
branches: [ "master" ]
schedule:
# Run at 8 AM, on sundays
- cron: '0 8 * * 0'
name: CI
env:
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
RUST_BACKTRACE: 1
jobs:
check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: ["aarch64-apple-darwin",
"aarch64-unknown-linux-musl",
"aarch64-pc-windows-msvc",
"arm-unknown-linux-musleabihf",
"armv7-unknown-linux-musleabihf",
"x86_64-apple-darwin",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl",
"x86_64-pc-windows-msvc"]
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- run: cargo check --target ${{ matrix.target }} --all-targets
typos:
name: Spellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check spelling of entire workspace
uses: crate-ci/typos@v1.28.3
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rustsec/audit-check@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
build-test:
name: Test Suite (native)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-2022]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo build
- run: cargo test --workspace
cross-build-test:
name: Test Suite (Cross)
env:
CROSS_VERSION: v0.2.5
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: ["aarch64-unknown-linux-musl",
"arm-unknown-linux-musleabihf",
"armv7-unknown-linux-musleabihf"]
steps:
- uses: actions/checkout@v4
- name: Install Cargo Cross
run: |
curl -LO "https://github.com/cross-rs/cross/releases/download/${{ env.CROSS_VERSION }}/cross-x86_64-unknown-linux-musl.tar.gz"
tar xf cross-x86_64-unknown-linux-musl.tar.gz
- name: Build ${{ matrix.target }}
run: ./cross build --verbose --workspace --target ${{ matrix.target }}
- name: Test ${{ matrix.target }}
run: ./cross test --verbose --workspace --target ${{ matrix.target }}
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all -- --check
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --workspace -- -D warnings -W clippy::all
tag-release:
needs: [check, typos, audit, build-test, cross-build-test, format, lint]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
permissions:
contents: write
outputs:
new_tag_created: ${{ steps.create_tag.outputs.new_tag_created }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_WITH_REPO_SCOPE }}
- name: Get version from Cargo.toml
run: |
VERSION=$(grep '^version = ' Cargo.toml | cut -d '"' -f 2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Check if tag exists
run: |
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
echo "TAG_EXISTS=true" >> $GITHUB_ENV
else
echo "TAG_EXISTS=false" >> $GITHUB_ENV
fi
- name: Create and push tag
id: create_tag
if: env.TAG_EXISTS == 'false'
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git tag -a "v${{ env.VERSION }}" -m "Release v${{ env.VERSION }}"
git push origin "v${{ env.VERSION }}"
echo "new_tag_created=true" >> $GITHUB_OUTPUT
release-crates-io:
needs: tag-release
if: needs.tag-release.outputs.new_tag_created == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Publish
run: cargo publish --token ${{ secrets.CARGO_PUBLISH_TOKEN }}