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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 97110ecd..b83d986b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,50 +10,22 @@ 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: 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 + image: otthorn/nk20_ci_38 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_39 script: tox -e py39-django22 +# Tox linter linters: stage: quality-assurance image: debian:buster-backports @@ -64,6 +36,20 @@ 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/ + +# Docker linter +docker-linter: + stage: quality-assurance + image: hadolint/hadolint + script: + - hadolint -c .hadolint Dockerfile + - hadolint -c .hadolint docker_ci/Dockerfile.* + # Compile documentation documentation: stage: docs 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) 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/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" 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 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