Loading .gitlab-ci.yml +3 −17 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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] Loading .pre-commit-config.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -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 Loading pipeline-templates/build-image.yml 0 → 100644 +105 −0 Original line number Diff line number Diff line # 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 <<ENV BUILD_TAG=${CI_REGISTRY_IMAGE}/build${TARGET+/$TARGET}:pipeline-${CI_PIPELINE_IID} ENV . build.env - | : buildctl build ... opts() { test $# -eq 0 || printf "--opt build-arg:%s" "$@"; } build() { opts | xargs buildctl build \ --frontend dockerfile.v0 \ --local context=. \ --local dockerfile=. \ --output type=image,push=true,name=${BUILD_TAG} \ --opt platform="${PLATFORMS}" \ --opt label:pipeline=${CI_PIPELINE_IID} \ --opt label:commit=${CI_COMMIT_SHORT_SHA} \ ${TARGET+--opt target=$TARGET} } eval "build ${BUILD_ARGS}" artifacts: reports: dotenv: build.env Tag Commit: stage: build image: docker.kodo.org.uk/ci-images/docker-reg:0.2.0 needs: [Build] script: - docker-reg ${BUILD_TAG} retag commit-${CI_COMMIT_SHORT_SHA} Tag Release: stage: deploy image: docker.kodo.org.uk/ci-images/docker-reg:0.2.0 needs: [Build] rules: - if: $RELEASE when: manual script: - docker-reg ${BUILD_TAG} retag ${CI_REGISTRY_IMAGE}${TARGET+/$TARGET}:${RELEASE} - docker-reg ${BUILD_TAG} retag ${CI_REGISTRY_IMAGE}${TARGET+/$TARGET}:latest pipeline-templates/pre-commit.yml 0 → 100644 +13 −0 Original line number Diff line number Diff line 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 Loading
.gitlab-ci.yml +3 −17 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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] Loading
.pre-commit-config.yaml +1 −1 Original line number Diff line number Diff line Loading @@ -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 Loading
pipeline-templates/build-image.yml 0 → 100644 +105 −0 Original line number Diff line number Diff line # 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 <<ENV BUILD_TAG=${CI_REGISTRY_IMAGE}/build${TARGET+/$TARGET}:pipeline-${CI_PIPELINE_IID} ENV . build.env - | : buildctl build ... opts() { test $# -eq 0 || printf "--opt build-arg:%s" "$@"; } build() { opts | xargs buildctl build \ --frontend dockerfile.v0 \ --local context=. \ --local dockerfile=. \ --output type=image,push=true,name=${BUILD_TAG} \ --opt platform="${PLATFORMS}" \ --opt label:pipeline=${CI_PIPELINE_IID} \ --opt label:commit=${CI_COMMIT_SHORT_SHA} \ ${TARGET+--opt target=$TARGET} } eval "build ${BUILD_ARGS}" artifacts: reports: dotenv: build.env Tag Commit: stage: build image: docker.kodo.org.uk/ci-images/docker-reg:0.2.0 needs: [Build] script: - docker-reg ${BUILD_TAG} retag commit-${CI_COMMIT_SHORT_SHA} Tag Release: stage: deploy image: docker.kodo.org.uk/ci-images/docker-reg:0.2.0 needs: [Build] rules: - if: $RELEASE when: manual script: - docker-reg ${BUILD_TAG} retag ${CI_REGISTRY_IMAGE}${TARGET+/$TARGET}:${RELEASE} - docker-reg ${BUILD_TAG} retag ${CI_REGISTRY_IMAGE}${TARGET+/$TARGET}:latest
pipeline-templates/pre-commit.yml 0 → 100644 +13 −0 Original line number Diff line number Diff line 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