-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (133 loc) · 4.07 KB
/
tests.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
name: tests
on:
push:
branches: [ main, dev ]
pull_request:
workflow_dispatch:
jobs:
fmt:
name: cargo fmt
runs-on: ubuntu-latest
container:
image: rust:1.74-bookworm
steps:
- uses: actions/checkout@v3
- run: |
rustup component add rustfmt
cargo fmt --all -- --check
sqlx:
name: prepare query metadata
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
container:
image: rust:1.74-bookworm
env:
DATABASE_URL: postgres://postgres@postgres:5432
SQLX_OFFLINE: true
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-sqlx-prepare-${{ hashFiles('**/Cargo.lock') }}
- name: Install sqlx
run: cargo install sqlx-cli --no-default-features --features postgres
- name: Run the test sqlx migrations
run: cargo sqlx migrate run --source file-service/migrations
- name: Check that the sqlx prepared query metadata is up-to-date
run: cargo sqlx prepare --workspace --check -- --all-targets --all-features
clippy:
name: cargo clippy
runs-on: ubuntu-latest
container:
image: rust:1.74-bookworm
env:
DATABASE_URL: postgres://postgres@postgres:5432
SQLX_OFFLINE: true
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- run: |
rustup component add clippy
# Temporarily allowing dead-code, while denying all other warnings
cargo clippy --all-features --all-targets -- -A dead-code -D warnings
test-and-coverage:
name: cargo test and coverage
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
actions: read
services:
postgres:
image: postgres:15
env:
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
container:
image: rust:1.74-bookworm
env:
DATABASE_URL: postgres://postgres@postgres:5432
SQLX_OFFLINE: true
LLVM_PROFILE_FILE_NAME: '{}-%Nm.profraw'
steps:
- name: Free some space
run: |
rm -rf /usr/share/dotnet
rm -rf /opt/ghc
rm -rf "/usr/local/share/boost"
rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install sqlx
run: cargo install sqlx-cli --no-default-features --features postgres
- name: Run the test sqlx migrations
run: cargo sqlx migrate run --source file-service/migrations
- name: Run tests and generate coverage report
run: cargo llvm-cov test --profile "git-test" --all-features --workspace --lcov --output-path lcov.info
- name: Test documentation code snippets
run: cargo test --doc --all-features --workspace
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2.2.0
with:
file: ./lcov.info