This repository has been archived by the owner on Nov 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
87 lines (85 loc) · 2.4 KB
/
ci.yaml
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: CI
on:
pull_request:
push:
branches:
- main
- develop
- features/github-actions-ci
jobs:
lint:
name: Linters
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
components: clippy, rustfmt
profile: minimal
toolchain: 1.62.1
- name: Check rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: '--check'
- name: Auto-cache Rust artifacts
uses: Swatinem/rust-cache@v2.0.0
- name: Check Clippy lints
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: '--all-features --no-deps -- -D warnings'
test:
name: Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- '5432:5432'
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.62.1
- name: Auto-cache Rust artifacts
uses: Swatinem/rust-cache@v2.0.0
- name: Restore sqlx-cli
uses: actions/cache@v3
id: cache-sqlx-cli
with:
path: |
~/.cargo/bin/cargo-sqlx
~/.cargo/bin/sqlx
key: ${{ runner.os }}-sqlx-cli-0.5.11
- name: Install sqlx-cli
uses: actions-rs/cargo@v1
with:
command: install
args: >-
--no-default-features
--features 'postgres,rustls'
--locked
--version 0.5.11
sqlx-cli
if: steps.cache-sqlx-cli.outputs.cache-hit != 'true'
- name: Reset test database
run: sqlx database reset -y --database-url $TEST_DATABASE_URL
env:
TEST_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/axum_rest_example_test
- name: Test all features
run: cargo test --all-features
env:
TEST_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/axum_rest_example_test