-
Notifications
You must be signed in to change notification settings - Fork 1
172 lines (160 loc) · 5.74 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
name: ci
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUST_TOOLCHAIN_VERSION: 1.76
DPRINT_VERSION: 0.45.0
DENY_VERSION: 0.14.15
GRCOV_VERSION: 0.8.19
SCCACHE_VERSION: 0.7.7
SCCACHE_CACHE_KEY: v1
# TODO ensure config scheme is up to date
# TODO https://github.com/obi1kenobi/cargo-semver-checks-action
# TODO semantic commits for changelog and version
# TODO if it's a tag build disable sccache
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup tools path
run: |
CARGO_INSTALL_ROOT=${{ runner.temp }}/cache
echo "CARGO_INSTALL_ROOT=${CARGO_INSTALL_ROOT}" >> "${GITHUB_ENV}"
echo "${CARGO_INSTALL_ROOT}/bin" >> "${GITHUB_PATH}"
shell: bash
- name: Cache tools
uses: actions/cache@v4
id: cache-tools
with:
path: ${{ env.CARGO_INSTALL_ROOT }}
key: tools-dprint-${{ env.DPRINT_VERSION }}-deny-${{ env.DENY_VERSION }}-${{ hashFiles('dprint.json') }}
- name: Install tools
if: steps.cache-tools.outputs.cache-hit != 'true'
run: |
cargo install --locked 'dprint@${{ env.DPRINT_VERSION }}'
cargo install --locked 'cargo-deny@${{ env.DENY_VERSION }}'
- name: Check formatting
run: dprint check
- name: Check deny
run: cargo deny --all-features check bans licenses sources
- name: Check advisories
run: cargo deny --all-features check advisories
continue-on-error: true
main:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
component: clippy
- os: ubuntu-22.04
target: x86_64-unknown-linux-musl
- os: macos-12
target: x86_64-apple-darwin
- os: macos-14
target: aarch64-apple-darwin
- os: windows-2022
target: x86_64-pc-windows-msvc
rustflags: -C target-feature=+crt-static
runs-on: ${{ matrix.os }}
name: ${{ matrix.target }}
steps:
- uses: actions/checkout@v4
- name: Install toolchain
run: |
# TODO make clippy optional
rustup toolchain install --profile minimal ${{ env.RUST_TOOLCHAIN_VERSION }} -t ${{ matrix.target }} --no-self-update -c llvm-tools-preview -c clippy
rustup default ${{ env.RUST_TOOLCHAIN_VERSION }}
- name: Setup tools path
run: |
CARGO_INSTALL_ROOT=${{ runner.temp }}/cache
echo "CARGO_INSTALL_ROOT=${CARGO_INSTALL_ROOT}" >> "${GITHUB_ENV}"
echo "${CARGO_INSTALL_ROOT}/bin" >> "${GITHUB_PATH}"
shell: bash
- name: Cache tools
uses: actions/cache@v4
id: cache-tools
with:
path: ${{ env.CARGO_INSTALL_ROOT }}
key: tools-grcov-${{ env.GRCOV_VERSION }}-sccache-${{ env.SCCACHE_VERSION }}-${{ matrix.os }}
- name: Install tools
if: steps.cache-tools.outputs.cache-hit != 'true'
run: |
cargo install --locked 'grcov@${{ env.GRCOV_VERSION }}'
cargo install --locked 'sccache@${{ env.SCCACHE_VERSION }}'
- name: Configure sccache
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Start sccache server
run: sccache --start-server
env:
SCCACHE_GHA_VERSION: ${{ env.SCCACHE_CACHE_KEY }}
SCCACHE_IDLE_TIMEOUT: 0
- name: Fetch
run: cargo fetch
- name: Build tests
run: cargo build --tests --target ${{ matrix.target }}
env:
RUSTFLAGS: -C instrument-coverage
RUSTC_WRAPPER: sccache
- run: sccache --show-stats && sccache -z
- name: Test
run: cargo test --target ${{ matrix.target }}
env:
RUSTFLAGS: -C instrument-coverage
- name: Run grcov
run: grcov . -s . --binary-path target/${{ matrix.target }}/debug --llvm --branch -t lcov -o lcov.info --keep-only "src/*"
- name: Publish code coverage
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: ${{ matrix.target }}
file: lcov.info
- name: Clippy
if: ${{ matrix.component == 'clippy' }}
run: cargo clippy --all-targets -- -D warnings
env:
RUSTC_WRAPPER: sccache
- run: sccache --show-stats && sccache -z
if: ${{ matrix.component == 'clippy' }}
- name: Build release
run: cargo build --release --target ${{ matrix.target }}
env:
RUSTFLAGS: ${{ matrix.rustflags }}
RUSTC_WRAPPER: sccache
- run: sccache --show-stats && sccache -z
- name: Upload
uses: actions/upload-artifact@v4
with:
name: havocompare-${{ matrix.target }}
path: target/${{ matrix.target }}/release/havocompare${{ startsWith(matrix.os, 'windows') && '.exe' || '' }}
if-no-files-found: error
publish:
name: publish
runs-on: ubuntu-22.04
needs: main
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: Cargo.toml
- name: Download
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: havocompare-*
- run: ls -larth
- run: ls -larth artifacts
- name: Create release
run: |
# TODO - check version: tag vs cargo toml
gh --version
# if: ${{ startsWith(github.ref, 'refs/tags/') }}