Skip to content

Commit 212aa65

Browse files
committed
ci: add test and check jobs to rust.yml
1 parent f77fd00 commit 212aa65

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

.github/workflows/rust.yml

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,61 @@
1-
name: Rust
1+
name: CI
22

33
on:
44
push:
55
branches: [ "master" ]
6+
67
pull_request:
7-
branches: [ "master" ]
8+
types: [ opened, synchronize, reopened ]
9+
branches:
10+
- master
811

912
env:
1013
CARGO_TERM_COLOR: auto
14+
PGPASSWORD: password
15+
DATABASE_TEST_URL: postgres://postgres:password@localhost:5432/testdb
1116

1217
jobs:
13-
build:
18+
build-test:
19+
name: Build + Test
20+
runs-on: ubuntu-latest
21+
services:
22+
postgres:
23+
image: postgres:14
24+
env:
25+
POSTGRES_USER: postgres
26+
POSTGRES_PASSWORD: password
27+
POSTGRES_DB: postgres
28+
# Set health checks to wait until postgres has started
29+
options: >-
30+
--health-cmd pg_isready
31+
--health-interval 10s
32+
--health-timeout 5s
33+
--health-retries 5
34+
# Map ports on service container to the host
35+
ports:
36+
- 5432:5432
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: dtolnay/rust-toolchain@stable
40+
- uses: Swatinem/rust-cache@v2
41+
- name: Create database
42+
run: |
43+
sudo apt-get install libpq-dev -y
44+
psql -h localhost -p 5432 -U postgres -d postgres -c 'create user testuser'
45+
psql -h localhost -p 5432 -U postgres -d postgres -c 'create database testdb with owner = testuser'
46+
- name: Test
47+
run: cargo test -- --test-threads=1 --show-output
48+
49+
fmt-clippy:
50+
name: Check
1451
runs-on: ubuntu-latest
1552
steps:
16-
- uses: actions/checkout@v4
17-
- name: Check
18-
run: cargo check
53+
- uses: actions/checkout@v4
54+
- uses: dtolnay/rust-toolchain@stable
55+
with:
56+
components: rustfmt, clippy
57+
- uses: Swatinem/rust-cache@v2
58+
- name: Check fmt
59+
run: cargo fmt --check
60+
- name: Clippy
61+
run: cargo clippy -- -D warnings

0 commit comments

Comments
 (0)