-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (64 loc) · 2.55 KB
/
web-api-ci.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
name: Web API CI
on:
push:
paths:
# Run if workflow changes
- '.github/workflows/web-api-ci.yml'
# Run on changed dependencies
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/rust-toolchain.toml'
# Run on changed source files
- 'backend/rvoc-backend/src/**'
- 'backend/api_commands/src/**'
- 'backend/integration-tests/src/**'
# Run on changed flake
- 'flake.nix'
- 'flake.lock'
branches:
- main
pull_request:
branches: main
# Run manually
workflow_dispatch:
jobs:
run_integration_tests:
name: Backend integration tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# adapted from https://github.com/diesel-rs/diesel/blob/1d66cdfb8323fc09612a08dca10752b47238181a/.github/workflows/ci.yml
- name: Install postgres (Linux)
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev postgresql
echo "host all all 127.0.0.1/32 md5" > sudo tee -a /etc/postgresql/10/main/pg_hba.conf
sudo service postgresql restart && sleep 3
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
sudo -u postgres createdb rvoc
sudo service postgresql restart && sleep 3
echo "PG_DATABASE_URL=postgres://postgres:postgres@localhost/" >> $GITHUB_ENV
echo "PG_EXAMPLE_DATABASE_URL=postgres://postgres:postgres@localhost/diesel_example" >> $GITHUB_ENV
echo "POSTGRES_RVOC_URL=postgres://postgres:postgres@localhost/rvoc" >> $GITHUB_ENV
- name: Install nix
uses: DeterminateSystems/nix-installer-action@v8
- name: Cache nix
uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Build debug binary
run: nix build --out-link debugBinary .#debugBinary
- name: Build integration-tests binary
run: nix build --out-link integrationTestsBinary .#integrationTestsBinary
- name: Set up environment variables
run: |
echo "PASSWORD_PEPPER=test-test-test-test" >> $GITHUB_ENV
echo "RVOC_INTEGRATION_TEST_MODE=true" >> $GITHUB_ENV
- name: Run database migrations
run: debugBinary/bin/rvoc-backend apply-migrations
- name: Run internal integration tests
run: debugBinary/bin/rvoc-backend run-internal-integration-tests
- name: Run integration tests
uses: BerniWittmann/background-server-action@v1
with:
command: RUST_BACKTRACE=1 integrationTestsBinary/bin/integration-tests
start: debugBinary/bin/rvoc-backend web