From 1f9b12e9d688ea618028523f10cafc080ac5b88c Mon Sep 17 00:00:00 2001 From: Emmanuel Raviart Date: Tue, 15 Nov 2022 15:31:20 +0100 Subject: [PATCH] Add CI --- .gitlab-ci.yml | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..b4b3082 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,78 @@ +default: + image: node:lts + + cache: + paths: + - node_modules/ + +variables: + ## This variable can be overridden at pipeline execution time. + ## Possible values: + ## - dole + ## - jorf + ## - kali + ## - legi + DATASET: undefined + ## Ensure that all the Git tags are retrieved. + ## https://docs.gitlab.com/ee/user/project/pipelines/settings.html#git-shallow-clone + GIT_DEPTH: 0 + ## Needed for storing locale dates + TZ: Europe/Paris + +stages: + - build + - test + - download + +build: + stage: build + before_script: + - npm ci + script: + - npm run build + +test: + stage: test + before_script: + - npm ci + script: + - npm run test + +download: + stage: test + only: + - schedules + - web + + before_script: + ## Install ssh-agent if not already installed, it is required by Docker. + ## (change apt-get to yum if you use an RPM-based image) + - "which ssh-agent || ( apt update -y && apt install openssh-client -y )" + + ## Run ssh-agent (inside the build environment) + - eval $(ssh-agent -s) + + ## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store + ## We're using tr to fix line endings which makes ed25519 keys work + ## without extra base64 encoding. + ## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556 + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + + ## Create the SSH directory and give it the right permissions + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + + ## Accept the SSH host keys of git.en-root.org. + - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + + ## Set the Git user name and email. + - git config --global user.email "tricoteuses@tricoteuses.fr" + - git config --global user.name "Tricoteuses données Dila" + + - npm ci + + script: + - mkdir -p ../dila-data/ + - git clone git@git.en-root.org:tricoteuses/data/dila/${DATASET}.git ../dila-data/${DATASET} + - npx tsx src/scripts/download_dila_dataset.ts ${DATASET} --push