From 4bfc057454302ba14f8e0d5593bcbb1c4493e4c1 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Sun, 21 Feb 2021 23:38:55 +0100 Subject: [PATCH 01/25] Use prebuilt docker images in the CI --- .gitlab-ci.yml | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 97110ecd..388cc49a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,50 +10,23 @@ variables: # Debian Buster py37-django22: stage: test - image: debian:buster-backports - before_script: - - > - apt-get update && - apt-get install --no-install-recommends -t buster-backports -y - python3-django python3-django-crispy-forms - python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache - python3-bs4 python3-setuptools tox texlive-xetex + image: otthorn/nk20_ci_37 script: tox -e py37-django22 # Ubuntu 20.04 py38-django22: stage: test + image: otthorn/nk20_ci_37 image: ubuntu:20.04 - before_script: - # Fix tzdata prompt - - ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime && echo Europe/Paris > /etc/timezone - - > - apt-get update && - apt-get install --no-install-recommends -y - python3-django python3-django-crispy-forms - python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache - python3-bs4 python3-setuptools tox texlive-xetex script: tox -e py38-django22 # Debian Bullseye py39-django22: stage: test - image: debian:bullseye - before_script: - - > - apt-get update && - apt-get install --no-install-recommends -y - python3-django python3-django-crispy-forms - python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache - python3-bs4 python3-setuptools tox texlive-xetex + image: otthorn/nk20_ci_37 script: tox -e py39-django22 +# Tox linter linters: stage: quality-assurance image: debian:buster-backports From fd11d96d953ce1feab37479443b7885df15b4d6e Mon Sep 17 00:00:00 2001 From: Otthorn Date: Sun, 21 Feb 2021 23:40:03 +0100 Subject: [PATCH 02/25] Add custom pre-built docker images to be used for the CI --- docker_ci/Dockerfile.37 | 18 ++++++++++++++++++ docker_ci/Dockerfile.38 | 22 ++++++++++++++++++++++ docker_ci/Dockerfile.39 | 18 ++++++++++++++++++ docker_ci/README.md | 21 +++++++++++++++++++++ docker_ci/TODO.md | 16 ++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 docker_ci/Dockerfile.37 create mode 100644 docker_ci/Dockerfile.38 create mode 100644 docker_ci/Dockerfile.39 create mode 100644 docker_ci/README.md create mode 100644 docker_ci/TODO.md diff --git a/docker_ci/Dockerfile.37 b/docker_ci/Dockerfile.37 new file mode 100644 index 00000000..a835c5bd --- /dev/null +++ b/docker_ci/Dockerfile.37 @@ -0,0 +1,18 @@ +FROM debian:buster-backports + +LABEL maintainer="otthorn@crans.org" +LABEL description="Debian Buster backports image with django and tox \ +installed for testing purposes" + +RUN apt-get update \ + && apt-get install --no-install-recommends -t buster-backports -y \ + python3-django python3-django-crispy-forms \ + python3-django-extensions python3-django-filters \ + python3-django-polymorphic \ + python3-djangorestframework python3-django-oauth-toolkit \ + python3-psycopg2 python3-pil \ + python3-babel python3-lockfile python3-pip python3-phonenumbers \ + python3-memcache \ + python3-bs4 python3-setuptools tox texlive-xetex \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* diff --git a/docker_ci/Dockerfile.38 b/docker_ci/Dockerfile.38 new file mode 100644 index 00000000..ea77c939 --- /dev/null +++ b/docker_ci/Dockerfile.38 @@ -0,0 +1,22 @@ +FROM ubuntu:20.04 + +LABEL maintainer="otthorn@crans.org" +LABEL description="Ubuntu 20.04 image with django and tox \ +installed for testing purposes" + +# fix tzdata prompt +RUN ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime && echo Europe/Paris > /etc/timezone + +RUN apt-get update \ + && apt-get install --no-install-recommends -y \ + python3-django python3-django-crispy-forms \ + python3-django-extensions python3-django-filters \ + python3-django-polymorphic \ + python3-djangorestframework python3-django-oauth-toolkit \ + python3-psycopg2 python3-pil \ + python3-babel python3-lockfile python3-pip python3-phonenumbers \ + python3-memcache \ + python3-bs4 python3-setuptools tox texlive-xetex \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + diff --git a/docker_ci/Dockerfile.39 b/docker_ci/Dockerfile.39 new file mode 100644 index 00000000..24c7bd84 --- /dev/null +++ b/docker_ci/Dockerfile.39 @@ -0,0 +1,18 @@ +FROM debian:bullseye + +LABEL maintainer="otthorn@crans.org" +LABEL description="Debian Bulleye image with django and tox \ +installed for testing purposes" + +RUN apt-get update \ + && apt-get install --no-install-recommends -y \ + python3-django python3-django-crispy-forms \ + python3-django-extensions python3-django-filters \ + python3-django-polymorphic \ + python3-djangorestframework python3-django-oauth-toolkit \ + python3-psycopg2 python3-pil \ + python3-babel python3-lockfile python3-pip python3-phonenumbers \ + python3-memcache \ + python3-bs4 python3-setuptools tox texlive-xetex \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* diff --git a/docker_ci/README.md b/docker_ci/README.md new file mode 100644 index 00000000..9f52ef17 --- /dev/null +++ b/docker_ci/README.md @@ -0,0 +1,21 @@ +# Docker CI + +Ce dossier contient les images docker à construire pour la CI. L'idée est +d'avoir une image pré-construire, au dessus laquel il y a besoin de faire +tourner uniquement les commandes qui nous intéresse. Cela permet notamment de +réduire drastiquement le temps que nécessite chaque test car seul la dernière +couche (layer) de l'image a besoin d'etre éxécuter. + +## Build les images + +Pour build les images il suffit de lancer les commandes suivantes + +``` +cd docker_ci/ +docker build -t nk20_ci_37 -f Dockerfile.37 . +docker build -t nk20_ci_38 -f Dockerfile.38 . +docker build -t nk20_ci_39 -f Dockerfile.39 . +``` + +Elles sont acutellement build et disponible sur dockerhub +https://hub.docker.com/otthorn/nk20_ci_37 diff --git a/docker_ci/TODO.md b/docker_ci/TODO.md new file mode 100644 index 00000000..623f563e --- /dev/null +++ b/docker_ci/TODO.md @@ -0,0 +1,16 @@ +## TODO +- Créer les images +- Build les images +- Push les images sur la docker registery de mon choix (docker hub + probablement) +- Tester la CI avec les images pré construite pour voir tout fonctionnne comme + avant +- Créer une CI pour les images docker elle meme (hadolin) +- Créer une CI pour les images docker de la note +- Créer une CI pour ansible +- Créer la MR +- Demande de merge de la MR + +## Optionnel +- build automatique des images par la CI +- utiliser le gitlab registery local une fois qu'il sera activé From 0941ee954dda3e46f802c4554feb6705a70d20bb Mon Sep 17 00:00:00 2001 From: Otthorn Date: Sun, 21 Feb 2021 23:46:20 +0100 Subject: [PATCH 03/25] copy paste is a bad practice --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 388cc49a..cd4d8abf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,14 +16,14 @@ py37-django22: # Ubuntu 20.04 py38-django22: stage: test - image: otthorn/nk20_ci_37 + image: otthorn/nk20_ci_38 image: ubuntu:20.04 script: tox -e py38-django22 # Debian Bullseye py39-django22: stage: test - image: otthorn/nk20_ci_37 + image: otthorn/nk20_ci_39 script: tox -e py39-django22 # Tox linter From d7a537b6b513455df797320732e3004c3f1364f9 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Sun, 21 Feb 2021 23:52:42 +0100 Subject: [PATCH 04/25] fix typo (added image: twice) --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cd4d8abf..d4ca3cd6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,6 @@ py37-django22: py38-django22: stage: test image: otthorn/nk20_ci_38 - image: ubuntu:20.04 script: tox -e py38-django22 # Debian Bullseye From d803ab5ec298c6bb988d2217215f4ff1aad7c56f Mon Sep 17 00:00:00 2001 From: Otthorn Date: Mon, 22 Feb 2021 00:17:49 +0100 Subject: [PATCH 05/25] Add docker image for tox linting to be used in CI --- docker_ci/Dockerfile.tox | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 docker_ci/Dockerfile.tox diff --git a/docker_ci/Dockerfile.tox b/docker_ci/Dockerfile.tox new file mode 100644 index 00000000..ea7f7685 --- /dev/null +++ b/docker_ci/Dockerfile.tox @@ -0,0 +1,8 @@ +FROM alpine:3.13 + +LABEL maintainer="otthorn@crans.org" +LABEL description="Alpine image with tox \ +installed for linting purposes" + +RUN apk --no-cache add py3-pip=20.3.4-r0 +RUN pip install --no-cache-dir tox==3.22.0 From a23093851f3f415676f9ea70fce93ff84ad2c169 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 22:57:33 +0100 Subject: [PATCH 06/25] Add skip list for ansible-lint --- .ansible-lint | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .ansible-lint diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 00000000..ac82f8cb --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,3 @@ +skip_list: + - command-instead-of-shell # Use shell only when shell functionality is required + - experimental # all rules tagged as experimental From b6c0f9758d86817552b25e3076c56f0e8e488744 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:02:29 +0100 Subject: [PATCH 07/25] Add docker image for ansible lint to be used in CI --- docker_ci/Dockerfile.ansiblelint | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docker_ci/Dockerfile.ansiblelint diff --git a/docker_ci/Dockerfile.ansiblelint b/docker_ci/Dockerfile.ansiblelint new file mode 100644 index 00000000..2ae87199 --- /dev/null +++ b/docker_ci/Dockerfile.ansiblelint @@ -0,0 +1,10 @@ +FROM python:3.9-alpine + +LABEL maintainer="otthorn@crans.org" +LABEL description="Alpine image with ansible-lint and yamllint \ +installed for linting purposes" + +RUN apk add --no-cache gcc musl-dev python3-dev libffi-dev openssl-dev cargo +RUN pip install --no-cache-dir "yamllint>=1.26.0,<2.0" +RUN pip install --no-cache-dir "ansible-lint==5.0.0" +RUN pip install --no-cache-dir "ansible>=2.10,<2.11" From 08df5fcccd0725c26a53649a113706f351c86c3e Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:02:51 +0100 Subject: [PATCH 08/25] Add ansible linting to the CI --- .gitlab-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4ca3cd6..79c4b5f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,6 +36,12 @@ linters: # Be nice to new contributors, but please use `tox` allow_failure: true +# Ansible linter +ansible-linter: + stage: quality-assurance + image: otthorn/nk20_ci_ansiblelint + script: ansible-lint ansible/ + # Compile documentation documentation: stage: docs From a06f3555598f55e32c8df8428d816c7011294c24 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:10:30 +0100 Subject: [PATCH 09/25] Add hadolint configuration file --- .hadolint | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .hadolint diff --git a/.hadolint b/.hadolint new file mode 100644 index 00000000..ee87b47e --- /dev/null +++ b/.hadolint @@ -0,0 +1,4 @@ +ignored: + - DL3008 # Do not force to pin version in apt (Debian) + - DL3013 # Do not force to pin version in pip (PyPI) + - DL3018 # Do not force to pin version in apk (Alpine) From fcc4121225ee5c5eb64543ccd077084fac6aad9c Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:14:00 +0100 Subject: [PATCH 10/25] Add CI docker linter for nk20 Dockerfile --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79c4b5f7..6e80b2e8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,6 +42,13 @@ ansible-linter: image: otthorn/nk20_ci_ansiblelint script: ansible-lint ansible/ +# Docker linter +docker-linter: + stage: quality-assurance + image: hadolint/hadolint + script: + - hadolint Dockerfile + # Compile documentation documentation: stage: docs From c13172d3ff1a3001dfa7df40e303620dd256e4d7 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:14:35 +0100 Subject: [PATCH 11/25] Add CI docker linter for CI Dockerfiles --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6e80b2e8..493396c0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,6 +48,7 @@ docker-linter: image: hadolint/hadolint script: - hadolint Dockerfile + - hadolint docker_ci/Dockerfile.* # Compile documentation documentation: From 1129815ca3b819684d0e5b477bd215beea3eda01 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:22:51 +0100 Subject: [PATCH 12/25] please use the configuration I have written for hadolint --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 493396c0..b83d986b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,8 +47,8 @@ docker-linter: stage: quality-assurance image: hadolint/hadolint script: - - hadolint Dockerfile - - hadolint docker_ci/Dockerfile.* + - hadolint -c .hadolint Dockerfile + - hadolint -c .hadolint docker_ci/Dockerfile.* # Compile documentation documentation: From 3e3e61d23fb8d2a96ccd9eceb4cb6f2ab328b069 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Sun, 21 Feb 2021 23:38:55 +0100 Subject: [PATCH 13/25] Use prebuilt docker images in the CI --- .gitlab-ci.yml | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 97110ecd..388cc49a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,50 +10,23 @@ variables: # Debian Buster py37-django22: stage: test - image: debian:buster-backports - before_script: - - > - apt-get update && - apt-get install --no-install-recommends -t buster-backports -y - python3-django python3-django-crispy-forms - python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache - python3-bs4 python3-setuptools tox texlive-xetex + image: otthorn/nk20_ci_37 script: tox -e py37-django22 # Ubuntu 20.04 py38-django22: stage: test + image: otthorn/nk20_ci_37 image: ubuntu:20.04 - before_script: - # Fix tzdata prompt - - ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime && echo Europe/Paris > /etc/timezone - - > - apt-get update && - apt-get install --no-install-recommends -y - python3-django python3-django-crispy-forms - python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache - python3-bs4 python3-setuptools tox texlive-xetex script: tox -e py38-django22 # Debian Bullseye py39-django22: stage: test - image: debian:bullseye - before_script: - - > - apt-get update && - apt-get install --no-install-recommends -y - python3-django python3-django-crispy-forms - python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache - python3-bs4 python3-setuptools tox texlive-xetex + image: otthorn/nk20_ci_37 script: tox -e py39-django22 +# Tox linter linters: stage: quality-assurance image: debian:buster-backports From 9b50ba722c47378aa23520712686399186962e19 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Sun, 21 Feb 2021 23:40:03 +0100 Subject: [PATCH 14/25] Add custom pre-built docker images to be used for the CI --- docker_ci/Dockerfile.37 | 18 ++++++++++++++++++ docker_ci/Dockerfile.38 | 22 ++++++++++++++++++++++ docker_ci/Dockerfile.39 | 18 ++++++++++++++++++ docker_ci/README.md | 21 +++++++++++++++++++++ docker_ci/TODO.md | 16 ++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 docker_ci/Dockerfile.37 create mode 100644 docker_ci/Dockerfile.38 create mode 100644 docker_ci/Dockerfile.39 create mode 100644 docker_ci/README.md create mode 100644 docker_ci/TODO.md diff --git a/docker_ci/Dockerfile.37 b/docker_ci/Dockerfile.37 new file mode 100644 index 00000000..a835c5bd --- /dev/null +++ b/docker_ci/Dockerfile.37 @@ -0,0 +1,18 @@ +FROM debian:buster-backports + +LABEL maintainer="otthorn@crans.org" +LABEL description="Debian Buster backports image with django and tox \ +installed for testing purposes" + +RUN apt-get update \ + && apt-get install --no-install-recommends -t buster-backports -y \ + python3-django python3-django-crispy-forms \ + python3-django-extensions python3-django-filters \ + python3-django-polymorphic \ + python3-djangorestframework python3-django-oauth-toolkit \ + python3-psycopg2 python3-pil \ + python3-babel python3-lockfile python3-pip python3-phonenumbers \ + python3-memcache \ + python3-bs4 python3-setuptools tox texlive-xetex \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* diff --git a/docker_ci/Dockerfile.38 b/docker_ci/Dockerfile.38 new file mode 100644 index 00000000..ea77c939 --- /dev/null +++ b/docker_ci/Dockerfile.38 @@ -0,0 +1,22 @@ +FROM ubuntu:20.04 + +LABEL maintainer="otthorn@crans.org" +LABEL description="Ubuntu 20.04 image with django and tox \ +installed for testing purposes" + +# fix tzdata prompt +RUN ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime && echo Europe/Paris > /etc/timezone + +RUN apt-get update \ + && apt-get install --no-install-recommends -y \ + python3-django python3-django-crispy-forms \ + python3-django-extensions python3-django-filters \ + python3-django-polymorphic \ + python3-djangorestframework python3-django-oauth-toolkit \ + python3-psycopg2 python3-pil \ + python3-babel python3-lockfile python3-pip python3-phonenumbers \ + python3-memcache \ + python3-bs4 python3-setuptools tox texlive-xetex \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + diff --git a/docker_ci/Dockerfile.39 b/docker_ci/Dockerfile.39 new file mode 100644 index 00000000..24c7bd84 --- /dev/null +++ b/docker_ci/Dockerfile.39 @@ -0,0 +1,18 @@ +FROM debian:bullseye + +LABEL maintainer="otthorn@crans.org" +LABEL description="Debian Bulleye image with django and tox \ +installed for testing purposes" + +RUN apt-get update \ + && apt-get install --no-install-recommends -y \ + python3-django python3-django-crispy-forms \ + python3-django-extensions python3-django-filters \ + python3-django-polymorphic \ + python3-djangorestframework python3-django-oauth-toolkit \ + python3-psycopg2 python3-pil \ + python3-babel python3-lockfile python3-pip python3-phonenumbers \ + python3-memcache \ + python3-bs4 python3-setuptools tox texlive-xetex \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* diff --git a/docker_ci/README.md b/docker_ci/README.md new file mode 100644 index 00000000..9f52ef17 --- /dev/null +++ b/docker_ci/README.md @@ -0,0 +1,21 @@ +# Docker CI + +Ce dossier contient les images docker à construire pour la CI. L'idée est +d'avoir une image pré-construire, au dessus laquel il y a besoin de faire +tourner uniquement les commandes qui nous intéresse. Cela permet notamment de +réduire drastiquement le temps que nécessite chaque test car seul la dernière +couche (layer) de l'image a besoin d'etre éxécuter. + +## Build les images + +Pour build les images il suffit de lancer les commandes suivantes + +``` +cd docker_ci/ +docker build -t nk20_ci_37 -f Dockerfile.37 . +docker build -t nk20_ci_38 -f Dockerfile.38 . +docker build -t nk20_ci_39 -f Dockerfile.39 . +``` + +Elles sont acutellement build et disponible sur dockerhub +https://hub.docker.com/otthorn/nk20_ci_37 diff --git a/docker_ci/TODO.md b/docker_ci/TODO.md new file mode 100644 index 00000000..623f563e --- /dev/null +++ b/docker_ci/TODO.md @@ -0,0 +1,16 @@ +## TODO +- Créer les images +- Build les images +- Push les images sur la docker registery de mon choix (docker hub + probablement) +- Tester la CI avec les images pré construite pour voir tout fonctionnne comme + avant +- Créer une CI pour les images docker elle meme (hadolin) +- Créer une CI pour les images docker de la note +- Créer une CI pour ansible +- Créer la MR +- Demande de merge de la MR + +## Optionnel +- build automatique des images par la CI +- utiliser le gitlab registery local une fois qu'il sera activé From 28932f316bb12feeb61b055650775fd56f9ae965 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Sun, 21 Feb 2021 23:46:20 +0100 Subject: [PATCH 15/25] copy paste is a bad practice --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 388cc49a..cd4d8abf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,14 +16,14 @@ py37-django22: # Ubuntu 20.04 py38-django22: stage: test - image: otthorn/nk20_ci_37 + image: otthorn/nk20_ci_38 image: ubuntu:20.04 script: tox -e py38-django22 # Debian Bullseye py39-django22: stage: test - image: otthorn/nk20_ci_37 + image: otthorn/nk20_ci_39 script: tox -e py39-django22 # Tox linter From ed06901fae86485daa978a95f33bc7cd72810630 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Sun, 21 Feb 2021 23:52:42 +0100 Subject: [PATCH 16/25] fix typo (added image: twice) --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cd4d8abf..d4ca3cd6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,6 @@ py37-django22: py38-django22: stage: test image: otthorn/nk20_ci_38 - image: ubuntu:20.04 script: tox -e py38-django22 # Debian Bullseye From 0636d8428686544537d3fe09dbd6a503cb25ba87 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Mon, 22 Feb 2021 00:17:49 +0100 Subject: [PATCH 17/25] Add docker image for tox linting to be used in CI --- docker_ci/Dockerfile.tox | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 docker_ci/Dockerfile.tox diff --git a/docker_ci/Dockerfile.tox b/docker_ci/Dockerfile.tox new file mode 100644 index 00000000..ea7f7685 --- /dev/null +++ b/docker_ci/Dockerfile.tox @@ -0,0 +1,8 @@ +FROM alpine:3.13 + +LABEL maintainer="otthorn@crans.org" +LABEL description="Alpine image with tox \ +installed for linting purposes" + +RUN apk --no-cache add py3-pip=20.3.4-r0 +RUN pip install --no-cache-dir tox==3.22.0 From c57f81b920175603a6b09955e72c47324aa6ee07 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 22:57:33 +0100 Subject: [PATCH 18/25] Add skip list for ansible-lint --- .ansible-lint | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .ansible-lint diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 00000000..ac82f8cb --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,3 @@ +skip_list: + - command-instead-of-shell # Use shell only when shell functionality is required + - experimental # all rules tagged as experimental From 9f3323c73e54d7d9d48bdbaabf45feb423706216 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:02:29 +0100 Subject: [PATCH 19/25] Add docker image for ansible lint to be used in CI --- docker_ci/Dockerfile.ansiblelint | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docker_ci/Dockerfile.ansiblelint diff --git a/docker_ci/Dockerfile.ansiblelint b/docker_ci/Dockerfile.ansiblelint new file mode 100644 index 00000000..2ae87199 --- /dev/null +++ b/docker_ci/Dockerfile.ansiblelint @@ -0,0 +1,10 @@ +FROM python:3.9-alpine + +LABEL maintainer="otthorn@crans.org" +LABEL description="Alpine image with ansible-lint and yamllint \ +installed for linting purposes" + +RUN apk add --no-cache gcc musl-dev python3-dev libffi-dev openssl-dev cargo +RUN pip install --no-cache-dir "yamllint>=1.26.0,<2.0" +RUN pip install --no-cache-dir "ansible-lint==5.0.0" +RUN pip install --no-cache-dir "ansible>=2.10,<2.11" From 893d87a9e136d84fb41f9cf0c9cbfc8e36cf97c9 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:02:51 +0100 Subject: [PATCH 20/25] Add ansible linting to the CI --- .gitlab-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4ca3cd6..79c4b5f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,6 +36,12 @@ linters: # Be nice to new contributors, but please use `tox` allow_failure: true +# Ansible linter +ansible-linter: + stage: quality-assurance + image: otthorn/nk20_ci_ansiblelint + script: ansible-lint ansible/ + # Compile documentation documentation: stage: docs From f6b711bb1b816eb00e4be8699746e526a54b1e7d Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:10:30 +0100 Subject: [PATCH 21/25] Add hadolint configuration file --- .hadolint | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .hadolint diff --git a/.hadolint b/.hadolint new file mode 100644 index 00000000..ee87b47e --- /dev/null +++ b/.hadolint @@ -0,0 +1,4 @@ +ignored: + - DL3008 # Do not force to pin version in apt (Debian) + - DL3013 # Do not force to pin version in pip (PyPI) + - DL3018 # Do not force to pin version in apk (Alpine) From d20a1038a81fdb8bdfef3f6904e238b3f8ed8401 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:14:00 +0100 Subject: [PATCH 22/25] Add CI docker linter for nk20 Dockerfile --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79c4b5f7..6e80b2e8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,6 +42,13 @@ ansible-linter: image: otthorn/nk20_ci_ansiblelint script: ansible-lint ansible/ +# Docker linter +docker-linter: + stage: quality-assurance + image: hadolint/hadolint + script: + - hadolint Dockerfile + # Compile documentation documentation: stage: docs From 2e49c9ffbdedd9a2c7b20b3495d8c2d5b0ba9fe0 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:14:35 +0100 Subject: [PATCH 23/25] Add CI docker linter for CI Dockerfiles --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6e80b2e8..493396c0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,6 +48,7 @@ docker-linter: image: hadolint/hadolint script: - hadolint Dockerfile + - hadolint docker_ci/Dockerfile.* # Compile documentation documentation: From e74ff54468fe386ce74e5b6f69dfd3e80b9031bc Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:22:51 +0100 Subject: [PATCH 24/25] please use the configuration I have written for hadolint --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 493396c0..b83d986b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,8 +47,8 @@ docker-linter: stage: quality-assurance image: hadolint/hadolint script: - - hadolint Dockerfile - - hadolint docker_ci/Dockerfile.* + - hadolint -c .hadolint Dockerfile + - hadolint -c .hadolint docker_ci/Dockerfile.* # Compile documentation documentation: From 3eed93e346ed8435ef53c9d8ba59212896936a90 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Tue, 23 Feb 2021 23:38:54 +0100 Subject: [PATCH 25/25] Remove unused file --- docker_ci/TODO.md | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 docker_ci/TODO.md diff --git a/docker_ci/TODO.md b/docker_ci/TODO.md deleted file mode 100644 index 623f563e..00000000 --- a/docker_ci/TODO.md +++ /dev/null @@ -1,16 +0,0 @@ -## TODO -- Créer les images -- Build les images -- Push les images sur la docker registery de mon choix (docker hub - probablement) -- Tester la CI avec les images pré construite pour voir tout fonctionnne comme - avant -- Créer une CI pour les images docker elle meme (hadolin) -- Créer une CI pour les images docker de la note -- Créer une CI pour ansible -- Créer la MR -- Demande de merge de la MR - -## Optionnel -- build automatique des images par la CI -- utiliser le gitlab registery local une fois qu'il sera activé