Skip to content

Commit

Permalink
build: add a ci job to run the tests using postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre committed Jun 26, 2024
1 parent 28e050d commit 0cf6bc4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,49 @@ jobs:
uses: ./.github/actions/nix_upload_store
if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }}

test_postgres:
name: Rust - test_postgres${{ matrix.test_projects != 'stable' && format('_{0}', matrix.test_projects) || '' }}
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: test
ports:
- 5433:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

defaults:
run:
shell: nix develop ./tools/nix#rust${{ matrix.test_projects == 'nightly' && '_nightly' || '' }} --keep CI --ignore-environment --command bash {0}
strategy:
fail-fast: false
matrix:
test_projects:
- stable
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
ref: ${{ github.event.inputs.commit_sha }}

- name: Install Nix
uses: ./.github/actions/cache_nix
with:
cache-unique-id: ${{ matrix.test_projects }}
id: nix-installer

- uses: ./.github/actions/cache_rust
with:
job_name: "${{ github.job }}-${{ matrix.test_projects }}"

- name: Run postgres test on ${{ matrix.test_projects }}
run: make -f implementations/rust/Makefile test_postgres

- name: Nix Upload Store
uses: ./.github/actions/nix_upload_store
if: ${{ steps.nix-installer.outputs.cache-hit != 'true' }}

check:
name: Rust - check_${{ matrix.check_projects }}
Expand Down
7 changes: 7 additions & 0 deletions implementations/rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ nextest:
nextest_%:
cargo --locked nextest --config-file $(ROOT_DIR)/tools/nextest/.config/nextest.toml run -E 'package($*)' --no-fail-fast
cargo --locked test --doc
test_postgres:
export OCKAM_POSTGRES_HOST=localhost
export OCKAM_POSTGRES_PORT=5433
export OCKAM_POSTGRES_DATABASE_NAME=test
export OCKAM_POSTGRES_USER=postgres
export OCKAM_POSTGRES_PASSWORD=password
cargo --locked nextest --config-file $(ROOT_DIR)/tools/nextest/.config/nextest.toml run -E 'test(sql) or test(cli_state)' --no-fail-fast --test-threads 1

lint: lint_cargo_fmt_check lint_cargo_deny lint_cargo_clippy
lint_cargo_fmt_check:
Expand Down

0 comments on commit 0cf6bc4

Please sign in to comment.