-
Notifications
You must be signed in to change notification settings - Fork 1
198 lines (175 loc) · 8.19 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# input for CI
# https://github.com/ClementTsang/bottom/blob/master/.github/workflows/ci.yml
# https://github.com/heim-rs/heim/blob/master/.github/workflows/ci.yml
# https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/ci.yml
name: ci
on:
pull_request:
push:
branches:
- main
schedule:
- cron: '00 01 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: rustfmt
- run: cargo fmt --all -- --check
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@master
# with:
# files: ./file.txt
clippy:
# should be fine to run clippy only on one platform since there aren't many
# operating system dependent configurations (except case sensitivity setting)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: clippy
- run: cargo clippy --all-targets --workspace -- -D warnings
compile:
name: Compile ${{ matrix.tuple.build }}
needs: [rustfmt, clippy, typos]
runs-on: ${{ matrix.tuple.os }}
env:
# For some checks&builds we use cross instead of cargo.
CARGO: cargo
strategy:
fail-fast: false
matrix:
tuple:
# available VMs are documented here:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
# though it is not very visible what the actual architecture is, and therefore it is not
# clear whether or not cross can/needs to be used.
# ---
# see https://doc.rust-lang.org/nightly/rustc/platform-support.html for platform support / tiers
# see https://github.com/cross-rs/cross#supported-targets for supported targets in cross
# ---
# alternatively matrix could be shared and specified via .json
# see https://github.saobby.my.eu.orgmunity/t/how-to-share-matrix-between-jobs/128595/8
# ---
- { build: 'linux-x86_64-pinned', os: 'ubuntu-22.04', target: 'x86_64-unknown-linux-gnu', cross: false, rust: 1.82.0, archive: true }
- { build: 'windows-x86_64-pinned', os: 'windows-2019', target: 'x86_64-pc-windows-msvc', cross: false, rust: 1.82.0, archive: true }
- { build: 'macos-x86_64-pinned', os: 'macos-latest', target: 'x86_64-apple-darwin', cross: false, rust: 1.82.0, archive: true }
- { build: 'linux-x86_64', os: 'ubuntu-latest', target: 'x86_64-unknown-linux-gnu', cross: false, rust: stable, archive: false }
- { build: 'linux-i686', os: 'ubuntu-latest', target: 'i686-unknown-linux-gnu', cross: true, rust: stable, archive: false }
- { build: 'linux-arm', os: 'ubuntu-latest', target: 'aarch64-unknown-linux-gnu', cross: true, rust: stable, archive: false } # aarch64
# - { build: 'ubuntu-armv7', os: 'ubuntu-latest', target: 'armv7-unknown-linux-gnueabihf', cross: true, rust: stable, archive: false } # armv7
# - { build: 'ubuntu-armv6', os: 'ubuntu-latest', target: 'arm-unknown-linux-gnueabihf', cross: true, rust: stable, archive: false } # armv6
- { build: 'macos-x86_64', os: 'macos-latest', target: 'x86_64-apple-darwin', cross: false, rust: stable, archive: false }
# - { build: 'macos-arm', os: 'macos-latest', target: 'aarch64-apple-darwin', cross: true, rust: stable, archive: false } # arm (tier 2, not in cross)
- { build: 'windows-x86_64-msvc', os: 'windows-latest', target: 'x86_64-pc-windows-msvc', cross: false, rust: stable, archive: false }
- { build: 'windows-i686-msvc', os: 'windows-latest', target: 'i686-pc-windows-msvc', cross: false, rust: stable, archive: false }
- { build: 'windows-x86_64-mingw', os: 'windows-latest', target: 'x86_64-pc-windows-gnu', cross: false, rust: stable, archive: false }
# - { build: 'windows-i686-mingw', os: 'windows-latest', target: 'i686-pc-windows-gnu', cross: false, rust: stable, archive: false }
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Rustup update can fail on windows since it tries to replace its binary. This is not really
# needed anyhow. https://github.com/rust-lang/rustup/issues/3029
- name: Disable rustup self-update
shell: bash
run: rustup set auto-self-update disable
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
# https://github.com/dtolnay/rust-toolchain
# this specifies the rustup toolchain
toolchain: ${{ matrix.tuple.rust }}
target: ${{ matrix.tuple.target }}
- name: Install cross
if: matrix.tuple.cross != false
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
- name: Check
run: |
echo "cargo command is: ${{ env.CARGO }}"
# this runs check for the target to use for (cross) compilation (must exist in rustup)
${{ env.CARGO }} check --verbose --target=${{ matrix.tuple.target }}
- name: Build artifact
if: matrix.tuple.archive != false && github.event_name == 'pull_request'
env:
CI_PKG_VERSION_PRE_RELEASE: --alpha
CI_PKG_VERSION_BUILD: ${{ github.run_number }}
run: |
${{ env.CARGO }} build --release --target=${{ matrix.tuple.target }}
- name: Archive
if: matrix.tuple.archive != false && github.event_name == 'pull_request'
shell: bash
run: |
staging="run-clang-tidy-build-${{github.run_number}}-${{ matrix.tuple.target }}"
mkdir -p "$staging"
cp {readme.md,LICENSE} "$staging/"
if [ "${{ matrix.tuple.os }}" = "windows-latest" ]; then
cp "target/${{ matrix.tuple.target }}/release/run-clang-tidy.exe" "$staging/"
7z a "$staging.zip" "$staging"
echo "ASSET=$staging.zip" >> $GITHUB_ENV
else
cp "target/${{ matrix.tuple.target }}/release/run-clang-tidy" "$staging/"
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
- name: Archive artifacts
uses: actions/upload-artifact@v4
if: matrix.tuple.archive != false && github.event_name == 'pull_request'
with:
name: dist-${{github.run_number}}-${{ matrix.tuple.target }}
path: ${{ env.ASSET }}
retention-days: 7
tests:
name: Test ${{ matrix.os }}
needs: [compile]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
# testing on the real VMs only, not via CROSS
- ubuntu-22.04
- macos-latest
- windows-latest
toolchain:
- stable
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install packages (ubuntu)
if: matrix.os == 'ubuntu-22.04'
run: |
.github/setup/load_artifacts_ubuntu.sh
- name: Install packages (macos)
if: matrix.os == 'macos-latest'
run: |
.github/setup/load_artifacts_macos.sh
- name: Install packages (windows)
if: matrix.os == 'windows-latest'
run: |
.github/setup/load_artifacts_windows.bat
# Rustup update can fail on windows since it tries to replace its binary. This is not really
# needed anyhow. https://github.com/rust-lang/rustup/issues/3029
- name: Disable rustup self-update
shell: bash
run: rustup set auto-self-update disable
- name: Install toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
- name: Run tests
# using only one test thread to avoid race conditions on temporary files
run: cargo test --verbose --no-fail-fast -- --test-threads 1