Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CircleCI Experiments #11049

Open
wants to merge 23 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
282 changes: 282 additions & 0 deletions .circleci/check_services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
version: 2.1

parameters:
rust-version:
type: string
default: "1.84"
node-version:
type: string
default: "23.0"
java-version:
type: string
default: "17.0"
python-version:
type: string
default: "3.12"
openfga-version:
type: string
default: "1.8.6"

orbs:
docker: circleci/[email protected]

executors:
python:
docker:
- image: cimg/python:<< pipeline.parameters.python-version >>
rust:
docker:
- image: cimg/rust:<< pipeline.parameters.rust-version >>
node:
docker:
- image: cimg/node:<< pipeline.parameters.node-version >>
java:
docker:
- image: cimg/openjdk:<< pipeline.parameters.java-version >>

jobs:
check-core:
executor: java
steps:
- checkout
- run:
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: 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: core/build/reports

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
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password$
steps:
- checkout
- setup_remote_docker
- run:
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:
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
environment:
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: |
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
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
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
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 install spreet
./assets/sprites/generate-atlas.sh

cargo install build_pbf_glyphs
./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..."
fi
- save_cache:
paths:
- ~/.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
- run:
name: Calculate source checksum
command: |
# Create checksum of the entire gateway 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: |
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 osrdyne 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
working_directory: osrdyne
command: |
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
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: |
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
tests:
jobs:
- check-core
- check-editoast
- check-gateway
- check-osrdyne
- check-front
8 changes: 8 additions & 0 deletions .circleci/validate_repository.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2.1

orbs:
docker: circleci/[email protected]

jobs:
check-commit:

File renamed without changes.
File renamed without changes.
File renamed without changes.