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

Next #476

Merged
merged 88 commits into from
Nov 26, 2024
Merged

Next #476

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
18e519a
test(dump): maj des fichiers dump pour être suivi par git lfs + ajout…
gBusato Oct 25, 2024
0ea1ab2
chore: lfs files update
antoinebigard Oct 25, 2024
103fb73
chore(dump): mise à jour des fichiers de dump
gBusato Oct 25, 2024
326ad19
refactor: wip
antoinebigard Oct 27, 2024
1871b54
refactor: wip
antoinebigard Oct 27, 2024
ed22fa9
refactor: wip
antoinebigard Oct 28, 2024
d536760
refactor: putting back circular dependency 🤮
antoinebigard Oct 28, 2024
5294c47
refactor: wip
antoinebigard Oct 28, 2024
f49c976
refactor: wip env var
antoinebigard Oct 28, 2024
9417e74
refactor: base infra wip
antoinebigard Oct 28, 2024
a1100e5
refactor: wip
antoinebigard Oct 28, 2024
7011956
refactor: show her some love, lint
antoinebigard Oct 28, 2024
b5cf7ac
refactor: typecheck
antoinebigard Oct 28, 2024
5945a4a
refactor: remove circ dependency
antoinebigard Oct 28, 2024
b54cb35
refactor: build steps
antoinebigard Oct 29, 2024
d0127b0
refactor: wip
antoinebigard Oct 29, 2024
055522c
refactor: build wip
antoinebigard Oct 29, 2024
7bff38f
refactor: ui build
antoinebigard Oct 29, 2024
f63e3df
refactor: prepare deploy
antoinebigard Oct 29, 2024
6030191
chore: fix env name
antoinebigard Oct 29, 2024
ec8c14e
fix(ci): comment test:ci
antoinebigard Oct 29, 2024
d43e9b0
fix: small missing replace
antoinebigard Oct 29, 2024
c39b97a
fix: prettier
antoinebigard Oct 29, 2024
1b4abce
Merge branch 'develop' into toto
antoinebigard Oct 29, 2024
a8bc9c2
fix: merge
antoinebigard Oct 29, 2024
649eff5
fix: dummy
antoinebigard Oct 29, 2024
d1cf8ef
chore: dump as binary
antoinebigard Oct 29, 2024
04b87c1
fix: bump sem release
antoinebigard Oct 29, 2024
815edc8
chore(ga): env recette next
antoinebigard Oct 29, 2024
f00a383
chore(waf): comment duplicate rule
antoinebigard Oct 29, 2024
6f96bc4
feat(server): passage des test en vitest
antoinebigard Oct 30, 2024
3308578
Merge pull request #475 from mission-apprentissage/feat/vitest
antoinebigard Oct 30, 2024
b60147f
chore(ci): uncomment test ci
antoinebigard Oct 30, 2024
fb13594
chore(test): un skip forgotten test
antoinebigard Oct 30, 2024
0997c48
chore: some vault update
antoinebigard Oct 30, 2024
434989b
feat: switch env
antoinebigard Oct 30, 2024
6fbe157
fix(ui): missing env
antoinebigard Oct 30, 2024
c51e97a
chore(infra): env type
antoinebigard Oct 30, 2024
bea6d7a
chore(vault): update local env from localhost to 127.0.0.1
FaXaq Oct 31, 2024
4148e06
fix(new-infra): fix cookie handling
FaXaq Nov 4, 2024
1748c85
fix(new-infra): ajout des cookies au requetes frontend
FaXaq Nov 4, 2024
a52bb33
fix(new-infra): correction d'un composant asynchrone qui entrainait u…
FaXaq Nov 4, 2024
16f05d4
fix: typecheck
FaXaq Nov 4, 2024
8e1698c
fix: tests
FaXaq Nov 4, 2024
0333681
fix: git-lfs
FaXaq Nov 6, 2024
9c29502
fix(lfs): remove lfs
FaXaq Nov 6, 2024
626e625
fix(tests): ajout des fichiers de dump avec postgres@15
FaXaq Nov 6, 2024
66eba73
fix(form): fix encoding & decoding of string
FaXaq Nov 7, 2024
b7ef18b
chore(types): types db & mauvais appel du kdbClient dans les corrections
FaXaq Nov 7, 2024
b99d6ea
fix(typecheck): remove ts-expected-error
FaXaq Nov 7, 2024
4fb21de
fix(intention-form): configuration de react-hook-form pour la désacti…
FaXaq Nov 12, 2024
c303c1b
fix(duplication-intention): omission du champ isIntention lors de la …
FaXaq Nov 12, 2024
ccc27af
Merge branch 'develop' into next
FaXaq Nov 13, 2024
b21a452
Merge branch 'develop' into next
FaXaq Nov 13, 2024
bfb178a
chore(ci): typo docker scout
antoinebigard Nov 13, 2024
89b9d0e
chore(ci): fixing log file
antoinebigard Nov 13, 2024
6d3d802
Merge branch 'develop' into next
FaXaq Nov 14, 2024
e22bd87
fix(env): ini
FaXaq Nov 18, 2024
6165210
Merge branch 'develop' into next
FaXaq Nov 18, 2024
ceb0fa9
fix(server): lodash import & typecheck following merge
FaXaq Nov 18, 2024
07b09bc
chore(recette1new): essai de délpoiement sur l'env recette1new
FaXaq Nov 19, 2024
c84b3e5
fix(error-page): ajout d'un titre à la page d'erreur
FaXaq Nov 19, 2024
f415034
fix(infra): ajout d'un env type et env name pour différencier les env…
FaXaq Nov 20, 2024
a63e8e4
feat: ajout d'un environnement de preprod
FaXaq Nov 20, 2024
213202d
fix: ajout de l'env de preprod au release app
FaXaq Nov 20, 2024
889ee15
fix: ajout preprod target au docker bake
FaXaq Nov 20, 2024
232d631
fix: intervert preprod & prod
FaXaq Nov 20, 2024
711d1dd
fix: maj metabase preprod
FaXaq Nov 20, 2024
005aa73
fix: essai metabase 1
FaXaq Nov 20, 2024
37c7fe5
fix: config metabase pour les autre env que preprod
FaXaq Nov 20, 2024
ef03bb4
fix: ajout metabase env to recette1 et recette2
FaXaq Nov 21, 2024
19b3d5f
fix: clean UI console
LucasDetre Nov 21, 2024
22308f5
fix: lint
LucasDetre Nov 21, 2024
c845c16
fix: fix des messages d'erreur au reset du password
LucasDetre Nov 19, 2024
f88c66f
fix: inclusion des places ouvertes pour les colorations en 2023
LucasDetre Nov 19, 2024
4a0043c
feat: ajout des titles dynamiques en fonction des pages
LucasDetre Nov 19, 2024
99fe7d7
fix(cli): creation migration
FaXaq Nov 25, 2024
f0c6b97
fix(release-interactive): ajout d'une garde pour éviter de créer un t…
FaXaq Nov 25, 2024
5e980b1
chore(recette): migrer de recette1new à recette1
FaXaq Nov 25, 2024
621d788
Merge branches 'fix/compteurs-places-ouvertes-2023', 'feat/accessibil…
LucasDetre Nov 21, 2024
a157185
fix: env serveur
FaXaq Nov 25, 2024
7c2aeff
fix: migrations commands
FaXaq Nov 25, 2024
36f8570
fix: cli actions context
FaXaq Nov 25, 2024
3ebfae0
chore: ajout d'une github action pour une rc manuelle
FaXaq Nov 25, 2024
fa2f6d9
chore: remove preview action
FaXaq Nov 25, 2024
2b45a31
chore: migration preprod à prod
FaXaq Nov 25, 2024
0b63771
Merge pull request #490 from mission-apprentissage/feat/merged-pr-next
LucasDetre Nov 26, 2024
20f929b
fix: mailpit password
FaXaq Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
98 changes: 98 additions & 0 deletions .bin/commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env bash

