From f114819f81e510e6faa205338b5b07aacec77a26 Mon Sep 17 00:00:00 2001 From: Adar Nimrod Date: Mon, 23 Nov 2020 10:43:03 +0200 Subject: [PATCH] GitLab CI. --- .gitlab-ci.yml | 50 +++++++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 8 ++++++- README.md | 2 +- exim4/Dockerfile | 4 ++-- 4 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..128c0f0 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,50 @@ +--- +image: adarnimrod/ci-images:docker + +stages: + - test + - build + - run + +pre-commit: + stage: test + image: adarnimrod/ci-images:pre-commit + variables: + XDG_CACHE_HOME: "$CI_PROJECT_DIR/.cache" + # Disabled until https://github.com/pre-commit/pre-commit/issues/1387 is + # resolved. + SKIP: "hadolint,docker-compose" + script: + - pre-commit run --all-files + cache: + paths: + - .cache/ + +build: + stage: build + tags: ["host01.shore.co.il"] + variables: + COMPOSE_DOCKER_CLI_BUILD: "1" + DOCKER_BUILDKIT: "1" + # Fix the permissions because of + # https://gitlab.com/gitlab-org/gitlab-runner/-/issues/1736. + before_script: + - chmod 644 exim4/exim4.conf + script: + - docker-compose build --no-cache --pull + - docker-compose pull --quiet + +run: + stage: run + tags: ["host01.shore.co.il"] + when: manual + script: + - docker-compose up --detach --remove-orphans + # yamllint disable rule:line-length + - | + for i in $(seq 12) + do + docker container inspect --format '{{ .State.Health.Status }}' $(docker-compose ps -q) | grep -v '^healthy$' || break + sleep 10 + done + ! docker container inspect --format '{{ .State.Health.Status }}' $(docker-compose ps -q) | grep -v '^healthy$' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e18404..dee5c99 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,7 @@ repos: rev: v2.3.0 hooks: - id: check-added-large-files + - id: check-executables-have-shebangs - id: check-merge-conflict - id: detect-private-key - id: trailing-whitespace @@ -19,7 +20,7 @@ repos: - id: proselint types: [plain-text] exclude: LICENSE - - repo: https://www.shore.co.il/git/docker-pre-commit + - repo: https://git.shore.co.il/nimrod/docker-pre-commit.git/ rev: v0.3.0 hooks: - id: docker-compose @@ -29,3 +30,8 @@ repos: hooks: - id: detect-secrets exclude: \.diff$ + - repo: https://git.shore.co.il/nimrod/shell-pre-commit.git + rev: v0.6.0 + hooks: + - id: shell-lint + - id: shellcheck diff --git a/README.md b/README.md index e967279..090afdc 100644 --- a/README.md +++ b/README.md @@ -16,4 +16,4 @@ This software is licensed under the MIT license (see `LICENSE.txt`). Nimrod Adar, [contact me](mailto:nimrod@shore.co.il) or visit my [website]( https://www.shore.co.il/). Patches are welcome via [`git send-email`]( http://git-scm.com/book/en/v2/Git-Commands-Email). The repository is located -at: . +at: . diff --git a/exim4/Dockerfile b/exim4/Dockerfile index f18dd2f..c021969 100644 --- a/exim4/Dockerfile +++ b/exim4/Dockerfile @@ -25,8 +25,8 @@ RUN apt-get update && \ rm -rf /tmp/* /var/tmp/* /var/lib/apt/lists/* /var/cache/apt/archives/* COPY --chown=root:root entrypoint /usr/local/bin/ COPY --chown=Debian-exim:Debian-exim aliases /etc/aliases -COPY exim4.conf /etc/exim4/exim4.conf -RUN exim4 -bV +COPY --chown=root:root exim4.conf /etc/exim4/exim4.conf +RUN ls -l /etc/exim4/exim4.conf && exim4 -bV #USER Debian-exim WORKDIR /var/spool/exim4 ENTRYPOINT ["entrypoint"] -- GitLab