base on Dématérialiser et simplifier les démarches administratives # demarches-simplifiees.fr
> [!NOTE]
> [Lire la version française du README](README.fr.md)
## Context
[demarches-simplifiees.fr](https://www.demarches-simplifiees.fr) is a web platform designed to address the French government's urgent need to comply with the directive for 100% digitization of administrative procedures.
## How to contribute?
demarches-simplifiees.fr is [open source](https://en.wikipedia.org/wiki/Open-source_software) software under the AGPL license.
Would you like to make changes or improvements? Read our [contribution guide](CONTRIBUTING.md).
## Development setup
### Technical dependencies
#### All environments
- postgresql (version >= 15)
- imagemagick and gsfonts to generate watermarks on identity documents or generate image thumbnails.
> [!WARNING]
> Remember to restrict ImageMagick's policy to block exploitation of malicious images.
> The default configuration is usually insufficient for images from the web.
> For example, on Debian/Ubuntu in `/etc/ImageMagick-6/policy.xml`:
```xml
<!-- in addition to the default policy, add at the end of the file -->
<policymap>
<policy domain="coder" rights="none" pattern="*"/>
<policy domain="coder" rights="read | write" pattern="{JPG,JPEG,PNG,JSON}"/>
<policy domain="module" rights="none" pattern="{MSL,MVG,PS,SVG,URL,XPS}"/>
</policymap>
```
We are currently migrating from `delayed_job` to `sidekiq` for asynchronous job processing.
To run sidekiq, you will need:
- redis
- lightgallery: a license has been purchased to support the project, but it is not required if the library is used as part of an open source application.
#### Development
- rbenv: see https://github.com/rbenv/rbenv-installer#rbenv-installer--doctor-scripts
- Bun: see https://bun.sh/docs/installation
#### Tests
- Chrome
- chromedriver:
- Mac: `brew install chromedriver`
- Linux: see https://developer.chrome.com/blog/chrome-for-testing
If Chrome's installation location is non-standard, or if you're using Brave or Chromium instead,
you may need to override the path to the Chrome binary for your machine, for example:
```ruby
# create file spec/support/spec_config.local.rb
Selenium::WebDriver::Chrome.path = "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
# Must exactly match the browser version
Webdrivers::Chromedriver.required_version = "103.0.5060.53"
```
It's also possible to automatically install and update when running `bin/update` by defining the `UPDATE_WEBDRIVER` environment variable. The binaries will be installed in the `~/.local/bin/` directory, which must be manually added to your path.
### Creating database roles
The information needed to initialize the database must be pre-configured manually using the following procedure:
su - postgres
psql
> create user tps_development with password 'tps_development' superuser;
> create user tps_test with password 'tps_test' superuser;
> \q
### Initializing the development environment
On Ubuntu, some packages must be installed first:
sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev libcurl4-gnutls-dev zlib1g-dev
To initialize the development environment, run the following command:
bin/setup
### Launching the application
Start the application server like this:
bin/dev
The application will then run at `http://localhost:3000` with a worker for jobs and the vitejs bundler running in parallel.
### Test users
Locally, a test user is automatically created with the credentials `
[email protected]`/`this is a very complicated password !`. (see [db/seeds.rb](https://github.com/betagouv/demarches-simplifiees.fr/blob/dev/db/seeds.rb))
### Scheduling recurring tasks
rails jobs:schedule
### Viewing emails sent locally
Open the page [http://localhost:3000/letter_opener](http://localhost:3000/letter_opener).
### Updating the application
To update your development environment, install new dependencies, and run migrations:
bin/update
### Running tests (RSpec)
Tests need their own database, and some of them use Selenium to run in a browser. Don't forget to create the test database and install Chrome and chromedriver to run all tests.
To run the application tests, several options are available:
- Run all tests
bin/rake spec
bin/rspec
- Run a specific test
bin/rake spec SPEC=file_path/file_name_spec.rb:line_number
bin/rspec file_path/file_name_spec.rb:line_number
- Run all tests in a file
bin/rake spec SPEC=file_path/file_name_spec.rb
bin/rspec file_path/file_name_spec.rb
- Only rerun tests that previously failed
bin/rspec --only-failures
- Run one or more system tests with a visible browser
NO_HEADLESS=1 bin/rspec spec/system
- Display JavaScript error logs from the browser console (`console.error('hello')`)
JS_LOG=debug,log,error bin/rspec spec/system
- Increase latency during end-to-end tests to detect stubborn bugs
MAKE_IT_SLOW=1 bin/rspec spec/system
### Adding tasks to run during deployment
rails generate after_party:task task_name
### Linting
The project uses several linters to check code readability and quality.
- Run all linters: `bin/rake lint`
- Check the status of translations: `bundle exec i18n-tasks health`
- [AccessLint](http://accesslint.com/) runs automatically on PRs
### Regenerating binstubs
bundle binstub railties --force
bin/rake rails:update:bin
## Deployment
See deployment notes in [DEPLOYMENT.md](doc/DEPLOYMENT.md)
## Common tasks
### Super-admin account management tasks
Super-admin account management tasks are available in the `superadmin` namespace.
To list them: `bin/rake -D superadmin:`.
### Support tasks
Support tasks are available in the `support` namespace.
To list them: `bin/rake -D support:`.
## Performance
[](https://oss.skylight.io/app/applications/zAvWTaqO0mu1)
We use Skylight to monitor our application's performance.
Additionally, we use [Yabeda](https://github.com/yabeda-rb/yabeda) to export Prometheus-format metrics for Sidekiq. This is activated via the `PROMETHEUS_EXPORTER_ENABLED` environment variable (see config/env.example.optional).
", Assign "at most 3 tags" to the expected json: {"id":"12771","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"