-
Notifications
You must be signed in to change notification settings - Fork 8
198 lines (185 loc) · 6.32 KB
/
rust.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
name: Rust
on:
push:
branches: [ "main", "next" ]
pull_request:
branches: [ "main", "next" ]
permissions:
checks: write
contents: read
pull-requests: write
env:
CARGO_TERM_COLOR: always
jobs:
clippy:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Configure cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: test-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: giraffate/clippy-action@v1
with:
reporter: github-pr-review
github_token: ${{ secrets.GITHUB_TOKEN }}
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create local bin directory
run: mkdir -p "${HOME}/.local/bin"
- name: Download markdown-test-report
uses: robinraju/[email protected]
with:
repository: "ctron/markdown-test-report"
tag: "v0.3.8"
fileName: markdown-test-report-linux-amd64
out-file-path: tmp
- name: Install markdown-test-report
run: |
mv tmp/markdown-test-report-linux-amd64 "${HOME}/.local/bin/markdown-test-report"
chmod +x "${HOME}/.local/bin/markdown-test-report"
- name: Download grcov
uses: robinraju/[email protected]
with:
repository: "mozilla/grcov"
tag: "v0.8.18"
fileName: grcov-x86_64-unknown-linux-gnu.tar.bz2
out-file-path: tmp
- name: Install grcov
run: |
tar -xvf tmp/grcov-x86_64-unknown-linux-gnu.tar.bz2
mv grcov "${HOME}/.local/bin"
chmod +x "${HOME}/.local/bin/grcov"
- name: Set up Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-06-15
- name: Add llvm-tools
run: rustup component add llvm-tools
- name: Configure cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: test-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: cargo test --verbose -- -Z unstable-options --report-time --format json | tee test-output.json
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Cinstrument-coverage
LLVM_PROFILE_FILE: cargo-test-%p-%m.profraw
- name: Process code coverage with grcov
run: grcov . --binary-path ./target/debug/deps/ -s . -t cobertura --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/cobertura.xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: target/cobertura.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Job summary (tests)
if: ${{ always() }}
run: "[ -f test-output.json ] && markdown-test-report --no-front-matter --output - >> $GITHUB_STEP_SUMMARY"
continue-on-error: true
build-binary:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Configure cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: test-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Compile binary
run: cargo build --release
- name: Store binary artifact
uses: actions/upload-artifact@v3
with:
name: paper-age-binary
path: target/release/paper-age
visual-snapshots:
runs-on: ubuntu-latest
needs: [build-binary]
env:
PAPERAGE_PASSPHRASE: supersecret
steps:
- uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
- name: Install latest PaperAge release
uses: robinraju/[email protected]
with:
repository: "matiaskorhonen/paper-age"
latest: true
extract: true
fileName: paper-age-x86_64-unknown-linux-gnu.tar.gz
out-file-path: tmp
- name: Move the release binary to bin
run: mv tmp/paper-age bin/paper-age-release
- name: Install pdfium-cli
uses: robinraju/[email protected]
with:
repository: "klippa-app/pdfium-cli"
tag: "v0.1.1"
fileName: pdfium-linux-x64
out-file-path: bin
- name: Make PDFium executable
run: chmod u+x bin/pdfium-linux-x64
- name: Download PaperAge binary for this branch
uses: actions/download-artifact@v3
with:
name: paper-age-binary
- name: Make the binary executable
run: chmod u+x paper-age
- name: Generate PDFs
run: |
mkdir -p visual-snapshots
echo "Hello World" | ./paper-age --title="A4 secret" --page-size=a4 --output=visual-snapshots/a4-current.pdf
echo "Hello World" | ./paper-age --title="Letter secret" --page-size=letter --output=visual-snapshots/letter-current.pdf
echo "Hello World" | ./bin/paper-age-release --title="A4 secret" --page-size=a4 --output=visual-snapshots/a4-release.pdf
echo "Hello World" | ./bin/paper-age-release --title="Letter secret" --page-size=letter --output=visual-snapshots/letter-release.pdf
- name: Convert the PDFs to PNGs
run: |
for f in visual-snapshots/*.pdf; do
echo "Converting $f to PNG"
./bin/pdfium-linux-x64 render "$f" "${f%.*}.png" --combine-pages --dpi 300 --file-type png
done
- name: Generate image diffs
run: |
for f in visual-snapshots/*-current.png; do
echo "Comparing ${f/-current.png/-release.png} to $f"
npx --package=odiff-bin --yes -- odiff --parsable-stdout --threshold=0.5 "${f/-current.png/-release.png}" "$f" "${f/-current.png/-diff.png}" || true
done
- name: Save PR number
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./visual-snapshots/PR.txt
- name: Save snapshots
uses: actions/upload-artifact@v3
with:
name: visual-snapshots
path: visual-snapshots