Skip to content

Latest commit

 

History

History
157 lines (118 loc) · 3.99 KB

CONTRIBUTING.md

File metadata and controls

157 lines (118 loc) · 3.99 KB

Contributing

Get Started

Requirements

Development Setup

⚠️ Important
If you're under Windows, please run all the CLI commands within a Linux shell-like terminal (i.e.: Git Bash).

Then run:

git clone https://github.com/betagouv/inca-app.git
cd inca-app
yarn
yarn setup
yarn dev:docker
yarn db:migrate
yarn db:seed
yarn dev

This will run PostgreSQL within a Docker container via Docker Compose as well as then webapp which should then be available at http://localhost:3000.

It will also watch for file changes and automatically re-hydrate the webapp on the go.

📋 Note
The yarn command install the dependencies but also run the scripts/dev/setup.js scripts. This script does the following tasks, if necessary:

  • Copy .env.example file to a .env one.
  • Generate an EdDSA Key Pair (required in order to generate and verify JWTs)

Development Runs

Once your local repository has been setup, you can subsequently run the development environment with:

yarn dev:docker
yarn dev

Deployment

Following our global deployment strategy:

ssh <USERNAME>@<SERVER_IP>
mkdir ~/deployments/inca-app

Add the current proxy Git repository workflow:

git init --bare ~/repositories/inca-app.git
vim ~/repositories/inca-app.git/hooks/post-receive

which could look like this:

#!/bin/bash

# Exit when any command fails:
set -e

TARGET="/home/<USERNAME>/deployments/inca-app"
GIT_DIR="/home/<USERNAME>/repositories/inca-app.git"
BRANCH="main"

while read oldrev newrev ref
do
  # Only checking out the specified branch:
  if [[ $ref = "refs/heads/${BRANCH}" ]]; then
    echo "Git reference $ref received. Deploying ${BRANCH} branch to production..."
    git --work-tree="$TARGET" --git-dir="$GIT_DIR" checkout -f "$BRANCH"
    cd $TARGET
    sudo make start
  else
    echo "Git reference $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
  fi
done

Give the execution rights:

chmod +x ~/repositories/inca-app.git/hooks/post-receive

You can now exit and go into you your local proxy directory to add your server repository reference:

git remote add live ssh://<USERNAME>@<SERVER_IP>/home/<USERNAME>/repositories/inca-app.git

Everything is now ready for the proxy part and you will now be able to push any new commit to production via:

git push live main

Best practice

Conventional Commits

We follow Conventional Commits principles.

Please try to check the existing history before committing anything if you're not familiar with this convention.

Thanks to husky, your code should be automatically linted before your changes are committed. If there is any lint error left, your changes won't be committed. It's up to you to fix them.

IDEs

Recommended Visual Studio Code settings

.vscode/settings.json

{
  "editor.codeActionsOnSave": {
    "source.fixAll": true
  },
  "eslint.codeActionsOnSave.mode": "all",
  "editor.defaultFormatter": "dbaeumer.vscode-eslint",
  "eslint.format.enable": true,
  "editor.formatOnSave": true,
  "eslint.packageManager": "yarn",
  "[css]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[prisma]": {
    "editor.defaultFormatter": "Prisma.prisma"
  }
}