set -euo pipefail

function Help() {
# Display Help
echo "Commands"
echo " bin:setup Installs ${PRODUCT_NAME} binary with zsh completion on system"
echo " init:env Update local env files using values from vault file"
echo " docker:login Login to ghcr.io"
echo " release:interactive Build & Push Docker image releases"
echo " release:manual:rc Build & Push Docker image releases in a release candidate"
echo " release:app Build & Push Docker image releases"
echo " deploy <env> --user <your_username> Deploy application to <env>"
echo " preview:build Build preview"
echo " preview:cleanup --user <your_username> Remove preview from close pull-requests"
echo " vault:init Fetch initial vault-password from template-apprentissage"
echo " vault:edit Edit vault file"
echo " vault:password Show vault password"
echo " seed:update Update seed using a database"
echo " seed:apply Apply seed to a database"
echo " deploy:log:encrypt Encrypt Github ansible logs"
echo " deploy:log:dencrypt Decrypt Github ansible logs"
echo
echo
}

function bin:setup() {
sudo ln -fs "${ROOT_DIR}/.bin/product" "/usr/local/bin/product-${PRODUCT_NAME}"

sudo mkdir -p /usr/local/share/zsh/site-functions
sudo ln -fs "${ROOT_DIR}/.bin/zsh-completion" "/usr/local/share/zsh/site-functions/_${PRODUCT_NAME}"
sudo rm -f ~/.zcompdump*
}

