From be11af6eee2a68ae20b63c63ddacf3e126be9d26 Mon Sep 17 00:00:00 2001
From: Simon Malesys <simon.malesys@pasteur.fr>
Date: Thu, 13 Feb 2025 17:16:06 +0100
Subject: [PATCH] Add the tests to the CI

---
 .gitlab-ci.yml | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8efadc91..31fe65ea 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,25 +16,35 @@ workflow:
 # Pipeline start
 # =============================================================================
 
+# Run the unit tests
+testing:
+  image: node:22-alpine
+  stage: validate
+  rules:
+    - changes:
+        - src/**/*
+  script:
+    - npm test
+
 # Validate the fasta files if they have changed
 validate-fasta-files:
+  image: node:22-alpine
   stage: validate
   rules:
     - changes:
         - data/*.fasta
-  image: node:22-alpine
   script:
     - npm run validate
 
 # Build the archive of the fasta files and compute the stats.
 # Commit the files in the data folder, triggering another CI.
 build-archive-and-stats:
+  image: node:22-alpine
   stage: archive
   rules:
     - if: $CI_COMMIT_BRANCH == "master"
       changes:
         - data/*.fasta
-  image: node:22-alpine
   script:
     - export CURRENT_DATE=$(date +'%Y-%m-%d')
     - export ARCHIVE_PATH=data/${CURRENT_DATE}.tar.gz
@@ -54,10 +64,10 @@ build-archive-and-stats:
 
 # Build the docker image and store it the gitlab registery.
 build-docker-image:
+  image: docker:24
   stage: build
   rules:
     - if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "dev"
-  image: docker:24
   interruptible: true
   script:
     - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
@@ -68,10 +78,10 @@ build-docker-image:
 # Fetch the image of MongoDB from the DockerHub and store it if there is any changes.
 # This avoid issues with Docker in case of overpulling.
 fetch-mongo-image:
+  image: docker:24
   stage: build
   rules:
     - if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "dev"
-  image: docker:24
   interruptible: true
   script:
     - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
@@ -81,8 +91,8 @@ fetch-mongo-image:
 
 # Base stage for deploy-dev and deploy-prod
 .deploy:
-  stage: deploy
   image: registry-gitlab.pasteur.fr/dsi-tools/docker-images:docker_kubernetes_image
+  stage: deploy
   interruptible: true
   script:
     - kubectl delete secret registry-gitlab -n ${NAMESPACE} --ignore-not-found=true
-- 
GitLab