From 04bd0b7d786dc41cdb54d3f5ad34e42990b2792c Mon Sep 17 00:00:00 2001 From: Florian Amsallem Date: Thu, 6 Mar 2025 14:39:39 +0100 Subject: [PATCH 01/23] CircleCI Commit --- .circleci/config.yml | 122 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000000..7603b773fe6 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,122 @@ +# This config was automatically generated from your source code +# Stacks detected: cicd:github-actions:.github/workflows,deps:java:core,deps:node:front,deps:python:tests,deps:rust:gateway,package_manager:poetry:tests,tool:gradle: +version: 2.1 +orbs: + node: circleci/node@5 + python: circleci/python@2 +jobs: + test-node: + # Install node dependencies and run tests + executor: node/default + working_directory: ~/project/front + steps: + - checkout: + path: ~/project + - node/install-packages: + pkg-manager: npm + - run: + name: Run tests + command: npm test --passWithNoTests + build-node: + # Build node project + executor: node/default + working_directory: ~/project/front + steps: + - checkout: + path: ~/project + - node/install-packages: + pkg-manager: npm + - run: + command: npm run build + - run: + name: Create the ~/artifacts directory if it doesn't exist + command: mkdir -p ~/artifacts + # Copy output to artifacts dir + - run: + name: Copy artifacts + command: cp -R build dist public .output .next .docusaurus ~/artifacts 2>/dev/null || true + - store_artifacts: + path: ~/artifacts + destination: node-build + test-java: + docker: + - image: cimg/openjdk:17.0 + working_directory: ~/project/core + steps: + - checkout: + path: ~/project + - run: + name: Calculate cache key + command: |- + find . -name 'pom.xml' -o -name 'gradlew*' -o -name '*.gradle*' | \ + sort | xargs cat > /tmp/CIRCLECI_CACHE_KEY + - restore_cache: + key: cache-{{ checksum "/tmp/CIRCLECI_CACHE_KEY" }} + - run: + command: ./gradlew check + - store_test_results: + path: build/test-results + - save_cache: + key: cache-{{ checksum "/tmp/CIRCLECI_CACHE_KEY" }} + paths: + - ~/.gradle/caches + - store_artifacts: + path: build/reports + test-python: + # Install dependencies and run tests + docker: + - image: cimg/python:>=3.9,<3.13-node + working_directory: ~/project/tests + steps: + - checkout: + path: ~/project + - python/install-packages: + pkg-manager: poetry + - run: + name: Run tests + command: poetry run pytest --junitxml=junit.xml || ((($? == 5)) && echo 'Did not find any tests to run.') + - store_test_results: + path: junit.xml + test-rust: + docker: + - image: cimg/rust:1.70 + working_directory: ~/project/gateway + steps: + - checkout: + path: ~/project + - restore_cache: + key: cargo-{{ checksum "Cargo.lock" }} + - run: + command: cargo test + - save_cache: + key: cargo-{{ checksum "Cargo.lock" }} + paths: + - ~/.cargo + deploy: + # This is an example deploy job, not actually used by the workflow + docker: + - image: cimg/base:stable + steps: + # Replace this with steps to deploy to users + - run: + name: deploy + command: '#e.g. ./deploy.sh' + - run: + name: found github actions config + command: ':' +workflows: + build-and-test: + jobs: + - test-node + - build-node: + requires: + - test-node + - test-java + - test-python + - test-rust + - test-java + - test-python + - test-rust + # - deploy: + # requires: + # - build-node From 39fb281e5648282ffdde01b797da9aacadeb5e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 14:47:53 +0100 Subject: [PATCH 02/23] circleci: try 1 --- .circleci/config.yml | 277 ++++++++++++++++++++++++++++--------------- 1 file changed, 182 insertions(+), 95 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7603b773fe6..2da15c81cda 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,122 +1,209 @@ -# This config was automatically generated from your source code -# Stacks detected: cicd:github-actions:.github/workflows,deps:java:core,deps:node:front,deps:python:tests,deps:rust:gateway,package_manager:poetry:tests,tool:gradle: version: 2.1 + +parameters: + rust-version: + type: string + default: "1.84" + orbs: - node: circleci/node@5 - python: circleci/python@2 + docker: circleci/docker@2.4.0 + +executors: + python: + docker: + - image: cimg/python:3.9 + rust: + docker: + - image: cimg/rust:<< pipeline.parameters.rust-version >> + node: + docker: + - image: cimg/node:20.5 + java: + docker: + - image: cimg/openjdk:17.0 + jobs: - test-node: - # Install node dependencies and run tests - executor: node/default - working_directory: ~/project/front + check-core: + executor: java steps: - - checkout: - path: ~/project - - node/install-packages: - pkg-manager: npm + - checkout - run: - name: Run tests - command: npm test --passWithNoTests - build-node: - # Build node project - executor: node/default - working_directory: ~/project/front - steps: - - checkout: - path: ~/project - - node/install-packages: - pkg-manager: npm - - run: - command: npm run build - - run: - name: Create the ~/artifacts directory if it doesn't exist - command: mkdir -p ~/artifacts - # Copy output to artifacts dir + name: Calculate source checksum + command: | + # Create checksum of the entire core directory + find core -type f -exec sha256sum {} \; | sort > /tmp/src_checksum + - restore_cache: + keys: + - gradle-core-{{ checksum "core/build.gradle" }} + - restore_cache: + keys: + - tests-core-{{ checksum "/tmp/src_checksum" }} - run: - name: Copy artifacts - command: cp -R build dist public .output .next .docusaurus ~/artifacts 2>/dev/null || true + name: Run Core Tests + command: | + if [ ! -f "/tmp/tests_passed" ]; then + cd core + ./gradlew check + touch /tmp/tests_passed + else + echo "Tests already passed for this source code version, skipping..." + fi + - save_cache: + paths: + - ~/.gradle + key: gradle-core-{{ checksum "core/build.gradle" }} + - save_cache: + paths: + - /tmp/tests_passed + key: tests-core-{{ checksum "/tmp/src_checksum" }} + - store_test_results: + path: core/build/test-results - store_artifacts: - path: ~/artifacts - destination: node-build - test-java: + path: core/build/reports + + check-editoast: docker: - - image: cimg/openjdk:17.0 - working_directory: ~/project/core + - image: cimg/rust:<< pipeline.parameters.rust-version >> + - image: cimg/postgres:17.0-postgis + environment: + POSTGRES_DB: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + - image: cimg/redis:7.2.4 # Exact version used by the valkey fork, should be compatible. steps: - - checkout: - path: ~/project + - checkout - run: - name: Calculate cache key - command: |- - find . -name 'pom.xml' -o -name 'gradlew*' -o -name '*.gradle*' | \ - sort | xargs cat > /tmp/CIRCLECI_CACHE_KEY + name: Calculate source checksum + command: | + # Create checksum of the entire editoast directory + find editoast -type f -exec sha256sum {} \; | sort > /tmp/src_checksum + - restore_cache: + keys: + - cargo-editoast-{{ checksum "editoast/Cargo.lock" }} - restore_cache: - key: cache-{{ checksum "/tmp/CIRCLECI_CACHE_KEY" }} + keys: + - tests-editoast-{{ checksum "/tmp/src_checksum" }} - run: - command: ./gradlew check - - store_test_results: - path: build/test-results + name: Setup Database + command: | + psql postgresql://postgres:password@localhost -f docker/init_db.sql + - run: + name: Run Editoast Tests + working_directory: editoast + environment: + DATABASE_URL: postgres://osrd:password@localhost/osrd + CI: "true" + command: | + if [ ! -f "/tmp/tests_passed" ]; then + sudo apt-get update + sudo apt-get install -y libgeos-dev libpq-dev + cargo install diesel_cli --no-default-features --features postgres + diesel migration run --locked-schema + cargo test --workspace --verbose + touch /tmp/tests_passed + else + echo "Tests already passed for this source code version, skipping..." + fi - save_cache: - key: cache-{{ checksum "/tmp/CIRCLECI_CACHE_KEY" }} paths: - - ~/.gradle/caches - - store_artifacts: - path: build/reports - test-python: - # Install dependencies and run tests - docker: - - image: cimg/python:>=3.9,<3.13-node - working_directory: ~/project/tests + - ~/.cargo + - editoast/target + key: cargo-editoast-{{ checksum "editoast/Cargo.lock" }} + - save_cache: + paths: + - /tmp/tests_passed + key: tests-editoast-{{ checksum "/tmp/src_checksum" }} + + check-gateway: + executor: rust steps: - - checkout: - path: ~/project - - python/install-packages: - pkg-manager: poetry + - checkout + - restore_cache: + keys: + - cargo-gateway-{{ checksum "gateway/Cargo.lock" }} - run: - name: Run tests - command: poetry run pytest --junitxml=junit.xml || ((($? == 5)) && echo 'Did not find any tests to run.') - - store_test_results: - path: junit.xml - test-rust: - docker: - - image: cimg/rust:1.70 - working_directory: ~/project/gateway + name: Run Gateway Tests + working_directory: gateway + command: | + cargo test --verbose + - run: + name: Check Gateway Format + working_directory: gateway + command: | + cargo fmt --check + - run: + name: Run Gateway Clippy + working_directory: gateway + command: | + cargo clippy --all-features --all-targets -- -D warnings + - save_cache: + paths: + - ~/.cargo + - gateway/target + key: cargo-gateway-{{ checksum "gateway/Cargo.lock" }} + + check-osrdyne: + executor: rust steps: - - checkout: - path: ~/project + - checkout - restore_cache: - key: cargo-{{ checksum "Cargo.lock" }} + keys: + - cargo-osrdyne-{{ checksum "osrdyne/Cargo.lock" }} + - run: + name: Run OSRDyne Tests + working_directory: osrdyne + command: | + cargo test --verbose - run: - command: cargo test + name: Check OSRDyne Format + working_directory: osrdyne + command: | + cargo fmt --check + - run: + name: Run OSRDyne Clippy + working_directory: osrdyne + command: | + cargo clippy --all-features --all-targets -- -D warnings - save_cache: - key: cargo-{{ checksum "Cargo.lock" }} paths: - ~/.cargo - deploy: - # This is an example deploy job, not actually used by the workflow - docker: - - image: cimg/base:stable + - osrdyne/target + key: cargo-osrdyne-{{ checksum "osrdyne/Cargo.lock" }} + + check-front: + executor: node steps: - # Replace this with steps to deploy to users + - checkout + - restore_cache: + keys: + - npm-{{ checksum "front/package-lock.json" }} + - run: + name: Install Dependencies + working_directory: front + command: npm ci + - run: + name: Check Code Formatting + working_directory: front + command: npx prettier . --check - run: - name: deploy - command: '#e.g. ./deploy.sh' + name: Check i18n Keys + working_directory: front + command: npm run i18n-checker - run: - name: found github actions config - command: ':' + name: Run Tests + working_directory: front + command: npm run test + - save_cache: + paths: + - front/node_modules + key: npm-{{ checksum "front/package-lock.json" }} + workflows: - build-and-test: + version: 2 + tests: jobs: - - test-node - - build-node: - requires: - - test-node - - test-java - - test-python - - test-rust - - test-java - - test-python - - test-rust - # - deploy: - # requires: - # - build-node + - check-core + - check-editoast + - check-gateway + - check-osrdyne + - check-front From 260e1d2a3cdf7f8182d82a3de595cf7d49c6afd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 14:51:39 +0100 Subject: [PATCH 03/23] circleci: try 2 --- .circleci/config.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2da15c81cda..fcd2d0f18c0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,6 +4,15 @@ parameters: rust-version: type: string default: "1.84" + node-version: + type: string + default: "22.0" + java-version: + type: string + default: "17.0" + python-version: + type: string + default: "3.12" orbs: docker: circleci/docker@2.4.0 @@ -11,16 +20,16 @@ orbs: executors: python: docker: - - image: cimg/python:3.9 + - image: cimg/python:<< pipeline.parameters.python-version >> rust: docker: - image: cimg/rust:<< pipeline.parameters.rust-version >> node: docker: - - image: cimg/node:20.5 + - image: cimg/node:<< pipeline.parameters.node-version >> java: docker: - - image: cimg/openjdk:17.0 + - image: cimg/openjdk:<< pipeline.parameters.java-version >> jobs: check-core: From 77d1503c22544128b8389f6e3b5a3920432b7321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 15:03:45 +0100 Subject: [PATCH 04/23] circleci: try 3 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fcd2d0f18c0..d738b87c811 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ parameters: default: "1.84" node-version: type: string - default: "22.0" + default: "23.0" java-version: type: string default: "17.0" From d262b53e3de2fe02e47918a1ba30c498f7654b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 15:35:56 +0100 Subject: [PATCH 05/23] circleci: try 4 --- .circleci/config.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d738b87c811..a18de2e617b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -78,9 +78,9 @@ jobs: POSTGRES_DB: postgres POSTGRES_USER: postgres POSTGRES_PASSWORD: password - - image: cimg/redis:7.2.4 # Exact version used by the valkey fork, should be compatible. steps: - checkout + - setup_remote_docker - run: name: Calculate source checksum command: | @@ -92,18 +92,32 @@ jobs: - restore_cache: keys: - tests-editoast-{{ checksum "/tmp/src_checksum" }} - - run: - name: Setup Database - command: | - psql postgresql://postgres:password@localhost -f docker/init_db.sql - run: name: Run Editoast Tests working_directory: editoast environment: DATABASE_URL: postgres://osrd:password@localhost/osrd CI: "true" + OPENFGA_DATASTORE_ENGINE: "postgres" + OPENFGA_DATASTORE_URI: "postgres://osrd:password@localhost:5432/osrd?search_path=openfga" + OPENFGA_HTTP_ADDR: "0.0.0.0:8091" command: | if [ ! -f "/tmp/tests_passed" ]; then + psql postgresql://postgres:password@localhost -f docker/init_db.sql + + docker run --rm \ + -e OPENFGA_DATASTORE_ENGINE \ + -e OPENFGA_DATASTORE_URI \ + -e OPENFGA_HTTP_ADDR \ + openfga/openfga:1.8.6 migrate + + # Run openfga + docker run --rm -d \ + -e OPENFGA_DATASTORE_ENGINE \ + -e OPENFGA_DATASTORE_URI \ + -e OPENFGA_HTTP_ADDR \ + openfga/openfga:1.8.6 run + sudo apt-get update sudo apt-get install -y libgeos-dev libpq-dev cargo install diesel_cli --no-default-features --features postgres From 0c9ac73c3937755fb178c9e9235663d4ecb41873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 15:45:31 +0100 Subject: [PATCH 06/23] circleci: try 5 --- .circleci/config.yml | 64 ++++++++++++------- .../{workflows => workflows.old}/build.yml | 0 .github/{workflows => workflows.old}/pr.yml | 0 .../{workflows => workflows.old}/release.yml | 0 .../update_nix_flake.yml | 0 5 files changed, 42 insertions(+), 22 deletions(-) rename .github/{workflows => workflows.old}/build.yml (100%) rename .github/{workflows => workflows.old}/pr.yml (100%) rename .github/{workflows => workflows.old}/release.yml (100%) rename .github/{workflows => workflows.old}/update_nix_flake.yml (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index a18de2e617b..79c281c3885 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -103,7 +103,7 @@ jobs: OPENFGA_HTTP_ADDR: "0.0.0.0:8091" command: | if [ ! -f "/tmp/tests_passed" ]; then - psql postgresql://postgres:password@localhost -f docker/init_db.sql + psql postgresql://postgres:password@localhost -f ../docker/init_db.sql docker run --rm \ -e OPENFGA_DATASTORE_ENGINE \ @@ -141,57 +141,77 @@ jobs: executor: rust steps: - checkout + - run: + name: Calculate source checksum + command: | + # Create checksum of the entire editoast directory + find gateway -type f -exec sha256sum {} \; | sort > /tmp/src_checksum - restore_cache: keys: - cargo-gateway-{{ checksum "gateway/Cargo.lock" }} + - restore_cache: + keys: + - tests-gateway-{{ checksum "/tmp/src_checksum" }} - run: name: Run Gateway Tests working_directory: gateway command: | - cargo test --verbose - - run: - name: Check Gateway Format - working_directory: gateway command: | - cargo fmt --check - - run: - name: Run Gateway Clippy - working_directory: gateway - command: | - cargo clippy --all-features --all-targets -- -D warnings + if [ ! -f "/tmp/tests_passed" ]; then + cargo test --verbose + cargo fmt --check + cargo clippy --all-features --all-targets -- -D warnings + touch /tmp/tests_passed + else + echo "Tests already passed for this source code version, skipping..." + fi - save_cache: paths: - ~/.cargo - gateway/target key: cargo-gateway-{{ checksum "gateway/Cargo.lock" }} + - save_cache: + paths: + - /tmp/tests_passed + key: tests-gateway-{{ checksum "/tmp/src_checksum" }} check-osrdyne: executor: rust steps: - checkout + - run: + name: Calculate source checksum + command: | + # Create checksum of the entire editoast directory + find osrdyne -type f -exec sha256sum {} \; | sort > /tmp/src_checksum - restore_cache: keys: - cargo-osrdyne-{{ checksum "osrdyne/Cargo.lock" }} + - restore_cache: + keys: + - tests-osrdyne-{{ checksum "/tmp/src_checksum" }} - run: - name: Run OSRDyne Tests + name: Run Osrdyne Tests working_directory: osrdyne command: | - cargo test --verbose - - run: - name: Check OSRDyne Format - working_directory: osrdyne command: | - cargo fmt --check - - run: - name: Run OSRDyne Clippy - working_directory: osrdyne - command: | - cargo clippy --all-features --all-targets -- -D warnings + if [ ! -f "/tmp/tests_passed" ]; then + cargo test --verbose + cargo fmt --check + cargo clippy --all-features --all-targets -- -D warnings + touch /tmp/tests_passed + else + echo "Tests already passed for this source code version, skipping..." + fi - save_cache: paths: - ~/.cargo - osrdyne/target key: cargo-osrdyne-{{ checksum "osrdyne/Cargo.lock" }} + - save_cache: + paths: + - /tmp/tests_passed + key: tests-osrdyne-{{ checksum "/tmp/src_checksum" }} check-front: executor: node diff --git a/.github/workflows/build.yml b/.github/workflows.old/build.yml similarity index 100% rename from .github/workflows/build.yml rename to .github/workflows.old/build.yml diff --git a/.github/workflows/pr.yml b/.github/workflows.old/pr.yml similarity index 100% rename from .github/workflows/pr.yml rename to .github/workflows.old/pr.yml diff --git a/.github/workflows/release.yml b/.github/workflows.old/release.yml similarity index 100% rename from .github/workflows/release.yml rename to .github/workflows.old/release.yml diff --git a/.github/workflows/update_nix_flake.yml b/.github/workflows.old/update_nix_flake.yml similarity index 100% rename from .github/workflows/update_nix_flake.yml rename to .github/workflows.old/update_nix_flake.yml From bbfd92b54a6ca6c489c1362296cef6a4b92881e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 15:48:41 +0100 Subject: [PATCH 07/23] circleci: try 6 --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 79c281c3885..2efab381a2a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -155,7 +155,6 @@ jobs: - run: name: Run Gateway Tests working_directory: gateway - command: | command: | if [ ! -f "/tmp/tests_passed" ]; then cargo test --verbose From be2d6fb8473f9f8fd88b4efd0a28fb0231398239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 15:49:45 +0100 Subject: [PATCH 08/23] circleci: try 7 --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2efab381a2a..7d76736b2a1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -192,7 +192,6 @@ jobs: - run: name: Run Osrdyne Tests working_directory: osrdyne - command: | command: | if [ ! -f "/tmp/tests_passed" ]; then cargo test --verbose From 75034c70a1d628bb8dc10e6a92ef6bf95cf101a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 15:53:01 +0100 Subject: [PATCH 09/23] circleci: try 8 --- .circleci/config.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7d76736b2a1..9baa3728778 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,6 +13,9 @@ parameters: python-version: type: string default: "3.12" + openfga-version: + type: string + default: "1.8.6" orbs: docker: circleci/docker@2.4.0 @@ -109,14 +112,14 @@ jobs: -e OPENFGA_DATASTORE_ENGINE \ -e OPENFGA_DATASTORE_URI \ -e OPENFGA_HTTP_ADDR \ - openfga/openfga:1.8.6 migrate + openfga/openfga:v<< pipeline.parameters.openfga-version >> migrate # Run openfga docker run --rm -d \ -e OPENFGA_DATASTORE_ENGINE \ -e OPENFGA_DATASTORE_URI \ -e OPENFGA_HTTP_ADDR \ - openfga/openfga:1.8.6 run + openfga/openfga:v<< pipeline.parameters.openfga-version >> run sudo apt-get update sudo apt-get install -y libgeos-dev libpq-dev From d6421c0557ece154e86e12bf4e73ae601a1c05d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 15:59:44 +0100 Subject: [PATCH 10/23] circleci: try 9 --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9baa3728778..c9c1399660d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -112,6 +112,7 @@ jobs: -e OPENFGA_DATASTORE_ENGINE \ -e OPENFGA_DATASTORE_URI \ -e OPENFGA_HTTP_ADDR \ + --net=host \ openfga/openfga:v<< pipeline.parameters.openfga-version >> migrate # Run openfga @@ -119,6 +120,7 @@ jobs: -e OPENFGA_DATASTORE_ENGINE \ -e OPENFGA_DATASTORE_URI \ -e OPENFGA_HTTP_ADDR \ + --net=host \ openfga/openfga:v<< pipeline.parameters.openfga-version >> run sudo apt-get update From e6d594a296670bd59cab57882013fcd91ce312b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 16:13:51 +0100 Subject: [PATCH 11/23] circleci: try 10 --- .circleci/config.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c9c1399660d..d90167954c0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -74,13 +74,7 @@ jobs: path: core/build/reports check-editoast: - docker: - - image: cimg/rust:<< pipeline.parameters.rust-version >> - - image: cimg/postgres:17.0-postgis - environment: - POSTGRES_DB: postgres - POSTGRES_USER: postgres - POSTGRES_PASSWORD: password + executor: rust steps: - checkout - setup_remote_docker @@ -104,8 +98,19 @@ jobs: OPENFGA_DATASTORE_ENGINE: "postgres" OPENFGA_DATASTORE_URI: "postgres://osrd:password@localhost:5432/osrd?search_path=openfga" OPENFGA_HTTP_ADDR: "0.0.0.0:8091" + POSTGRES_DB: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password command: | if [ ! -f "/tmp/tests_passed" ]; then + docker run --rm -d \ + -e POSTGRES_DB \ + -e POSTGRES_USER \ + -e POSTGRES_PASSWORD \ + --net=host \ + --name postgres \ + cimg/postgres:17.0-postgis + psql postgresql://postgres:password@localhost -f ../docker/init_db.sql docker run --rm \ From 74eb5e0bf87b896ae3a6b61b0dda7245550cc9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 16:21:23 +0100 Subject: [PATCH 12/23] circleci: try 11 --- .circleci/config.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d90167954c0..463e68ed5b1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -74,7 +74,13 @@ jobs: path: core/build/reports check-editoast: - executor: rust + docker: + - image: cimg/rust:<< pipeline.parameters.rust-version >> + - image: cimg/postgres:17.0-postgis + environment: + POSTGRES_DB: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password steps: - checkout - setup_remote_docker @@ -98,19 +104,13 @@ jobs: OPENFGA_DATASTORE_ENGINE: "postgres" OPENFGA_DATASTORE_URI: "postgres://osrd:password@localhost:5432/osrd?search_path=openfga" OPENFGA_HTTP_ADDR: "0.0.0.0:8091" - POSTGRES_DB: postgres - POSTGRES_USER: postgres - POSTGRES_PASSWORD: password command: | - if [ ! -f "/tmp/tests_passed" ]; then - docker run --rm -d \ - -e POSTGRES_DB \ - -e POSTGRES_USER \ - -e POSTGRES_PASSWORD \ - --net=host \ - --name postgres \ - cimg/postgres:17.0-postgis + echo "DEBUG" + docker ps -a + docker network list + echo "END DEBUG" + if [ ! -f "/tmp/tests_passed" ]; then psql postgresql://postgres:password@localhost -f ../docker/init_db.sql docker run --rm \ From 802c4b5c38615b0afbcf7d6c9649c38ef63cd73e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 16:31:06 +0100 Subject: [PATCH 13/23] circleci: try 12 --- .circleci/config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 463e68ed5b1..262252f5845 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -106,8 +106,7 @@ jobs: OPENFGA_HTTP_ADDR: "0.0.0.0:8091" command: | echo "DEBUG" - docker ps -a - docker network list + docker inspect $(docker ps -q --filter ancestor=cimg/postgres:17.0-postgis | head -n 1) echo "END DEBUG" if [ ! -f "/tmp/tests_passed" ]; then From d6bb12b907f811955a856f1199bf953ca828e9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 16:38:36 +0100 Subject: [PATCH 14/23] circleci: try 13 --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 262252f5845..ec3b736abcf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -77,6 +77,7 @@ jobs: docker: - image: cimg/rust:<< pipeline.parameters.rust-version >> - image: cimg/postgres:17.0-postgis + name: postgres environment: POSTGRES_DB: postgres POSTGRES_USER: postgres From f4115d34f9169b6660706111c8c43b71ffe77bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 16:40:24 +0100 Subject: [PATCH 15/23] circleci: try 14 --- .circleci/config.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ec3b736abcf..4eec953f5b1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -103,7 +103,7 @@ jobs: DATABASE_URL: postgres://osrd:password@localhost/osrd CI: "true" OPENFGA_DATASTORE_ENGINE: "postgres" - OPENFGA_DATASTORE_URI: "postgres://osrd:password@localhost:5432/osrd?search_path=openfga" + OPENFGA_DATASTORE_URI: "postgres://osrd:password@postgres:5432/osrd?search_path=openfga" OPENFGA_HTTP_ADDR: "0.0.0.0:8091" command: | echo "DEBUG" @@ -117,7 +117,6 @@ jobs: -e OPENFGA_DATASTORE_ENGINE \ -e OPENFGA_DATASTORE_URI \ -e OPENFGA_HTTP_ADDR \ - --net=host \ openfga/openfga:v<< pipeline.parameters.openfga-version >> migrate # Run openfga @@ -125,7 +124,7 @@ jobs: -e OPENFGA_DATASTORE_ENGINE \ -e OPENFGA_DATASTORE_URI \ -e OPENFGA_HTTP_ADDR \ - --net=host \ + -p 8091:8091 \ openfga/openfga:v<< pipeline.parameters.openfga-version >> run sudo apt-get update From 3a30e1bba584db24552c47ab048d93dc7843bb55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 17:09:09 +0100 Subject: [PATCH 16/23] circleci: try 15 --- .circleci/config.yml | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4eec953f5b1..3d67f577353 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -77,11 +77,10 @@ jobs: docker: - image: cimg/rust:<< pipeline.parameters.rust-version >> - image: cimg/postgres:17.0-postgis - name: postgres environment: POSTGRES_DB: postgres POSTGRES_USER: postgres - POSTGRES_PASSWORD: password + POSTGRES_PASSWORD: password$ steps: - checkout - setup_remote_docker @@ -96,37 +95,29 @@ jobs: - restore_cache: keys: - tests-editoast-{{ checksum "/tmp/src_checksum" }} + - run: - name: Run Editoast Tests - working_directory: editoast + name: Install and run OpenFGA + background: true environment: - DATABASE_URL: postgres://osrd:password@localhost/osrd - CI: "true" OPENFGA_DATASTORE_ENGINE: "postgres" OPENFGA_DATASTORE_URI: "postgres://osrd:password@postgres:5432/osrd?search_path=openfga" OPENFGA_HTTP_ADDR: "0.0.0.0:8091" command: | - echo "DEBUG" - docker inspect $(docker ps -q --filter ancestor=cimg/postgres:17.0-postgis | head -n 1) - echo "END DEBUG" + sudo mkdir -p /opt/openfga + curl -L https://github.com/openfga/openfga/releases/download/v<< pipeline.parameters.openfga-version >>/openfga_<< pipeline.parameters.openfga-version >>_linux_amd64.tar.gz | sudo tar -xz -C /opt/openfga + /opt/openfga/openfga migrate + /opt/openfga/openfg run + - run: + name: Run Editoast Tests + working_directory: editoast + environment: + DATABASE_URL: postgres://osrd:password@localhost/osrd + CI: "true" + command: | if [ ! -f "/tmp/tests_passed" ]; then psql postgresql://postgres:password@localhost -f ../docker/init_db.sql - - docker run --rm \ - -e OPENFGA_DATASTORE_ENGINE \ - -e OPENFGA_DATASTORE_URI \ - -e OPENFGA_HTTP_ADDR \ - openfga/openfga:v<< pipeline.parameters.openfga-version >> migrate - - # Run openfga - docker run --rm -d \ - -e OPENFGA_DATASTORE_ENGINE \ - -e OPENFGA_DATASTORE_URI \ - -e OPENFGA_HTTP_ADDR \ - -p 8091:8091 \ - openfga/openfga:v<< pipeline.parameters.openfga-version >> run - sudo apt-get update sudo apt-get install -y libgeos-dev libpq-dev cargo install diesel_cli --no-default-features --features postgres From 4cf278c3cb1c841dd3bd3429b0956f11637d08df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 17:15:43 +0100 Subject: [PATCH 17/23] circleci: try 16 --- .circleci/config.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3d67f577353..bd8ca24965a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -101,13 +101,15 @@ jobs: background: true environment: OPENFGA_DATASTORE_ENGINE: "postgres" - OPENFGA_DATASTORE_URI: "postgres://osrd:password@postgres:5432/osrd?search_path=openfga" + OPENFGA_DATASTORE_URI: "postgres://osrd:password@localhost:5432/osrd?search_path=openfga" OPENFGA_HTTP_ADDR: "0.0.0.0:8091" command: | sudo mkdir -p /opt/openfga curl -L https://github.com/openfga/openfga/releases/download/v<< pipeline.parameters.openfga-version >>/openfga_<< pipeline.parameters.openfga-version >>_linux_amd64.tar.gz | sudo tar -xz -C /opt/openfga + echo "Running OpenFGA Migration" /opt/openfga/openfga migrate - /opt/openfga/openfg run + echo "Running OpenFGA itself" + /opt/openfga/openfga run - run: name: Run Editoast Tests From b188d7d4012fcb15ca9bbb1d0621dcb127531be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 17:31:28 +0100 Subject: [PATCH 18/23] circleci: try 17 --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index bd8ca24965a..2297cb1b141 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -76,6 +76,7 @@ jobs: check-editoast: docker: - image: cimg/rust:<< pipeline.parameters.rust-version >> + - image: cimg/redis:7.2.4 # Exact version used by the valkey fork, should be compatible. - image: cimg/postgres:17.0-postgis environment: POSTGRES_DB: postgres @@ -96,6 +97,11 @@ jobs: keys: - tests-editoast-{{ checksum "/tmp/src_checksum" }} + - run: + name: Prepare the database + command: | + psql postgresql://postgres:password@localhost -f ../docker/init_db.sql + - run: name: Install and run OpenFGA background: true From cae2f5084475cf760c5c9529eceac811d4bae772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 17:34:50 +0100 Subject: [PATCH 19/23] circleci: try 19 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2297cb1b141..ce471d1099f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -100,7 +100,7 @@ jobs: - run: name: Prepare the database command: | - psql postgresql://postgres:password@localhost -f ../docker/init_db.sql + psql postgresql://postgres:password@localhost -f docker/init_db.sql - run: name: Install and run OpenFGA From bb8e08d9acbbbbe28b33550d68ce4049874f580c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 17:42:55 +0100 Subject: [PATCH 20/23] circleci: try 20 --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index ce471d1099f..92c2573dfee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -130,6 +130,10 @@ jobs: sudo apt-get install -y libgeos-dev libpq-dev cargo install diesel_cli --no-default-features --features postgres diesel migration run --locked-schema + cargo install spreet + ./assets/sprites/generate-atlas.sh + cargo install build_pbf_glyphs + ./assets/fonts/generate-glyphs.sh cargo test --workspace --verbose touch /tmp/tests_passed else From 58dac1f32115b9c09cede0cc4016e0a5e58a28fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 17:59:57 +0100 Subject: [PATCH 21/23] circleci: try 21 --- .circleci/config.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 92c2573dfee..69628ab1989 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -117,6 +117,11 @@ jobs: echo "Running OpenFGA itself" /opt/openfga/openfga run + - run: + name: Install FGA Client + command: | + curl -L https://github.com/openfga/cli/releases/download/v0.6.4/fga_0.6.4_linux_amd64.tar.gz | sudo tar -xz -C /usr/local/bin/ fga + - run: name: Run Editoast Tests working_directory: editoast @@ -130,10 +135,13 @@ jobs: sudo apt-get install -y libgeos-dev libpq-dev cargo install diesel_cli --no-default-features --features postgres diesel migration run --locked-schema + cargo install spreet ./assets/sprites/generate-atlas.sh + cargo install build_pbf_glyphs - ./assets/fonts/generate-glyphs.sh + ./assets/fonts/generate-glyphs.sh + cargo test --workspace --verbose touch /tmp/tests_passed else From 577552b4691775efd3e89bae6030479d137e4be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 18:17:11 +0100 Subject: [PATCH 22/23] circleci: try 22 --- .circleci/config.yml | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 69628ab1989..8ebcca750a8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -143,6 +143,9 @@ jobs: ./assets/fonts/generate-glyphs.sh cargo test --workspace --verbose + + cargo fmt --check + cargo clippy --all-features --all-targets -- -D warnings touch /tmp/tests_passed else echo "Tests already passed for this source code version, skipping..." @@ -164,7 +167,7 @@ jobs: - run: name: Calculate source checksum command: | - # Create checksum of the entire editoast directory + # Create checksum of the entire gateway directory find gateway -type f -exec sha256sum {} \; | sort > /tmp/src_checksum - restore_cache: keys: @@ -201,7 +204,7 @@ jobs: - run: name: Calculate source checksum command: | - # Create checksum of the entire editoast directory + # Create checksum of the entire osrdyne directory find osrdyne -type f -exec sha256sum {} \; | sort > /tmp/src_checksum - restore_cache: keys: @@ -235,29 +238,38 @@ jobs: executor: node steps: - checkout + - run: + name: Calculate source checksum + command: | + # Create checksum of the entire front directory + find front -type f -exec sha256sum {} \; | sort > /tmp/src_checksum + - restore_cache: + keys: + - tests-front-{{ checksum "/tmp/src_checksum" }} - restore_cache: keys: - npm-{{ checksum "front/package-lock.json" }} - run: name: Install Dependencies working_directory: front - command: npm ci - - run: - name: Check Code Formatting - working_directory: front - command: npx prettier . --check - - run: - name: Check i18n Keys - working_directory: front - command: npm run i18n-checker - - run: - name: Run Tests - working_directory: front - command: npm run test + command: | + if [ ! -f "/tmp/tests_passed" ]; then + npm ci + npx prettier . --check + npm run i18n-checker + npm run test + touch /tmp/tests_passed + else + echo "Tests already passed for this source code version, skipping..." + fi - save_cache: paths: - front/node_modules key: npm-{{ checksum "front/package-lock.json" }} + - save_cache: + paths: + - /tmp/tests_passed + key: tests-front-{{ checksum "/tmp/src_checksum" }} workflows: version: 2 From 21cd78ec93a53004579e4b281ada515bb713aabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lyse=20Viard?= Date: Thu, 6 Mar 2025 18:31:03 +0100 Subject: [PATCH 23/23] circleci: try 23 --- .circleci/{config.yml => check_services.yml} | 0 .circleci/validate_repository.yml | 8 ++++++++ 2 files changed, 8 insertions(+) rename .circleci/{config.yml => check_services.yml} (100%) create mode 100644 .circleci/validate_repository.yml diff --git a/.circleci/config.yml b/.circleci/check_services.yml similarity index 100% rename from .circleci/config.yml rename to .circleci/check_services.yml diff --git a/.circleci/validate_repository.yml b/.circleci/validate_repository.yml new file mode 100644 index 00000000000..9e74b3bc996 --- /dev/null +++ b/.circleci/validate_repository.yml @@ -0,0 +1,8 @@ +version: 2.1 + +orbs: + docker: circleci/docker@2.4.0 + +jobs: + check-commit: + \ No newline at end of file