-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (148 loc) · 4.64 KB
/
general.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
name: Tests and formatting
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
- develop
pull_request:
types: [ opened, synchronize, reopened ]
branches:
- develop
env:
CARGO_TERM_COLOR: always
SQLX_VERSION: 0.8.2 # When changing ensure the cache is invalidated
APP_USER: db_user
APP_USER_PWD: password
APP_DB_NAME: chat_demo
jobs:
test_stand_alone_mysql:
name: Test (Standalone MySQL)
runs-on: ubuntu-latest
services:
mysql:
image: mysql
env:
MYSQL_USER: ${{ env.APP_USER }}
MYSQL_PASSWORD: ${{ env.APP_USER_PWD }}
MYSQL_DATABASE: ${{ env.APP_DB_NAME }}
MYSQL_ROOT_PASSWORD: password
MYSQL_ROOT_HOST: "%"
ports:
- 3306:3306
redis:
image: redis:7
ports:
- 6379:6379
steps:
- uses: wykies/checkout@main
with:
submodules: recursive
- uses: wykies/setup-rust-toolchain@main
- name: Install sqlx-cli
run:
cargo install sqlx-cli
--version=${{ env.SQLX_VERSION }}
--features rustls,mysql
--no-default-features
--locked
- name: Migrate database
run: |
sudo apt-get install mysql-client -y
cd crates/chat-app-server && SKIP_DOCKER=true ./scripts/init_db_mysql.sh
- name: Load sqlx query files for mysql
run: cargo run --bin switch-db -- standalone
- name: Check sqlx prepared queries for mysql are is up-to-date
run: |
cargo sqlx prepare --check --workspace -- --bins --tests --all-features
- name: Run tests
run: cargo test
test_stand_alone_postgres:
name: Test (Standalone Postgres)
runs-on: ubuntu-latest
services:
mysql:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
- 5432:5432
redis:
image: redis:7
ports:
- 6379:6379
steps:
- uses: wykies/checkout@main
with:
submodules: recursive
- uses: wykies/setup-rust-toolchain@main
- name: Install sqlx-cli
run:
cargo install sqlx-cli
--version=${{ env.SQLX_VERSION }}
--features rustls,postgres
--no-default-features
--locked
- name: Create app user in Postgres
run: |
sudo apt-get install postgresql-client
# Create the application user
CREATE_QUERY="CREATE USER ${APP_USER} WITH PASSWORD '${APP_USER_PWD}';"
PGPASSWORD="password" psql -U "postgres" -h "localhost" -c "${CREATE_QUERY}"
# Grant create db privileges to the app user
GRANT_QUERY="ALTER USER ${APP_USER} CREATEDB;"
PGPASSWORD="password" psql -U "postgres" -h "localhost" -c "${GRANT_QUERY}"
- name: Migrate database
run: |
cd crates/chat-app-server && SKIP_DOCKER=true ./scripts/init_db_pg.sh
- name: Load sqlx query files for postgres
run: cargo run --bin switch-db -- shuttle
- name: Check sqlx prepared queries for postgres are is up-to-date
run: |
cargo sqlx prepare --check --workspace -- --bins --tests --no-default-features --features postgres,standalone
- name: Run tests
run: cargo test --package chat-app-server --no-default-features --features standalone,postgres
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: wykies/checkout@main
with:
submodules: recursive
- uses: wykies/setup-rust-toolchain@main
with:
components: rustfmt
cache: false
- name: Enforce formatting
run: cargo fmt --check
clippy:
name: Clippy (Standalone)
runs-on: ubuntu-latest
steps:
- uses: wykies/checkout@main
with:
submodules: recursive
- uses: wykies/setup-rust-toolchain@main
with:
components: clippy
- name: Load sqlx query files for standalone version
run: cargo run --bin switch-db -- standalone
- name: Linting
run: cargo clippy --all-features -- -D warnings
wasm:
name: Clippy WASM
runs-on: ubuntu-latest
steps:
- uses: wykies/checkout@main
with:
submodules: recursive
- uses: wykies/setup-rust-toolchain@main
with:
target: wasm32-unknown-unknown
components: clippy
- name: Linting
run: cargo clippy --target="wasm32-unknown-unknown" --package chat-app-client -- -D warnings