-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (58 loc) · 1.69 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
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "*" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
env:
CODE_COV_VAL: '0'
steps:
- name: Clone main repository
uses: actions/checkout@v4
- uses: moonrepo/setup-rust@v1
with:
components: rustfmt
cache: false
name: Setup Rust Toolchain
- uses: Swatinem/rust-cache@v2
name: Cache Rust Dependencies
- run: export RUSTFLAGS="-D warnings" && cargo build
name: Run build scripts
- name: Check Format
run: cargo fmt --check
working-directory: .
- name: Run Clippy
run: rustup component add clippy && cargo clippy
working-directory: .
- name: Install dependencies
run: sudo apt-get install -y musl-tools
- name: Install tarpaulin
run: cargo install cargo-tarpaulin
- name: Run tests with coverage
run: |
cargo tarpaulin --lib --out Html --output-dir target/debug/tarpaulin/ -- --nocapture > test.log
LAST_LINE=$( tail -n 1 test.log)
CODE_COV=$(echo "$LAST_LINE" | cut -d '%' -f 1)
echo "CODE_COV: $CODE_COV"
COLOR=$(
float=$(echo "$CODE_COV" | bc)
threshold=80.0
if (( $(echo "$float > $threshold" | bc -l) )); then
echo "brightgreen"
else
echo "yellow"
fi
)
echo "COLOR: $COLOR"
sh ./scripts/gen_svg.sh $COLOR $CODE_COV
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/debug/tarpaulin/
publish_branch: gh-pages