Repository navigation
97 lines (82 loc) · 3.11 KB
/
Copy pathpull_request.yml
File metadata and controls
97 lines (82 loc) · 3.11 KB
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
name: Pipeline
# consistency regarding formatting and idiomatic Rust
on:
push:
branches:
- dev
pull_request:
branches:
- "**"
permissions:
contents: read
# a new run for the same branch or pull request cancels the outdated run
concurrency:
group: ${{ github.workflow_ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUSTDOCFLAGS: "-Dwarnings"
jobs:
pipeline:
name: Pipeline - code coverage + dependency check
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v7
- name: Setup dtolnay/rust-toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
# The native FLINT library is compiled for the CPU of the runner it is built on.
# Hence, the cache may only be reused on runners with the same CPU (model and features).
- name: Determine CPU of the runner
id: cpu
run: |
grep -m1 'model name' /proc/cpuinfo
echo "hash=$({ grep -m1 'model name' /proc/cpuinfo; grep -m1 '^flags' /proc/cpuinfo; } | sha256sum | cut -c1-16)" >> "$GITHUB_OUTPUT"
# load project cache to reduce compilation time, whose key additionally covers
# the Rust version, the Cargo.toml files, and build-relevant environment variables
- name: Setup project cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ steps.cpu.outputs.hash }}
- name: Set environment variables
run: |
echo "PROJECT_NAME=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0] | [ .name ] | join("")')" >> $GITHUB_ENV
echo "PROJECT_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0] | [ .version ] | join("")')" >> $GITHUB_ENV
- name: Update dependencies
run: cargo update
- name: Build
run: cargo build
- name: Generate docs
run: cargo doc --no-deps
- name: Run doc tests # Unit tests are run by tarpaulin
run: cargo test --doc --verbose
- name: Install cargo-tarpaulin
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-tarpaulin
- name: Calculate test coverage
run: cargo tarpaulin --out Html
- name: Archive code coverage results
uses: actions/upload-artifact@v7
with:
name: ${{ env.PROJECT_NAME }}-code_coverage_report-v${{ env.PROJECT_VERSION }}
path: tarpaulin-report.html
# Lints: Clippy and Fmt
- name: Clippy
run: cargo clippy -- -D warnings
- name: Format
run: cargo fmt --all -- --check
# Cargo check for security issues
- name: Install cargo-audit
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-audit
- name: Security audit
run: cargo audit
# Check for outdated dependencies
- name: Install cargo-outdated
uses: dtolnay/install@cargo-outdated
- name: Outdated dependencies
run: cargo outdated --root-deps-only --exit-code 1