From fc2e9fd5967e7178f5d97f81cebe209ce6a44dda Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 31 Mar 2023 06:11:42 +0000 Subject: [PATCH 01/14] Add gitlabCI --- .gitla-ci.yml | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .gitla-ci.yml diff --git a/.gitla-ci.yml b/.gitla-ci.yml new file mode 100644 index 0000000..d720d58 --- /dev/null +++ b/.gitla-ci.yml @@ -0,0 +1,99 @@ +# This file is a template, and might need editing before it works on your project. +# Using job token: https://docs.gitlab.com/ee/user/project/new_ci_build_permissions_model.html#job-token + +########################@ + +image: docker:latest +services: +- docker:dind + +stages: + - build + - test + - release + +before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + +include: + - template: Code-Quality.gitlab-ci.yml + +code_quality: + rules: + - if: '$CODE_QUALITY_DISABLED' + when: never + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # Run code quality job in merge request pipelines + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' # Run code quality job in pipelines on the master branch (but not in other branch pipelines) + - if: '$CI_COMMIT_TAG' + artifacts: + paths: [gl-code-quality-report.json] + stage: test + +# Build the master branch when there is no tag +build-master: + stage: build + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + only: + - master +# Additional build when a tag is made +build-tags: + stage: build + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + only: + - tags + +# Steps for the merge request +build-mr: + stage: build + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + only: + - merge_requests + +test: + stage: test + script: + - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + - docker run "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" bash -c 'source $COMMON_BUILD_PREFIX/setup.sh && source ../bin/setup.sh && nd280-validate --apply' + only: + - merge_requests + - master + - tags + +documentation: + stage: test + script: + - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + - docker run "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" bash -c 'source $COMMON_BUILD_PREFIX/setup.sh && source ../bin/setup.sh && make hatRecon_documentation' + only: + - merge_requests + - master + - tags + +release-master: + stage: release + script: + - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE:latest" + - docker push "$CI_REGISTRY_IMAGE:latest" + only: + - master + +release-tags: + stage: release + script: + - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" + only: + - tags + +variables: + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "" + #DOCKER_HOST: tcp://docker:2375 From 0ff4bbf73537138eeef4d0678a738cd7a1eff68e Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 31 Mar 2023 06:12:31 +0000 Subject: [PATCH 02/14] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d720d58 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,99 @@ +# This file is a template, and might need editing before it works on your project. +# Using job token: https://docs.gitlab.com/ee/user/project/new_ci_build_permissions_model.html#job-token + +########################@ + +image: docker:latest +services: +- docker:dind + +stages: + - build + - test + - release + +before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + +include: + - template: Code-Quality.gitlab-ci.yml + +code_quality: + rules: + - if: '$CODE_QUALITY_DISABLED' + when: never + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # Run code quality job in merge request pipelines + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' # Run code quality job in pipelines on the master branch (but not in other branch pipelines) + - if: '$CI_COMMIT_TAG' + artifacts: + paths: [gl-code-quality-report.json] + stage: test + +# Build the master branch when there is no tag +build-master: + stage: build + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + only: + - master +# Additional build when a tag is made +build-tags: + stage: build + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + only: + - tags + +# Steps for the merge request +build-mr: + stage: build + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + only: + - merge_requests + +test: + stage: test + script: + - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + - docker run "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" bash -c 'source $COMMON_BUILD_PREFIX/setup.sh && source ../bin/setup.sh && nd280-validate --apply' + only: + - merge_requests + - master + - tags + +documentation: + stage: test + script: + - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + - docker run "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" bash -c 'source $COMMON_BUILD_PREFIX/setup.sh && source ../bin/setup.sh && make hatRecon_documentation' + only: + - merge_requests + - master + - tags + +release-master: + stage: release + script: + - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE:latest" + - docker push "$CI_REGISTRY_IMAGE:latest" + only: + - master + +release-tags: + stage: release + script: + - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" + only: + - tags + +variables: + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "" + #DOCKER_HOST: tcp://docker:2375 From 3f847a3e4f0b10cd560d40432008718756ed193e Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 31 Mar 2023 06:13:36 +0000 Subject: [PATCH 03/14] Add new file --- .codeclimate.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .codeclimate.yml diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 0000000..d6312c9 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,6 @@ +version: "2" +plugins: + cppcheck: + enabled: true + duplication: + enabled: true From a5d7380d5c897888d2524c99cfb30cc96948f880 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 31 Mar 2023 06:32:27 +0000 Subject: [PATCH 04/14] Delete .gitla-ci.yml --- .gitla-ci.yml | 99 --------------------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 .gitla-ci.yml diff --git a/.gitla-ci.yml b/.gitla-ci.yml deleted file mode 100644 index d720d58..0000000 --- a/.gitla-ci.yml +++ /dev/null @@ -1,99 +0,0 @@ -# This file is a template, and might need editing before it works on your project. -# Using job token: https://docs.gitlab.com/ee/user/project/new_ci_build_permissions_model.html#job-token - -########################@ - -image: docker:latest -services: -- docker:dind - -stages: - - build - - test - - release - -before_script: - - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - -include: - - template: Code-Quality.gitlab-ci.yml - -code_quality: - rules: - - if: '$CODE_QUALITY_DISABLED' - when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # Run code quality job in merge request pipelines - - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' # Run code quality job in pipelines on the master branch (but not in other branch pipelines) - - if: '$CI_COMMIT_TAG' - artifacts: - paths: [gl-code-quality-report.json] - stage: test - -# Build the master branch when there is no tag -build-master: - stage: build - script: - - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - only: - - master -# Additional build when a tag is made -build-tags: - stage: build - script: - - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - only: - - tags - -# Steps for the merge request -build-mr: - stage: build - script: - - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - only: - - merge_requests - -test: - stage: test - script: - - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - - docker run "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" bash -c 'source $COMMON_BUILD_PREFIX/setup.sh && source ../bin/setup.sh && nd280-validate --apply' - only: - - merge_requests - - master - - tags - -documentation: - stage: test - script: - - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - - docker run "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" bash -c 'source $COMMON_BUILD_PREFIX/setup.sh && source ../bin/setup.sh && make hatRecon_documentation' - only: - - merge_requests - - master - - tags - -release-master: - stage: release - script: - - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE:latest" - - docker push "$CI_REGISTRY_IMAGE:latest" - only: - - master - -release-tags: - stage: release - script: - - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" - only: - - tags - -variables: - DOCKER_DRIVER: overlay2 - DOCKER_TLS_CERTDIR: "" - #DOCKER_HOST: tcp://docker:2375 From 66a7c14c1ff9bfba805effb1d64a1fc38657b36e Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 2 Jun 2023 08:57:29 +0200 Subject: [PATCH 05/14] Update gitlabCI to use python --- .gitlab-ci.yml | 151 +++++++++++++++++++------------------------------ 1 file changed, 57 insertions(+), 94 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d720d58..f2a20a5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,99 +1,62 @@ -# This file is a template, and might need editing before it works on your project. -# Using job token: https://docs.gitlab.com/ee/user/project/new_ci_build_permissions_model.html#job-token +# To contribute improvements to CI/CD templates, please follow the Development guide at: +# https://docs.gitlab.com/ee/development/cicd/templates.html +# This specific template is located at: +# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml -########################@ +# Official language image. Look for the different tagged releases at: +# https://hub.docker.com/r/library/python/tags/ +#image: python:latest -image: docker:latest -services: -- docker:dind - -stages: - - build - - test - - release +# Change pip's cache directory to be inside the project directory since we can +# only cache local items. +variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + +# Pip's cache doesn't store the python packages +# https://pip.pypa.io/en/stable/topics/caching/ +# +# If you want to also cache the installed packages, you have to install +# them in a virtualenv and cache it as well. +cache: + paths: + - .cache/pip + - venv/ +tags: + - python before_script: - - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - -include: - - template: Code-Quality.gitlab-ci.yml - -code_quality: - rules: - - if: '$CODE_QUALITY_DISABLED' - when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' # Run code quality job in merge request pipelines - - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' # Run code quality job in pipelines on the master branch (but not in other branch pipelines) - - if: '$CI_COMMIT_TAG' - artifacts: - paths: [gl-code-quality-report.json] - stage: test - -# Build the master branch when there is no tag -build-master: - stage: build - script: - - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - only: - - master -# Additional build when a tag is made -build-tags: - stage: build - script: - - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - only: - - tags - -# Steps for the merge request -build-mr: - stage: build - script: - - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - only: - - merge_requests - -test: - stage: test - script: - - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - - docker run "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" bash -c 'source $COMMON_BUILD_PREFIX/setup.sh && source ../bin/setup.sh && nd280-validate --apply' - only: - - merge_requests - - master - - tags - -documentation: - stage: test - script: - - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - - docker run "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" bash -c 'source $COMMON_BUILD_PREFIX/setup.sh && source ../bin/setup.sh && make hatRecon_documentation' - only: - - merge_requests - - master - - tags - -release-master: - stage: release + - python --version ; pip --version # For debugging + - pip install virtualenv + - virtualenv venv + - source venv/bin/activate + +#test: +# script: +# - pip install ruff tox # you can also use tox +# - pip install --editable ".[test]" +# - tox -e py,ruff + +run: script: - - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE:latest" - - docker push "$CI_REGISTRY_IMAGE:latest" - only: - - master - -release-tags: - stage: release - script: - - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" - only: - - tags - -variables: - DOCKER_DRIVER: overlay2 - DOCKER_TLS_CERTDIR: "" - #DOCKER_HOST: tcp://docker:2375 + - pip install . + # run the command here + artifacts: + paths: + - build/* + +#pages: +# script: +# - pip install sphinx sphinx-rtd-theme +# - cd doc +# - make html +# - mv build/html/ ../public/ +# artifacts: +# paths: +# - public +# rules: +# - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + +#deploy: +# stage: deploy +# script: echo "Define your deployment script!" +# environment: production From 0802bcce78e37c90af43ba1ddbe34eaa5dada3a4 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 2 Jun 2023 07:19:37 +0000 Subject: [PATCH 06/14] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f2a20a5..df99416 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,8 +21,6 @@ cache: paths: - .cache/pip - venv/ -tags: - - python before_script: - python --version ; pip --version # For debugging @@ -36,7 +34,9 @@ before_script: # - pip install --editable ".[test]" # - tox -e py,ruff -run: +build: + tags: + - python script: - pip install . # run the command here From dcba17120a7b8eb8fe0d5f386c53ba19c5f8ffe9 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 2 Jun 2023 07:21:24 +0000 Subject: [PATCH 07/14] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df99416..9a2219a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,7 +36,7 @@ before_script: build: tags: - - python + - python3 script: - pip install . # run the command here From c466fe1dc0a25caf3d180377c4f11d47cb58999f Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 2 Jun 2023 07:24:11 +0000 Subject: [PATCH 08/14] Update swig --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a2219a..efa7a44 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,9 @@ cache: - venv/ before_script: + - apt-get remove swig + - apt-get install -y swig3.0 + - ln -s /usr/bin/swig3.0 /usr/bin/swig - python --version ; pip --version # For debugging - pip install virtualenv - virtualenv venv From 6c377df641324a2c9befb64ccaa4eb20e256aeec Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 2 Jun 2023 07:24:49 +0000 Subject: [PATCH 09/14] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index efa7a44..5bd3c87 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,7 +23,6 @@ cache: - venv/ before_script: - - apt-get remove swig - apt-get install -y swig3.0 - ln -s /usr/bin/swig3.0 /usr/bin/swig - python --version ; pip --version # For debugging From 95a57e4d1860b2c582f71e634e8fe6d1399ada12 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 2 Jun 2023 07:25:19 +0000 Subject: [PATCH 10/14] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5bd3c87..34dc251 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,7 @@ cache: - venv/ before_script: + - apt-get update - apt-get install -y swig3.0 - ln -s /usr/bin/swig3.0 /usr/bin/swig - python --version ; pip --version # For debugging From a8ac4ddcdf41a889a148d120ce46ebb79c8a5269 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 2 Jun 2023 07:27:27 +0000 Subject: [PATCH 11/14] Update .gitlab-ci.yml file --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 34dc251..9fb8c57 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,8 +24,8 @@ cache: before_script: - apt-get update - - apt-get install -y swig3.0 - - ln -s /usr/bin/swig3.0 /usr/bin/swig + - apt-get install -y swig4.0 + - ln -s /usr/bin/swig4.0 /usr/bin/swig - python --version ; pip --version # For debugging - pip install virtualenv - virtualenv venv From 723fb4b839e0667a1d2fa6f64b5a1044cb6dd6e1 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 16 Aug 2024 08:54:09 +0200 Subject: [PATCH 12/14] Change CI to use docker containers --- .gitlab-ci.yml | 89 ++++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 58 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9fb8c57..de93206 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,65 +1,38 @@ # To contribute improvements to CI/CD templates, please follow the Development guide at: # https://docs.gitlab.com/ee/development/cicd/templates.html # This specific template is located at: -# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml +# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Docker.gitlab-ci.yml -# Official language image. Look for the different tagged releases at: -# https://hub.docker.com/r/library/python/tags/ -#image: python:latest - -# Change pip's cache directory to be inside the project directory since we can -# only cache local items. -variables: - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - -# Pip's cache doesn't store the python packages -# https://pip.pypa.io/en/stable/topics/caching/ +# Build a Docker image with CI/CD and push to the GitLab registry. +# Docker-in-Docker documentation: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html # -# If you want to also cache the installed packages, you have to install -# them in a virtualenv and cache it as well. -cache: - paths: - - .cache/pip - - venv/ - -before_script: - - apt-get update - - apt-get install -y swig4.0 - - ln -s /usr/bin/swig4.0 /usr/bin/swig - - python --version ; pip --version # For debugging - - pip install virtualenv - - virtualenv venv - - source venv/bin/activate - -#test: -# script: -# - pip install ruff tox # you can also use tox -# - pip install --editable ".[test]" -# - tox -e py,ruff - -build: +# This template uses one generic job with conditional builds +# for the default branch and all other (MR) branches. + +docker-build: + # Use the official docker image. + image: docker:cli + stage: build + services: + - docker:dind tags: - - python3 + - docker-24 + variables: + DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + # All branches are tagged with $DOCKER_IMAGE_NAME (defaults to commit ref slug) + # Default branch is also tagged with `latest` script: - - pip install . - # run the command here - artifacts: - paths: - - build/* - -#pages: -# script: -# - pip install sphinx sphinx-rtd-theme -# - cd doc -# - make html -# - mv build/html/ ../public/ -# artifacts: -# paths: -# - public -# rules: -# - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - -#deploy: -# stage: deploy -# script: echo "Define your deployment script!" -# environment: production + - docker build --pull -t "$DOCKER_IMAGE_NAME" . + - docker push "$DOCKER_IMAGE_NAME" + - | + if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then + docker tag "$DOCKER_IMAGE_NAME" "$CI_REGISTRY_IMAGE:latest" + docker push "$CI_REGISTRY_IMAGE:latest" + fi + # Run this job in a branch where a Dockerfile exists + rules: + - if: $CI_COMMIT_BRANCH + exists: + - Dockerfile From 14ff1e96f78f5ccfc739d4e93306275ec574ad47 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 16 Aug 2024 08:58:06 +0200 Subject: [PATCH 13/14] Change base os path to gitlab --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7f1b649..4d20a6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/hyperk/dependencies2:latest +FROM registry.git.hyperk.org/hyperk/hk-containers/dependencies2:latest RUN curl -LO https://github.com/DIRACGrid/DIRACOS2/releases/latest/download/DIRACOS-Linux-$(uname -m).sh &&\ bash DIRACOS-Linux-$(uname -m).sh &&\ From 77089a8a850d3d7520ce5dc70d5068b82e7088d3 Mon Sep 17 00:00:00 2001 From: Mathieu Guigue Date: Fri, 16 Aug 2024 10:14:56 +0200 Subject: [PATCH 14/14] Add variables --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index de93206..f9ae578 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,3 +36,6 @@ docker-build: - if: $CI_COMMIT_BRANCH exists: - Dockerfile +variables: # not strictly needed, depending on runner configuration + DOCKER_HOST: "tcp://docker:2375" + DOCKER_TLS_CERTDIR: "" \ No newline at end of file