This service allow to edit an infrastructure using railjson schema. It will apply modification and update generated data such as object geometry.
For both tests or run:
- rustup
- libpq (may be packaged as
libpq-dev
) - openssl
- libgeos (may be packaged as
libgeos-dev
) - A properly initialized postgresql database and a redis server:
docker compose up --no-build --detach postgres redis
# apply database migration
$ cargo install diesel_cli --no-default-features --features postgres
$ diesel migration run
# Build and run
$ cargo build
$ cargo run -- runserver
# Test server is up
$ curl -f http://localhost:8090/health
To avoid thread conflicts while accessing the database, use serial_test
#[test]
#[serial_test::serial]
cargo test -- --test-threads=4
Here a list of components to help you in your development (see CI jobs if necessary):
- rustfmt: Format the whole code
cargo fmt
- clippy: Run a powerful linter
cargo clippy --all-features --all-targets -- -D warnings
- grcov: Check code coverage (see documentation on GitHub)
To install rustfmt
and clippy
, simply run:
rustup component add rustfmt clippy
To setup grcov
, please see its documentation
Our docker-compose.yml
at the root of the project uses the postgis
image by default.
For M1 macs, it requires emulation since it's not compiled for arm platforms, which results
in a significant slowdown. Define this variable in your environment or in a .env
file somewhere:
export OSRD_POSTGIS_IMAGE='nickblah/postgis:15-postgis-3'
We have to keep the OpenApi of the service statically in the repository. To make sure it is always valid a CI check has been set up. To update the OpenApi when a change has been made to an endpoint, run the following command:
cargo run openapi > openapi.yaml
We use dependabot on the project to notify when dependencies are outdated.
We do not use dependabot to automatically update dependencies, as we want to merge all updates at
once and review the changes (and avoid flooding dev
branch with dependency-bump commits).
Here is the process to update dependencies:
- Change the versions.
- If you're using VSCode you can install the
serayuzgur.crates
extension and run the "update all dependencies" command.
Make sure that the new chosen version is stable, and that loose constraints are not overwritten in your commit. - If you're not, you can go check the versions used by dependabot in its PRs and update the versions manually.
- If you're using VSCode you can install the
- Run
cargo update
to update the Cargo.lock file (even sub-dependencies). - Check that all dependabot editoast PRs are included in your update.
- Adapt the code to the new versions, if needed.
- Create a PR with your changes, and link all dependabot PRs in the description.