function init:env() {
"${SCRIPT_DIR}/setup-local-env.sh" "$@"
}

function docker:login() {
"${SCRIPT_DIR}/docker-login.sh" "$@"
}

function release:interactive() {
"${SCRIPT_DIR}/release-interactive.sh" "$@"
}

function release:app() {
"${SCRIPT_DIR}/release-app.sh" "$@"
}

function release:manual:rc() {
"${SCRIPT_DIR}/release-manual-rc.sh" "$@"
}

function deploy() {
"${SCRIPT_DIR}/deploy-app.sh" "$@"
}

function preview:build() {
"${SCRIPT_DIR}/build-images.sh" "$@"
}

function preview:cleanup() {
"${SCRIPT_DIR}/run-playbook.sh" "preview_cleanup.yml" "preview"
}

function vault:init() {
# Ensure Op is connected
op account get > /dev/null
op document get ".vault-password-tmpl" --vault "vault-passwords-common" > "${ROOT_DIR}/.infra/vault/.vault-password.gpg"
}

function vault:edit() {
editor=${EDITOR:-'code -w'}
EDITOR=$editor "${SCRIPT_DIR}/edit-vault.sh" "$@"
}

function vault:password() {
"${SCRIPT_DIR}/get-vault-password-client.sh" "$@"
}

function seed:update() {
"${SCRIPT_DIR}/seed-update.sh" "$@"
}

function seed:apply() {
"${SCRIPT_DIR}/seed-apply.sh" "$@"
}

function deploy:log:encrypt() {
(cd "$ROOT_DIR" && "${SCRIPT_DIR}/deploy-log-encrypt.sh" "$@")
}

function deploy:log:decrypt() {
(cd "$ROOT_DIR" && "${SCRIPT_DIR}/deploy-log-decrypt.sh" "$@")
}

30 changes: 30 additions & 0 deletions .bin/product
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

set -euo pipefail

export BIN_DIR="$(dirname -- "$( readlink -f -- "$0"; )")"
export ROOT_DIR="$(dirname "${BIN_DIR}")"
export SCRIPT_DIR="$BIN_DIR/scripts"

source "${BIN_DIR}/product-meta.sh"
source "${BIN_DIR}/commands.sh"

################################################################################
################################################################################
# Main program #
################################################################################
################################################################################

readonly command=${1:-}
if [ -z "$command" ]; then
Help
fi;
shift

if [[ `command -v $command` != $command ]]; then
echo "Err: Command '$command' not found"
echo
Help
fi;

$command "$@"
7 changes: 7 additions & 0 deletions .bin/product-meta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -euo pipefail

export PRODUCT_NAME=orion
export REPO_NAME=tjp-pilotage
export DATABASE_NAME=orion
readonly OP_ACCOUNT="inserjeunes"
41 changes: 41 additions & 0 deletions .bin/scripts/build-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
set -euo pipefail

export VERSION="${1:?"Veuillez préciser la version"}"
mode=${2:?"Veuillez préciser le mode <push|load>"}
shift 2

get_channel() {
local version="$1"
channel=$(echo "$version" | cut -d '-' -f 2)

if [ "$channel" == "$version" ]; then
channel="latest"
else
channel=$(echo $channel | cut -d '.' -f 1 )
fi

echo $channel
}

