-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (82 loc) · 3.03 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
name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-C instrument-coverage"
LLVM_PROFILE_FILE: "target/profile/traq-bot-http-rs-%p-%m.profraw"
CARGO_UDEPS_VERSION: "0.1.43"
GRCOV_VERSION: "0.8.19"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Build
run: |
cargo build --workspace
cargo build --package traq-bot-http --no-default-features
cargo build --package traq-bot-http --features time
cargo build --package traq-bot-http --features 'uuid chrono'
cargo build --package traq-bot-http --features http
cargo build --package traq-bot-http --all-features
- name: Lint
run: |
cargo clippy --workspace -- -D warnings
cargo clippy --package traq-bot-http --no-default-features -- -D warnings
cargo clippy --package traq-bot-http --features 'uuid time' -- -D warnings
cargo clippy --package traq-bot-http --features 'chrono http' -- -D warnings
cargo clippy --package traq-bot-http --all-features -- -D warnings
- name: Format
run: |
cargo fmt --all --check
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Install grcov
run: |
curl -sSL -o grcov.tar.bz2 https://github.com/mozilla/grcov/releases/download/v${GRCOV_VERSION}/grcov-x86_64-unknown-linux-gnu.tar.bz2
tar -jxf grcov.tar.bz2
rm grcov.tar.bz2
- name: Clean # not to use old coverage
run: cargo clean
- name: Run tests
run: |
mkdir -p target/profile
cargo test
cargo test --features time
cargo test --all-features
- name: generate LCOV
run: |
./grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/coverage.lcov
- name: Upload coverage to Codecov
if: github.repository_owner == 'H1rono' || github.repository_owner == 'h1rono'
uses: codecov/codecov-action@v5
with:
files: target/coverage.lcov
token: ${{ secrets.CODECOV_TOKEN }}
check-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cargo-udeps
run: |
export UDEPS_ASSET_NAME="cargo-udeps-v${CARGO_UDEPS_VERSION}-x86_64-unknown-linux-gnu"
curl -sSL -o cargo-udeps.tar.gz https://github.com/est31/cargo-udeps/releases/download/v${CARGO_UDEPS_VERSION}/${UDEPS_ASSET_NAME}.tar.gz
tar -xf cargo-udeps.tar.gz
install -m 755 ${UDEPS_ASSET_NAME}/cargo-udeps /usr/local/bin/cargo-udeps
rm -rf cargo-udeps.tar.gz ${UDEPS_ASSET_NAME}
- name: Check udeps
run: |
rustup toolchain install nightly
cargo +nightly udeps