From 7b022827a10c6cf5ac16ac0991e5327abeb9ac08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=BCttemann?= Date: Thu, 20 Jun 2024 16:25:44 +0200 Subject: [PATCH 1/2] Remove dependencies to let pre-commit install them --- Dockerfile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index d5f6e51..9991bd2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,4 @@ FROM python:3.12.4-alpine3.20@sha256:a982997504b8ec596f553d78f4de4b961bbdf5254e0177f6e99bb34f4ef16f95 -COPY --from=koalaman/shellcheck:v0.10.0@sha256:2097951f02e735b613f4a34de20c40f937a6c8f18ecb170612c88c34517221fb /bin/shellcheck /usr/bin/ -COPY --from=ghcr.io/gitleaks/gitleaks:v8.18.4@sha256:f44e526acc67786b7476db413edb993ce2d152660d32fb3eb48d9bca06fa83f8 /usr/bin/gitleaks /usr/bin/ # renovate: datasource=repology depName=alpine_3_20/build-base versioning=loose ENV BUILD_BASE_VERSION="0.5-r3" @@ -14,8 +12,6 @@ ENV GIT_VERSION="2.45.2-r0" ENV OPENSSH_KEYGEN_VERSION="9.7_p1-r3" # renovate: datasource=pypi depName=pre-commit versioning=pep440 ENV PRE_COMMIT_VERSION="3.7.1" -# renovate: datasource=rubygems depName=mdl versioning=ruby -ENV MDL_VERSION="0.13.0" RUN mkdir /data /tmp/pre-commit COPY .pre-commit-config.yaml /tmp/pre-commit @@ -23,13 +19,11 @@ COPY .pre-commit-config.yaml /tmp/pre-commit RUN apk add --update --no-cache \ build-base="${BUILD_BASE_VERSION}" \ gcc="${GCC_VERSION}" \ - ruby="${RUBY_VERSION}" \ ruby-dev="${RUBY_VERSION}" \ git="${GIT_VERSION}" \ openssh-keygen="${OPENSSH_KEYGEN_VERSION}" \ && \ pip install --no-cache-dir pre-commit=="${PRE_COMMIT_VERSION}" && \ - gem install --no-document mdl -v "${MDL_VERSION}" && \ git config --global --add safe.directory /data && \ cd /tmp/pre-commit && \ git init --initial-branch main && \ From 3d63abe0298a7f14974e6e19f622fdae918a9dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=BCttemann?= Date: Thu, 20 Jun 2024 16:39:03 +0200 Subject: [PATCH 2/2] Add tests for pre-commit container Run pre-commit on the freshly built container against salt and rc2matrix --- .woodpecker.yaml => .woodpecker/.build.yaml | 12 +++-- .woodpecker/.test.yaml | 56 +++++++++++++++++++++ 2 files changed, 64 insertions(+), 4 deletions(-) rename .woodpecker.yaml => .woodpecker/.build.yaml (83%) create mode 100644 .woodpecker/.test.yaml diff --git a/.woodpecker.yaml b/.woodpecker/.build.yaml similarity index 83% rename from .woodpecker.yaml rename to .woodpecker/.build.yaml index 463d1a5..c06e7d6 100644 --- a/.woodpecker.yaml +++ b/.woodpecker/.build.yaml @@ -2,7 +2,7 @@ when: path: '*Dockerfile*' steps: - build-main: + build main: when: branch: main image: woodpeckerci/plugin-docker-buildx:4.0.0@sha256:9d24b71c37d7a958d79252e608c4d1a04b02f2e74d4e26003b43e0830038bde0 @@ -14,9 +14,11 @@ steps: password: from_secret: gitea_token repo: git.verdigado.com/${CI_REPO,,} - tag: 'latest' + tags: + - 'latest' + - ${CI_COMMIT_SHA} - build-branch: + build branch: when: branch: exclude: ['main'] @@ -29,4 +31,6 @@ steps: password: from_secret: gitea_token repo: git.verdigado.com/${CI_REPO,,} - tag: ${CI_COMMIT_BRANCH} + tags: + - ${CI_COMMIT_BRANCH} + - ${CI_COMMIT_SHA} diff --git a/.woodpecker/.test.yaml b/.woodpecker/.test.yaml new file mode 100644 index 0000000..69c9a51 --- /dev/null +++ b/.woodpecker/.test.yaml @@ -0,0 +1,56 @@ +skip_clone: true +when: + - event: push +depends_on: + - build +variables: + - &image 'git.verdigado.com/verdigado-images/container-pre-commit:${CI_COMMIT_SHA}' +steps: + await-image: + image: alpine + environment: + IMAGE: *image + commands: + - apk add --update --no-cache img + - 'while !(( img pull $IMAGE 2>&1 | grep -q "Error: failed to unmount" )) ; do echo "Awaiting image $IMAGE..."; sleep 3; done' + - echo 'found.' + + clone salt: + image: woodpeckerci/plugin-git + settings: + remote: https://git.verdigado.com/verdigado-Privileged/Salt.git + path: salt + sha: '' + ref: refs/heads/master + branch: master + + pre-commit salt: + image: *image + depends_on: + - await-image + - clone salt + environment: + - SKIP=no-commit-to-branch # Ignore "don't commit to protected branch" check + commands: + - cd salt + - pre-commit run --all-files + + clone rocketchat2matrix: + image: woodpeckerci/plugin-git + settings: + remote: https://git.verdigado.com/NB-Public/rocketchat2matrix.git + path: rocketchat2matrix + sha: '' + ref: refs/heads/main + branch: master + + pre-commit rocketchat2matrix: + image: *image + depends_on: + - await-image + - clone rocketchat2matrix + environment: + - SKIP=no-commit-to-branch # Ignore "don't commit to protected branch" check + commands: + - cd rocketchat2matrix + - pre-commit run --all-files