if [[ $# == "0" ]]; then
echo "Veuillez spécifier les environnements à build (production, recette, preview, local)"
exit 1;
fi;

set +e
docker buildx create --name "ij-${PRODUCT_NAME}" --driver docker-container --config "$SCRIPT_DIR/buildkitd.toml" 2> /dev/null
set -e

if [[ ! -z "${CI:-}" ]]; then
export DEPS_ID=($(md5sum $ROOT_DIR/yarn.lock))
else
export DEPS_ID=""
fi

export CHANNEL=$(get_channel $VERSION)

# "$@" is the list of environements
docker buildx bake --builder "ij-${PRODUCT_NAME}" --${mode} "$@"
docker builder prune --builder "ij-${PRODUCT_NAME}" --keep-storage 20GB --force
docker buildx stop --builder "ij-${PRODUCT_NAME}"
7 changes: 7 additions & 0 deletions .bin/scripts/buildkitd.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[worker.oci]
max-parallelism = 2

[[worker.oci.gcpolicy]]
all = true
keepBytes = "20GB"
keepDuration = "72h"
26 changes: 26 additions & 0 deletions .bin/scripts/deploy-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail

readonly ENV_FILTER=${1:?"Merci de préciser un ou plusieurs environnements (ex. recette ou production)"}
shift

function deploy() {
echo "Déploiement sur l'environnement ${ENV_FILTER}..."

if [[ "$ENV_FILTER" == "preview" ]]; then
readonly PR_NUMBER=${1:?"Merci de préciser le numéro de la Pull Request (ex. 33)"};
shift;

if ! [[ $PR_NUMBER =~ ^[0-9]+$ ]]; then
echo "Merci de préciser le numéro de la Pull Request (ex. 33)" >&2;
echo "Usage: deploy-app.sh preview <pr_number> <ansible_args...>" >&2;
exit 1
fi

"${ROOT_DIR}/.bin/scripts/run-playbook.sh" "preview.yml" "$ENV_FILTER" --extra-var "pr_number=$PR_NUMBER"
else
"${ROOT_DIR}/.bin/scripts/run-playbook.sh" "deploy.yml" "$ENV_FILTER" "$@"
fi
}

deploy "$@"
40 changes: 40 additions & 0 deletions .bin/scripts/deploy-log-decrypt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -euo pipefail

if [ -z "${1:-}" ]; then
read -p "Veuillez renseigner l'ID du run: " RUN_ID
else
readonly RUN_ID="$1"
shift
fi

if [ -z "${1:-}" ]; then
read -p "Veuillez renseigner l'ID du job: " JOB_ID
else
readonly JOB_ID="$1"
shift
fi

if [[ -z "${ANSIBLE_VAULT_PASSWORD_FILE:-}" ]]; then
ansible_extra_opts+=("--vault-password-file" "${SCRIPT_DIR}/get-vault-password-client.sh")
else
echo "Récupération de la passphrase depuis l'environnement variable ANSIBLE_VAULT_PASSWORD_FILE"
fi

readonly PASSPHRASE="$ROOT_DIR/.bin/SEED_PASSPHRASE.txt"
readonly VAULT_FILE="${ROOT_DIR}/.infra/vault/vault.yml"

delete_cleartext() {
rm -f "$PASSPHRASE"
}
trap delete_cleartext EXIT


rm -f /tmp/deploy.log.gpg

gh run download "$RUN_ID" -n "logs-$JOB_ID" -D /tmp

ansible-vault view "${ansible_extra_opts[@]}" "$VAULT_FILE" | yq '.vault.SEED_GPG_PASSPHRASE' > "$PASSPHRASE"

gpg -d --batch --passphrase-file "$PASSPHRASE" /tmp/deploy.log.gpg
23 changes: 23 additions & 0 deletions .bin/scripts/deploy-log-encrypt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -euo pipefail

if [[ -z "${ANSIBLE_VAULT_PASSWORD_FILE:-}" ]]; then
ansible_extra_opts+=("--vault-password-file" "${SCRIPT_DIR}/get-vault-password-client.sh")
else
echo "Récupération de la passphrase depuis l'environnement variable ANSIBLE_VAULT_PASSWORD_FILE"
fi

readonly PASSPHRASE="$ROOT_DIR/.bin/SEED_PASSPHRASE.txt"
readonly VAULT_FILE="${ROOT_DIR}/.infra/vault/vault.yml"

delete_cleartext() {
rm -f "$PASSPHRASE"
}
trap delete_cleartext EXIT

ansible-vault view "${ansible_extra_opts[@]}" "$VAULT_FILE" | yq '.vault.SEED_GPG_PASSPHRASE' > "$PASSPHRASE"

# Make sur the file exists
touch /tmp/deploy.log
gpg -c --cipher-algo twofish --batch --passphrase-file "$PASSPHRASE" -o /tmp/deploy.log.gpg /tmp/deploy.log
10 changes: 10 additions & 0 deletions .bin/scripts/docker-login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -euo pipefail

read -p "[ghcr.io] user ? : " u
read -p "[ghcr.io] GH personnal token ? : " p

echo "Login sur le registry ..."
echo $p | docker login ghcr.io -u "$u" --password-stdin
echo "Logged!"
6 changes: 6 additions & 0 deletions .bin/scripts/edit-vault.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail

readonly VAULT_FILE="${ROOT_DIR}/.infra/vault/vault.yml"

ansible-vault edit --vault-password-file="${SCRIPT_DIR}/get-vault-password-client.sh" "${VAULT_FILE}"
70 changes: 70 additions & 0 deletions .bin/scripts/get-vault-password-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
set -euo pipefail

# echo "Command line interface to view the vault password"
# echo "This file implements Ansible specifications third-party vault tools"
# echo "For more informations see https://docs.ansible.com/ansible/latest/vault_guide/vault_managing_passwords.html#storing-passwords-in-third-party-tools-with-vault-password-client-scripts"

## CHECK UPDATES AND RENEW

readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly BIN_DIR="$(dirname "${SCRIPT_DIR}")"
readonly ROOT_DIR="$(dirname "${BIN_DIR}")"
readonly VAULT_DIR="${ROOT_DIR}/.infra/vault"
readonly VAULT_FILE="${VAULT_DIR}/vault.yml"
readonly PRODUCT_NAME="orion"
readonly OP_ACCOUNT="inserjeunes"

DOCUMENT_CONTENT=$(op --account "${OP_ACCOUNT}" document get ".vault-password-${PRODUCT_NAME}" --vault "vault-passwords-common" || echo "")
vault_password_file="${VAULT_DIR}/.vault-password.gpg"
previous_vault_password_file="${VAULT_DIR}/.vault-password-previous.gpg"

if [ ! -f "$vault_password_file" ]; then
echo "$DOCUMENT_CONTENT" > "$vault_password_file"
echo "vault password créé avec succès."

# Si le fichier existe et que son contenu est différent
elif [ ! -z "$DOCUMENT_CONTENT" ] && [ "$DOCUMENT_CONTENT" != "$(cat "${vault_password_file}")" ]; then
# Renommer l'ancien fichier
mv "$vault_password_file" "$previous_vault_password_file"
# echo "vault-password existant renommé en .vault-password-previous.gpg."

# Créer un nouveau fichier avec le contenu actuel
echo "$DOCUMENT_CONTENT" > "$vault_password_file"
# echo "Nouveau vault-password créé avec succès."

previous_vault_password_file_clear_text="${VAULT_DIR}/prev_clear_text"
vault_password_file_clear_text="${VAULT_DIR}/new_clear_text"

delete_cleartext() {
rm -f "$previous_vault_password_file_clear_text" "$vault_password_file_clear_text"
}
trap delete_cleartext EXIT

gpg --quiet --batch --use-agent --decrypt "${previous_vault_password_file}" > "${previous_vault_password_file_clear_text}"
gpg --quiet --batch --use-agent --decrypt "${vault_password_file}" > "${vault_password_file_clear_text}"

ansible-vault rekey \
--vault-id "${previous_vault_password_file_clear_text}" \
--new-vault-id "${vault_password_file_clear_text}" \
"${VAULT_FILE}" > /dev/null || true

delete_cleartext
fi


decrypt_password() {
## Decrypt

if test -f "${vault_password_file}"; then
gpg --quiet --batch --use-agent --decrypt "${vault_password_file}"
else
#Allows to run playbooks with --vault-password-file even if password has not been yet generated
echo "not-yet-generated"
fi

gpgconf --kill gpg-agent
}


decrypt_password
12 changes: 12 additions & 0 deletions .bin/scripts/get-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

VERSION=$(git describe --tags --abbrev=0 --candidates 100 --always)
HEAD=$(git rev-parse HEAD)

if [[ "$VERSION" = "$HEAD" ]]; then
VERSION="v0.0.0"
fi;

set -euo pipefail

echo "${VERSION:1}"
Loading