Skip to content

Commit 6526b48

Browse files
author
Glubus
committed
test ci
1 parent 4b6864b commit 6526b48

2 files changed

Lines changed: 80 additions & 101 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.

.github/workflows/rust.yml

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,92 @@
1-
name: Rust
1+
name: Rust CI
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: [ "master", "main", "develop" ]
66
pull_request:
7-
branches: [ "master" ]
7+
branches: [ "master", "main", "develop" ]
88

99
env:
1010
CARGO_TERM_COLOR: always
11+
DATABASE_URL: postgresql://postgres:password@localhost:5432/osu_backend_test
1112

1213
jobs:
13-
build:
14-
14+
test:
1515
runs-on: ubuntu-latest
16+
17+
services:
18+
postgres:
19+
image: postgres:15
20+
env:
21+
POSTGRES_PASSWORD: password
22+
POSTGRES_DB: osu_backend_test
23+
options: >-
24+
--health-cmd pg_isready
25+
--health-interval 10s
26+
--health-timeout 5s
27+
--health-retries 5
28+
ports:
29+
- 5432:5432
1630

1731
steps:
18-
- uses: actions/checkout@v4
19-
- name: Build
20-
run: cargo build --verbose
21-
- name: Run tests
22-
run: cargo test --verbose
32+
- uses: actions/checkout@v4
33+
34+
- name: Checkout migrations
35+
uses: actions/checkout@v4
36+
with:
37+
repository: Osef-me/migrations
38+
path: migrations
39+
40+
- uses: actions-rs/toolchain@v1
41+
with:
42+
toolchain: stable
43+
components: rustfmt, clippy
44+
45+
- name: Cache dependencies
46+
uses: actions/cache@v3
47+
with:
48+
path: |
49+
~/.cargo/registry
50+
~/.cargo/git
51+
target
52+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
53+
54+
- name: Install sqlx-cli
55+
run: cargo install sqlx-cli --no-default-features --features postgres
56+
57+
- name: Wait for PostgreSQL
58+
run: |
59+
until pg_isready -h localhost -p 5432 -U postgres; do
60+
echo "Waiting for PostgreSQL..."
61+
sleep 1
62+
done
63+
64+
- name: Run migrations
65+
run: sqlx migrate run
66+
env:
67+
DATABASE_URL: ${{ env.DATABASE_URL }}
68+
working-directory: migrations
69+
70+
- name: Format check
71+
run: cargo fmt --all -- --check
72+
73+
- name: Clippy check
74+
run: cargo clippy --all-targets --all-features -- -D warnings
75+
76+
- name: Build
77+
run: cargo build --verbose --all-features
78+
env:
79+
DATABASE_URL: ${{ env.DATABASE_URL }}
80+
81+
- name: Run tests
82+
run: cargo test --verbose --all-features
83+
env:
84+
DATABASE_URL: ${{ env.DATABASE_URL }}
85+
86+
- name: Test migrations rollback
87+
run: |
88+
sqlx migrate revert
89+
sqlx migrate run
90+
env:
91+
DATABASE_URL: ${{ env.DATABASE_URL }}
92+
working-directory: migrations

0 commit comments

Comments
 (0)