-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (119 loc) · 3.53 KB
/
development.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
name: development
env:
FIXED_RUST_VERSION: 1.74.0
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- 1.74.0
- stable
- beta
- nightly
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
profile: minimal
- name: Release build
run: cargo build --release
lint:
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- 1.74.0
- stable
- beta
- nightly
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
profile: minimal
components: rustfmt, clippy
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
test:
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- 1.74.0
- stable
- beta
- nightly
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
profile: minimal
- name: Unit Test
run: cargo test --lib
- name: Start MongoDB
uses: supercharge/[email protected]
- name: Integration Test
run: cargo test --test '*'
env:
RUST_TEST_THREADS: 1
MONGODB_URI: "mongodb://localhost:27017/"
MONGODB_DATABASE_NAME: "test"
coverage:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# https://docs.deepsource.com/docs/analyzers-test-coverage#with-github-actions
- name: Use pull request HEAD commit for DeepSource
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.FIXED_RUST_VERSION }}
profile: minimal
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install rust-covfix
run: |
curl -L https://github.com/Kogia-sima/rust-covfix/releases/latest/download/rust-covfix-linux-x86_64.tar.xz |tar Jxf -
mv rust-covfix-linux-x86_64/rust-covfix ./
- name: Start MongoDB
uses: supercharge/[email protected]
- name: Generate and fix code coverage
run: |
cargo llvm-cov --ignore-filename-regex "main" --lcov --output-path lcov.info
./rust-covfix lcov.info -o lcov.info
env:
RUST_TEST_THREADS: 1
MONGODB_URI: "mongodb://localhost:27017/"
MONGODB_DATABASE_NAME: "test"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
file: ./lcov.info
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage reports to DeepSource
if: github.event_name == 'pull_request'
run: |
curl https://deepsource.io/cli | sh
./bin/deepsource report --analyzer test-coverage --key rust --value-file ./lcov.info
env:
DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}