From 467dde1970e6e9b44cc5d7335e16e1abb4583a85 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Wed, 12 Oct 2022 02:44:12 +0100 Subject: [PATCH 1/3] Add child pipeline template for Dockerimage builds --- pipeline-templates/build-image.yml | 105 +++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 pipeline-templates/build-image.yml diff --git a/pipeline-templates/build-image.yml b/pipeline-templates/build-image.yml new file mode 100644 index 0000000..b576f9d --- /dev/null +++ b/pipeline-templates/build-image.yml @@ -0,0 +1,105 @@ +# A child pipeline for building and tagging Docker images +# +# Usage +# ----- +# +# Include this file from a trigger keyword in a job. +# +# jobspec: +# rules: +# - Dockerfile +# - entrypoint.sh +# - src/* +# trigger: +# project: dom/project-templates +# ref: main +# file: pipeline-templates/build-image.yml +# strategy: depend +# +# Multiple images can be built by combining with the "parallel.matrix" keyword. +# In this case the TARGET variable can be set to select both the target +# stage in the Dockerfile, as well as the output repository name. +# +# jobspec: +# parallel: +# matrix: +# - TARGET: [first-image, second-image] +# trigger: +# project: dom/project-templates +# ref: main +# file: pipeline-templates/build-image.yml +# strategy: depend +# +# +# Variables +# --------- +# +# RELEASE: +# Set to a release version string to tag the built images as releases +# +# TARGET: +# The name of a stage from *Dockerfile* to produce as a build image, which +# will also be included in the repo name of the image +# (default: unused) +# +# PLATFORMS: +# A comma separated list of Docker/OCI platforms to build images for +# (default: linux/amd64, linux/arm64) + + +variables: + PLATFORMS: + value: linux/amd64,linux/arm64 + description: Docker/OCI platform specifiers for built images to target; + comma separated + + +Build: + stage: build + image: docker.kodo.org.uk/ci-images/buildkit/buildctl:build-38 + tags: [buildkit] + script: + - | + tee build.env < Date: Wed, 12 Oct 2022 19:31:36 +0100 Subject: [PATCH 2/3] Add pre-commit pipeline template --- .gitlab-ci.yml | 20 +++----------------- pipeline-templates/pre-commit.yml | 13 +++++++++++++ 2 files changed, 16 insertions(+), 17 deletions(-) create mode 100644 pipeline-templates/pre-commit.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9af3cf9..759e990 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,6 +11,9 @@ workflow: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH +include: +- local: pipeline-templates/pre-commit.yml + .python: image: python:3.9 @@ -25,23 +28,6 @@ workflow: - pip install "pip>=21.3" -Quality Gate: - stage: .pre - image: docker.kodo.org.uk/ci-images/pre-commit:latest - variables: - PRE_COMMIT_HOME: $CI_PROJECT_DIR/cache/pre-commit - cache: - key: $CI_JOB_IMAGE - paths: [cache] - rules: - - if: $CI_PIPELINE_SOURCE == "push" - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - script: - - source .gitlab-ci.pre-commit-run.bash - - pre_commit_run --hook-stage=commit - - pre_commit_run --hook-stage=push - - Build Package: stage: build extends: [.python] diff --git a/pipeline-templates/pre-commit.yml b/pipeline-templates/pre-commit.yml new file mode 100644 index 0000000..f30ff2b --- /dev/null +++ b/pipeline-templates/pre-commit.yml @@ -0,0 +1,13 @@ +Push Checks: + stage: .pre + image: docker.kodo.org.uk/ci-images/pre-commit:2.20.0 + rules: + - if: $CI_PIPELINE_SOURCE == "push" + variables: + PRE_COMMIT_HOME: $CI_PROJECT_DIR/cache/pre-commit + cache: + key: $CI_JOB_IMAGE + paths: [cache] + script: + - pre-commit-run --hook-stage=commit + - pre-commit-run --hook-stage=push -- GitLab From 1c34df4f8ef840dbdab90b9ea2ec4e095d5d7275 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Fri, 14 Oct 2022 01:28:16 +0100 Subject: [PATCH 3/3] Bump pre-commit hooks --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4d4948d..6652cc5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,7 +35,7 @@ repos: - id: gitlint - repo: https://code.kodo.org.uk/dom/pre-commit-hooks - rev: v0.6 + rev: v0.6.1 hooks: - id: check-executable-modes - id: check-for-squash -- GitLab