Send json post body properly in integration tests. #29
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/**' | |
# Run on changed flake | |
- 'flake.nix' | |
- 'flake.lock' | |
branches: | |
- main | |
# We are creating this workflow on this branch, hence we enable it here. | |
# This can be deleted once the branch is removed. | |
- 42-add-user-account-creation | |
pull_request: | |
branches: main | |
jobs: | |
run_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: cachix/install-nix-action@v22 | |
- name: Cache /nix/store | |
uses: actions/cache@v3 | |
with: | |
path: /nix/store | |
key: ${{ runner.os }}-${{ hashFiles('flake.*') }}-${{ hashFiles('.github/workflows/web-api-ci.yml') }} | |
- 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 | |
- name: Run database migrations | |
run: debugBinary/bin/rvoc-backend apply-migrations | |
- name: Run integration tests | |
uses: BerniWittmann/background-server-action@v1 | |
with: | |
command: integrationTestsBinary/bin/integration-tests | |
start: debugBinary/bin/rvoc-backend web |