-
-
Notifications
You must be signed in to change notification settings - Fork 157
99 lines (99 loc) · 2.74 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
name: Rust
on:
push:
branches:
- master
pull_request:
paths:
- .cargo/config.toml
- .github/workflows/rust.yml
- crates/**
- nextgen/**
- tests/**
- Cargo.lock
- Cargo.toml
- Makefile.toml
- rust-toolchain.toml
env:
WITH_COVERAGE: ${{ contains(github.head_ref, 'develop-') || endsWith(github.ref, 'master') }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: moonrepo/setup-rust@v1
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all --check
lint:
name: Lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: moonrepo/setup-rust@v1
with:
bins: cargo-make
components: clippy
- name: Run linter
run: cargo make lint
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [buildjet-4vcpu-ubuntu-2204, self-hosted-laptop-macos-m1, self-hosted-laptop-windows-i7]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: moonrepo/setup-rust@v1
with:
bins: cargo-make, cargo-nextest, cargo-llvm-cov
components: llvm-tools-preview
cache: ${{ runner.os == 'Linux' }}
- name: Run tests with coverage
if: ${{ env.WITH_COVERAGE == 'true' }}
run: cargo make test-coverage
env:
NEXTEST_PROFILE: ci
- name: Run tests
if: ${{ env.WITH_COVERAGE == 'false' }}
run: cargo make test
env:
NEXTEST_PROFILE: ci
- name: Generate code coverage
if: ${{ env.WITH_COVERAGE == 'true' }}
run: cargo make generate-report
- name: Upload coverage report
uses: actions/upload-artifact@v3
if: ${{ env.WITH_COVERAGE == 'true' }}
with:
name: coverage-${{ runner.os }}
path: ./report.txt
if-no-files-found: error
coverage:
if: ${{ contains(github.head_ref, 'develop-') || endsWith(github.ref, 'master') }}
name: Code coverage
runs-on: ubuntu-latest
needs:
- test
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
name: Download coverage reports
with:
path: coverage
- uses: codecov/codecov-action@v3
name: Upload to Codecov
with:
files: ./coverage/coverage-Linux/report.txt,./coverage/coverage-macOS/report.txt,./coverage/coverage-Windows/report.txt
flags: rust
verbose: true