-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (62 loc) · 1.87 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
name: Rust
on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
# https://stackoverflow.com/questions/57915791/github-actions-how-to-connect-to-postgres-in-githhub-actions
# https://docs.github.com/en/github-ae@latest/actions/using-containerized-services/creating-postgresql-service-containers
services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: hitsave
POSTGRES_PORT: 5432
POSTGRES_HOST: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
runs-on: ubuntu-latest
env:
# using env variables seems to be broken on github actions?!
# https://github.com/actions/runner/issues/480
DATABASE_URL: postgres://postgres:postgres@localhost:5432/hitsave
# DATABASE_URL: postgres://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@${{ env.POSTGRES_HOST }}:${{ env.POSTGRES_PORT }}/${{ env.POSTGRES_DB }}
steps:
- uses: actions/checkout@v3
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
- name: Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "api -> target"
- name: Install sqlx
uses: baptiste0928/cargo-install@v1
with:
crate: sqlx-cli
version: "0.6.2"
features: "native-tls,postgres"
locked: true
- name: Migrate
run: sqlx migrate run
working-directory: api
- name: Build
run: cargo build --verbose
working-directory: api
- name: Run tests
run: cargo test --verbose
working-directory: api