-
-
Notifications
You must be signed in to change notification settings - Fork 1
231 lines (179 loc) · 7.15 KB
/
build-test-and-lint.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
## Workflow triggered by pull_request and pushes on master branch
# Due to limitations we are checking compilation but testing everything on the Ubuntu environment only.
name: build-test-and-lint
on:
push:
branches: [ "master", "release/*" ]
pull_request:
branches: [ master ]
types: [opened, reopened, synchronize, ready_for_review]
schedule:
# Run on the 3rd of every month at 2:01
- cron: '1 2 3 * *'
workflow_dispatch:
inputs:
branch_commit_or_ref:
description: 'Run this workflow in what branch/commit?'
required: true
type: string
default: master
jobs:
run_when:
# it succeeds if any of the following conditions are met:
# - when the PR is not a draft and is not labeled 'prevent-ci'
runs-on: ubuntu-latest
if: (!github.event.pull_request.draft) && (!contains( github.event.pull_request.labels.*.name, 'prevent-ci'))
env:
JOB_GITHUB_REF: ${{ github.head_ref || github.ref }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch_commit_or_ref || '' }}
- name: Report Workflow Information
id: workflow_report
uses: ./.github/actions/workflow-info
with:
title: '${{ github.ref_name }}'
parameters: '${{ toJson(inputs) }}'
content: |
- Ref: ${{ github.head_ref }}
ci:
needs: run_when
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
channel: [ stable ]
steps:
# region Checkout and Install
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch_commit_or_ref || '' }}
- name: Rustup Self Update
if: matrix.os != 'macos-latest'
run: |
rustup self update
- name: Update Rust toolchain from channel ${{ matrix.channel }}
run: |
rustup update ${{ matrix.channel }}
rustup default ${{ matrix.channel }}
rustup component add llvm-tools
- name: Check Rust ${{ matrix.channel }} toolchain versions
run: |
printf '# Rust Information\n\n' >> "${GITHUB_STEP_SUMMARY}";
printf '## Program Versions on Channel ${{ matrix.channel }}\n\n' >> "${GITHUB_STEP_SUMMARY}";
rustup --version >> "${GITHUB_STEP_SUMMARY}";
cargo --version >> "${GITHUB_STEP_SUMMARY}";
rustc --version >> "${GITHUB_STEP_SUMMARY}";
printf '## Toolchain Information\n\n```sh\n$ rustup show\n' >> "${GITHUB_STEP_SUMMARY}";
rustup show >> "${GITHUB_STEP_SUMMARY}";
printf '\n```\n\n' >> "${GITHUB_STEP_SUMMARY}";
printf '\n\n## Cargo Commands\n\n```sh\n$ cargo --list\n' >> "${GITHUB_STEP_SUMMARY}";
cargo --list >> "${GITHUB_STEP_SUMMARY}";
printf '\n```\n\n' >> "${GITHUB_STEP_SUMMARY}";
# endregion
# region Testing
- name: Run cargo check
run: cargo check --all-features
- name: Run Solr for testing
uses: hoverkraft-tech/compose-action@v2.0.1
if: matrix.os == 'ubuntu-latest'
with:
compose-file: "./docker/docker-compose.yml"
up-flags: "-d"
- name: Run cargo test
run: cargo test
# endregion
# region Linting
- name: Run cargo clippy
if: matrix.os == 'ubuntu-latest'
continue-on-error: true # show all errors
run: cargo clippy --all-features
- name: Check source code for future incompatibilities
id: report_future_incompatibilities
if: matrix.os == 'ubuntu-latest'
run: |
echo '::group::Checking Future Incompatibilities';
printf '# Future Incompatibilities\n\n' >> "${GITHUB_STEP_SUMMARY}";
printf '<!-- markdownlint-disable-file MD009 MD027 MD028 MD034 -->\n## Compilation\n\n' >> "${GITHUB_STEP_SUMMARY}";
cargo check --future-incompat-report 2>&1 >> "${GITHUB_STEP_SUMMARY}";
echo '::endgroup::';
echo '::group::Reporting Future Incompatibilities';
printf '\n## Future Incompatibilities Report\n\n' >> "${GITHUB_STEP_SUMMARY}";
if cargo report future-incompatibilities --color never >> "${GITHUB_STEP_SUMMARY}"; then
echo "FUTURE_INCOMPATIBILITIES=1" >> "${GITHUB_OUTPUT}";
echo "::warning file=Cargo.toml,line=15,col=2,endColumn=24,title=FUTURE-INCOMPATIBILITIES::Future imcompatibilities found in source code or dependencies.";
false;
else
echo "FUTURE_INCOMPATIBILITIES=0" >> "${GITHUB_OUTPUT}";
printf 'No future incompatibilities found in this build.\n' >> "${GITHUB_STEP_SUMMARY}";
fi
echo '::endgroup::';
- name: Run cargo fmt
if: matrix.os == 'ubuntu-latest'
run: cargo fmt --check
- name: Run cargo doc
if: matrix.os == 'ubuntu-latest'
run: cargo doc --no-deps --document-private-items --all-features
# endregion
# region Test Coverage
- name: Install cargo-llvm-cov
if: matrix.os == 'ubuntu-latest'
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run coverage report
if: matrix.os == 'ubuntu-latest'
run: cargo llvm-cov --all-features --workspace --lcov --no-cfg-coverage-nightly --output-path lcov.info
- name: Coveralls
if: matrix.os == 'ubuntu-latest'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: './lcov.info'
# endregion
deps:
needs: ci
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
channel: [ stable ]
steps:
# region Environment setup
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch_commit_or_ref || '' }}
- name: Update Rust toolchain from channel ${{ matrix.channel }}
run: |
rustup self update
rustup update ${{ matrix.channel }}
rustup update nightly
rustup default ${{ matrix.channel }}
- name: Check Rust ${{ matrix.channel }} toolchain versions
run: |
rustup --version
cargo --version
rustc --version
rustup show
rustup default
# endregion
# region Run security audit
- name: Intall cargo-audit from channel ${{ matrix.channel }}
run: cargo install cargo-auditable cargo-audit cargo-udeps
- name: Build with dependency lists embedded in the binaries
run: cargo auditable build --release
- name: Run security audit
run: cargo audit bin target/release/solrcopy
# endregion
# region Checking unused dependencies
- name: Print dependency tree
run: cargo tree --verbose --color never
- name: Intall cargo-udeps from channel ${{ matrix.channel }}
run: cargo install cargo-udeps
- name: Find unused dependencies in Cargo.toml
run: cargo +nightly udeps --release
# endregion
# end of file