From 64c3f1fa9c79dd21689cb9b0bbe47e8e78ee05af 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] Add tests for pre-commit container Run pre-commit on the freshly built container against salt and rc2matrix --- .woodpecker.yaml => .woodpecker/.build.yaml | 23 +++++---- .woodpecker/.test.yaml | 56 +++++++++++++++++++++ 2 files changed, 69 insertions(+), 10 deletions(-) rename .woodpecker.yaml => .woodpecker/.build.yaml (72%) create mode 100644 .woodpecker/.test.yaml diff --git a/.woodpecker.yaml b/.woodpecker/.build.yaml similarity index 72% rename from .woodpecker.yaml rename to .woodpecker/.build.yaml index 463d1a5..f59d616 100644 --- a/.woodpecker.yaml +++ b/.woodpecker/.build.yaml @@ -1,10 +1,8 @@ -when: - path: '*Dockerfile*' - steps: - build-main: + build main: when: - branch: main + - event: push + branch: main image: woodpeckerci/plugin-docker-buildx:4.0.0@sha256:9d24b71c37d7a958d79252e608c4d1a04b02f2e74d4e26003b43e0830038bde0 pull: true settings: @@ -14,12 +12,15 @@ 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'] + - event: push + branch: + exclude: ['main'] image: woodpeckerci/plugin-docker-buildx:4.0.0@sha256:9d24b71c37d7a958d79252e608c4d1a04b02f2e74d4e26003b43e0830038bde0 pull: true settings: @@ -29,4 +30,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