-
Notifications
You must be signed in to change notification settings - Fork 1
158 lines (152 loc) · 4.62 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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Rust
on:
push:
branches: [master]
pull_request:
branches: [master, dev]
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target/
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run build
run: cargo build
test:
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: laguna_dev_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
needs: build
strategy:
fail-fast: false
# NOTE: Only use Linux for testing
# Server will likely be deployed on linux
# GH Actions doesn't support containers on Windows
# MacOS doesn't have docker installed by default
matrix:
os: [ubuntu-latest]
rust: [stable]
runs-on: ${{ matrix.os }}
env:
SQLX_OFFLINE: true
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/laguna_dev_db
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target/
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: RUST_LOG=warn cargo test --all --features testx -- --nocapture
coverage:
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: laguna_dev_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
needs: test
# Don't coverage dependabot
if: github.actor != 'dependabot[bot]'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
rust: [stable]
env:
SQLX_OFFLINE: true
DATABASE_URL: postgres://postgres:postgres@postgres:5432/laguna_dev_db
runs-on: ${{ matrix.os }}
# TODO: Maybe use https://github.com/taiki-e/install-action so to avoid recompile of tarpaulin
container:
image: xd009642/tarpaulin
options: --security-opt seccomp=unconfined
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target/
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Generate coverage data
run: |
RUST_LOG=warn cargo tarpaulin --workspace --timeout 120 --out xml --features testx --skip-clean --target-dir=target/coverage
- name: Upload to codecov.io
uses: codecov/codecov-action@v3 # Make sure to use v3 because it allows tokenless upload
deploy_docs:
needs: [build, test]
permissions:
contents: write
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- name: Build Docs
run: cargo doc --no-deps --workspace --features dox
- name: Doc Index Page Redirection
run: echo '<meta http-equiv="refresh" content="0; url=laguna_backend/index.html">' > target/doc/index.html
- name: Deploy Docs
uses: peaceiris/actions-gh-pages@v3
with:
user_name: "github-actions-laguna[bot]"
user_email: "github-actions-laguna[bot]@users.noreply.github.com"
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: documentation
publish_dir: target/doc
force_orphan: true