-
-
Notifications
You must be signed in to change notification settings - Fork 18
169 lines (145 loc) · 4.48 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
name: CI
on:
pull_request:
push:
branches:
- main
- rustdoc-v*
env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
jobs:
ci-everything:
name: All CI stages
runs-on: ubuntu-latest
needs:
- lint
- rust-tests
if: ${{ success() || failure() }} # Run this job even if a dependency has failed.
steps:
- name: Job outcomes
run: |
echo "lint: ${{ needs.lint.result }}"
echo "rust-tests: ${{ needs.rust-tests.result }}"
# Fail this required job if any of its dependent jobs have failed.
#
# Do not attempt to consolidate these steps into one step, it won't work.
# Multi-line `if` clauses are not evaluated properly: see the intermediate commits in
# https://github.com/obi1kenobi/cargo-semver-checks/pull/405
- if: ${{ needs.lint.result != 'success' }}
run: exit 1
- if: ${{ needs.rust-tests.result != 'success' }}
run: exit 1
lint:
name: Check lint and rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy
rustflags: ""
- name: cargo clippy
run: cargo clippy --workspace --all-features --all-targets -- -D warnings -Dclippy::print_stdout -Dclippy::print_stderr -Dclippy::dbg_macro --allow deprecated
- name: cargo fmt
run: cargo fmt -- --check
- name: cargo doc
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --workspace --all-features --no-deps --document-private-items
rust-tests:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
toolchain: ["1.82"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
rustflags: ""
- name: Regenerate test data
run: ./scripts/regenerate_test_rustdocs.sh +${{ matrix.toolchain }}
- name: compile
run: cargo test --no-run
- name: test
run: cargo test
- name: compile with rayon
run: cargo test --no-run --features rayon
- name: test with rayon
run: cargo test --features rayon
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs:
- should-publish
- ci-everything
- pre-publish-checks
if: needs.should-publish.outputs.is_new_version == 'yes' && startsWith(github.ref, 'refs/heads/rustdoc-v')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: true
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: false
rustflags: ""
- name: Tag the version
run: |
set -euxo pipefail
export CURRENT_VERSION="$(./scripts/get_current_version.sh trustfall-rustdoc-adapter)"
git tag "v$CURRENT_VERSION"
git push origin "v$CURRENT_VERSION"
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish
should-publish:
name: Check if version changed
runs-on: ubuntu-latest
outputs:
is_new_version: ${{ steps.check.outputs.is_new_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- id: check
run: |
set +e
./scripts/is_version_already_uploaded.sh trustfall-rustdoc-adapter
export EXIT_CODE="$?"
set -e
if [[ "$EXIT_CODE" == "7" ]]; then
echo "is_new_version=no" >> $GITHUB_OUTPUT
elif [[ "$EXIT_CODE" == "0" ]]; then
echo "is_new_version=yes" >> $GITHUB_OUTPUT
else
# Unexpected outcome, indicates a bug.
exit "$EXIT_CODE"
fi
pre-publish-checks:
name: Check for semver compliance
runs-on: ubuntu-latest
needs:
- ci-everything
- should-publish
if: needs.should-publish.outputs.is_new_version == 'yes'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2