-
Notifications
You must be signed in to change notification settings - Fork 27
183 lines (149 loc) · 5.25 KB
/
test.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
name: tests
on:
pull_request:
push:
branches:
- main
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-Dwarnings"
FORCE_COLOR: 3
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Validate Cargo.lock is up-to-date
run: |
cargo check --workspace
git diff --exit-code
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run tests with Coverage report enabled
run: cargo llvm-cov test --all-features --workspace --codecov --locked --output-path codecov_report.json
- name: Store PR number and commit SHA
run: |
echo "Storing PR number ${{ github.event.number }}"
echo "${{ github.event.number }}" > pr_number.txt
echo "Storing commit SHA ${{ github.event.pull_request.head.sha }}"
echo "${{ github.event.pull_request.head.sha }}" > commit_sha.txt
# Workaround for https://github.com/orgs/community/discussions/25220
# Triggered sub-workflow is not able to detect the original commit/PR which is available
# in this workflow.
- name: Store PR number
uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
- name: Store commit SHA
uses: actions/upload-artifact@v4
with:
name: commit_sha
path: commit_sha.txt
# This stores the coverage report in artifacts. The actual upload to Codecov
# is executed by a different workflow `coverage-report.yml`. The reason for this
# split is because `on.pull_request` workflows don't have access to secrets.
- name: Store coverage report in artifacts
uses: actions/upload-artifact@v4
with:
name: codecov_report
path: codecov_report.json
- run: |
echo "The coverage report was stored in Github artifacts."
echo "It will be uploaded to Codecov using [coverage-report.yml] workflow shortly."
test-other-books:
strategy:
matrix:
include:
# Update the refs below once in a while.
- repo: rust-lang/book
ref: 71352deb20727b4dda9ebfe8182709d5bf17dfea
- repo: google/comprehensive-rust
ref: 981676d811927f1b50b7654ceb4cc3c10d7fe97b
name: Test with ${{ matrix.repo }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install tools
run: |
sudo apt install gettext
# Debug builds are fine and slightly faster.
cargo install --debug --path i18n-helpers
cargo install --debug --locked --version 0.4.35 mdbook
- name: Checkout ${{ matrix.repo }}
uses: actions/checkout@v4
with:
repository: ${{ matrix.repo }}
ref: ${{ matrix.ref }}
path: example-book
- name: Test extracting text
working-directory: example-book
run: |
MDBOOK_OUTPUT='{"xgettext": {"pot-file": "messages.pot"}}' mdbook build -d po
msgfmt -o /dev/null --statistics po/messages.pot
fuzz:
name: Fuzz test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install nightly Rust
run: rustup default nightly
- uses: Swatinem/rust-cache@v2
with:
# Default is "v0-rust"
# Use a separate key to prevent collision with main cache
prefix-key: "fuzz"
# Cache only on main build
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-directories: |
fuzz/target
fuzz/corpus
- name: Install cargo-fuzz
run: cargo install cargo-fuzz
- name: Run group_events fuzzer and minimize corpus
run: |
cargo fuzz run group_events -- -only_ascii=1 -max_total_time=30
cargo fuzz cmin group_events
- name: Run normalize fuzzer and minimize corpus
run: |
cargo fuzz run normalize -- -only_ascii=1 -max_total_time=30
cargo fuzz cmin normalize
- name: Run gettext fuzzer and minimize corpus
run: |
cargo fuzz run gettext -- -only_ascii=1 -max_total_time=30
cargo fuzz cmin gettext
- name: Run xgettext fuzzer and minimize corpus
run: |
cargo fuzz run xgettext -- -only_ascii=1 -max_total_time=30
cargo fuzz cmin xgettext
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Clippy
run: cargo clippy --all-targets
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust nightly
run: rustup default stable
- name: Install rustfmt
run: rustup component add rustfmt
- name: Check Formatting
uses: dprint/check@v2.2