Skip to content

Commit

Permalink
ci: configure OpenFGA for editoast tests
Browse files Browse the repository at this point in the history
Signed-off-by: Leo Valais <[email protected]>
Co-authored-by: Florian Amsallem <[email protected]>
  • Loading branch information
leovalais and flomonster committed Feb 21, 2025
1 parent 331bc42 commit a3d3056
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
43 changes: 13 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -517,31 +517,6 @@ jobs:
name: Check editoast tests
needs:
- build

services:
postgres:
image: postgis/postgis
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
valkey:
image: valkey/valkey
ports:
- 6379:6379
options: >-
--health-cmd "valkey-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -558,13 +533,21 @@ jobs:
run: |
docker load --input ./osrd-editoast-test.tar
- name: Execute tests within container
- name: Startup the test infrastructure
id: start_editoast_tests_infra
run: |
docker run --rm --net=host \
-v $PWD/docker/init_db.sql:/init_db.sql \
postgis/postgis:latest \
psql postgresql://postgres:password@localhost:5432 -f /init_db.sql
set -e
services='valkey openfga'
composes='-f docker-compose.yml'
docker compose $composes pull --policy missing $services
docker compose $composes up --no-build -d $services
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1

- name: Execute tests within container
run: |
# snapshot testing library `insta` requires CI=true
docker run --name=editoast-test --net=host -v $PWD/output:/output \
-e DATABASE_URL="postgres://osrd:password@localhost:5432/osrd" \
Expand Down
10 changes: 10 additions & 0 deletions editoast/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ RUN rustup component add llvm-tools && \
rustup component add rustfmt && \
rustup component add clippy && \
cargo install grcov

# install `fga` binary used in `crate fga` unit tests
RUN mkdir install \
&& cd install \
&& wget https://github.com/openfga/cli/releases/download/v0.6.4/fga_0.6.4_linux_amd64.tar.gz \
&& tar xf fga_0.6.4_linux_amd64.tar.gz \
&& mv fga /usr/local/bin \
&& cd .. \
&& rm -rf install

COPY --from=planner /editoast/recipe.json recipe.json
COPY --from=planner /editoast/editoast_derive/ editoast_derive
COPY --from=test_data . /tests/data
Expand Down

0 comments on commit a3d3056

Please sign in to comment.