From 82ac3b246de5a69d5e2730bfdffe14d15c9d4781 Mon Sep 17 00:00:00 2001 From: sandcha <sandcha@users.noreply.github.com> Date: Mon, 24 Feb 2025 15:34:52 +0100 Subject: [PATCH 1/7] =?UTF-8?q?Retire=20l'ancien=20build=20avant=20d=C3=A9?= =?UTF-8?q?ploiement=20dans=20le=20script=20deploy.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab/ci/deploy.sh | 6 +++--- package.json | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab/ci/deploy.sh b/.gitlab/ci/deploy.sh index c24747d..39eb196 100644 --- a/.gitlab/ci/deploy.sh +++ b/.gitlab/ci/deploy.sh @@ -5,14 +5,14 @@ # stop at first error set -e -echo "Stop all services..." +echo "Stop the service before deleting the build..." systemctl --user stop dotations-ui-integ.service -# Later: remove dependencies before reinstall? +npm run clean:build npm install npm run build -echo "Restart service..." +echo "Start the service after build creation..." systemctl --user start dotations-ui-integ.service echo "Deployment done! 🎉" diff --git a/package.json b/package.json index 4407d07..a52b85d 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "coverage": "vitest run --coverage", "clean": "rm -Rf .svelte-kit/;rm -Rf node_modules/;rm -Rf build/", + "clean:build": "rm -Rf build/", "dev": "vite dev", "format": "prettier --write .", "lint": "prettier --check . && eslint .", -- GitLab From ef97eeeca3faad3cf67750c9f49412b0ace3dedc Mon Sep 17 00:00:00 2001 From: sandcha <sandcha@users.noreply.github.com> Date: Mon, 24 Feb 2025 15:36:37 +0100 Subject: [PATCH 2/7] =?UTF-8?q?Met=20=C3=A0=20jour=20les=20sources=20du=20?= =?UTF-8?q?d=C3=A9p=C3=B4t=20au=20d=C3=A9ploiement=20en=20int=C3=A9gration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c6bb50a..69aae35 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,10 +53,13 @@ release-and-tag: # artifacts from all previous stages are passed by default deploy-integ: - # SSH_PRIVATE_KEY and INTEGRATION_IP defined in: - # https://git.leximpact.dev/groups/leximpact/simulateur-dotations-communes/-/settings/ci_cd - # INTEGRATION_HOST_DOMAIN_NAME defined in: - # https://git.leximpact.dev/groups/leximpact/-/settings/ci_cd + variables: + GIT_AUTHOR_NAME: "leximpact-bot" + GIT_EMAIL: "62298368+leximpact-bot@users.noreply.github.com" + # SSH_PRIVATE_KEY and INTEGRATION_IP defined in: + # https://git.leximpact.dev/groups/leximpact/simulateur-dotations-communes/-/settings/ci_cd + # INTEGRATION_HOST_DOMAIN_NAME defined in: + # https://git.leximpact.dev/groups/leximpact/-/settings/ci_cd stage: deploy before_script: # install git to have ssh-agent and ssh-add @@ -67,12 +70,14 @@ deploy-integ: # check that we are in a container (inside Proxmox LXC container) before bypassing StrictHostKeyChecking - '[[ -f /.dockerenv ]] && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\tLogLevel quiet\n" > ~/.ssh/config' script: - # remove previous build on integration server - - ssh -J gitlabci@$INTEGRATION_HOST_DOMAIN_NAME leximpact@$INTEGRATION_IP "cd $CI_PROJECT_NAME && rm -Rf build/* && exit" + # configure GIT user + - ssh -J gitlabci@$INTEGRATION_HOST_DOMAIN_NAME leximpact@$INTEGRATION_IP "cd $CI_PROJECT_NAME && git config user.email $GIT_EMAIL && git config user.name $GIT_AUTHOR_NAME" + # update the project's source code + - ssh -J gitlabci@$INTEGRATION_HOST_DOMAIN_NAME leximpact@$INTEGRATION_IP "cd $CI_PROJECT_NAME && git fetch && git checkout -B $CI_COMMIT_REF_NAME $CI_COMMIT_SHA && git pull origin $CI_COMMIT_REF_NAME && exit" # get deploy.sh on container (on SSH port 22) - ssh -J gitlabci@$INTEGRATION_HOST_DOMAIN_NAME leximpact@$INTEGRATION_IP "mkdir -p $CI_PROJECT_NAME/.gitlab/ci/ && exit" - scp -o "ProxyCommand ssh gitlabci@$INTEGRATION_HOST_DOMAIN_NAME nc -w 1 %h 22" .gitlab/ci/deploy.sh leximpact@$INTEGRATION_IP:$CI_PROJECT_NAME/.gitlab/ci/deploy.sh - # use a ssh relay to connect to the host containing the runner and run deploy.sh + # use a ssh relay to connect to the host containing the runner and run .gitlab/ci/deploy.sh - ssh -J gitlabci@$INTEGRATION_HOST_DOMAIN_NAME leximpact@$INTEGRATION_IP "cd $CI_PROJECT_NAME && bash .gitlab/ci/deploy.sh && exit" environment: # defined in: https://git.leximpact.dev/leximpact/simulateur-dotations-communes/leximpact-dotations-ui/-/environments -- GitLab From d4f95b79bf80e0915b96e271ae43d26dd0850aa3 Mon Sep 17 00:00:00 2001 From: sandcha <sandcha@users.noreply.github.com> Date: Mon, 24 Feb 2025 15:45:31 +0100 Subject: [PATCH 3/7] =?UTF-8?q?TO=20REVERT=20D=C3=A9sactive=20le=20check?= =?UTF-8?q?=20de=20version=20pour=20tester=20le=20d=C3=A9ploiement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 69aae35..608fdbb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ cache: stages: - install - - check + # - check - publish - deploy @@ -20,19 +20,19 @@ install-and-build: # INFO rebuild is needed when Node version changes - npm run build -check-version: - stage: check - before_script: - # apt update to allow apt install to list existing libraries - - apt update --yes - - apt-get install -y git - - git status -vv - # INFO fetch depth set in GitLab Settings > CI/CD > General pipelines > Git shallow clone - script: - # check for functional changes and version number with executable script - - .gitlab/ci/is-version-number-acceptable.sh - except: - - main +# check-version: +# stage: check +# before_script: +# # apt update to allow apt install to list existing libraries +# - apt update --yes +# - apt-get install -y git +# - git status -vv +# # INFO fetch depth set in GitLab Settings > CI/CD > General pipelines > Git shallow clone +# script: +# # check for functional changes and version number with executable script +# - .gitlab/ci/is-version-number-acceptable.sh +# except: +# - main # create release in order to create tag (to bypass 'git tag' access rights configuration) release-and-tag: -- GitLab From cb9ac08ba1ba3b43135d0af9b94b3b071de74c56 Mon Sep 17 00:00:00 2001 From: sandcha <sandcha@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:02:08 +0100 Subject: [PATCH 4/7] =?UTF-8?q?Revert=20"TO=20REVERT=20D=C3=A9sactive=20le?= =?UTF-8?q?=20check=20de=20version=20pour=20tester=20le=20d=C3=A9ploiement?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit d4f95b79bf80e0915b96e271ae43d26dd0850aa3 --- .gitlab-ci.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 608fdbb..69aae35 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ cache: stages: - install - # - check + - check - publish - deploy @@ -20,19 +20,19 @@ install-and-build: # INFO rebuild is needed when Node version changes - npm run build -# check-version: -# stage: check -# before_script: -# # apt update to allow apt install to list existing libraries -# - apt update --yes -# - apt-get install -y git -# - git status -vv -# # INFO fetch depth set in GitLab Settings > CI/CD > General pipelines > Git shallow clone -# script: -# # check for functional changes and version number with executable script -# - .gitlab/ci/is-version-number-acceptable.sh -# except: -# - main +check-version: + stage: check + before_script: + # apt update to allow apt install to list existing libraries + - apt update --yes + - apt-get install -y git + - git status -vv + # INFO fetch depth set in GitLab Settings > CI/CD > General pipelines > Git shallow clone + script: + # check for functional changes and version number with executable script + - .gitlab/ci/is-version-number-acceptable.sh + except: + - main # create release in order to create tag (to bypass 'git tag' access rights configuration) release-and-tag: -- GitLab From 49164be9f5f425eb3345e6c2ea07d033c9269df4 Mon Sep 17 00:00:00 2001 From: sandcha <sandcha@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:11:46 +0100 Subject: [PATCH 5/7] Explicite que la clef SSH est celle du runner et non du leximpact-bot par exemple --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 69aae35..8cb60ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,6 +66,7 @@ deploy-integ: - apt update - apt-get install -y git curl - eval $(ssh-agent -s) + # add the ssh key of the GitLab runner - ssh-add <(echo "$SSH_PRIVATE_KEY") # check that we are in a container (inside Proxmox LXC container) before bypassing StrictHostKeyChecking - '[[ -f /.dockerenv ]] && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\tLogLevel quiet\n" > ~/.ssh/config' -- GitLab From 2a9bbe0d4b5cccb6f575c0efb2347408a7b8d623 Mon Sep 17 00:00:00 2001 From: sandcha <sandcha@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:34:55 +0100 Subject: [PATCH 6/7] =?UTF-8?q?Evite=20de=20stopper=20le=20service=20en=20?= =?UTF-8?q?int=C3=A9gration=20en=20cas=20de=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab/ci/deploy.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab/ci/deploy.sh b/.gitlab/ci/deploy.sh index 39eb196..031b528 100644 --- a/.gitlab/ci/deploy.sh +++ b/.gitlab/ci/deploy.sh @@ -5,14 +5,14 @@ # stop at first error set -e -echo "Stop the service before deleting the build..." -systemctl --user stop dotations-ui-integ.service - -npm run clean:build +# INFO: +# no need to stop the service or delete the previous build before (re)build +# (in case of memory shortage move the building step to the CI) +echo "Update the application's dependencies and build..." npm install npm run build -echo "Start the service after build creation..." -systemctl --user start dotations-ui-integ.service +echo "Restart the service after build update..." +systemctl --user restart dotations-ui-integ.service echo "Deployment done! 🎉" -- GitLab From a186f133442dafb509d1a6d1c07a62a37b6d7338 Mon Sep 17 00:00:00 2001 From: sandcha <sandcha@users.noreply.github.com> Date: Mon, 24 Feb 2025 16:43:43 +0100 Subject: [PATCH 7/7] =?UTF-8?q?Versionne=20en=20patch=200.4.1=20la=20mise?= =?UTF-8?q?=20=C3=A0=20jour=20du=20job=20deploy-integ=20de=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 715d7e5..e374bed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # CHANGELOG +### 0.4.1 [!9](https://git.leximpact.dev/leximpact/simulateur-dotations-communes/leximpact-dotations-ui/-/merge_requests/9) + +- Amélioration technique. +- Détails : + - Ajoute la mise à jour du code source lors d'un déploiement en intégration + - Complète le job de CI `deploy-integ` + - Définit la mise à jour du service en intégration dans `.gitlab/ci/deploy.sh` + ## 0.4.0 [!8](https://git.leximpact.dev/leximpact/simulateur-dotations-communes/leximpact-dotations-ui/-/merge_requests/8) - Ajout d'une fonctionnalité. Correction d'un crash. diff --git a/package.json b/package.json index a52b85d..a56b91f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "leximpact-dotations-ui", - "version": "0.4.0", + "version": "0.4.1", "private": true, "scripts": { "build": "vite build", -- GitLab