From 7501a018fda93772783fe7a783d39b1b1ff24e6f Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 30 Sep 2024 16:49:11 -0400 Subject: [PATCH] Switch to using webhook_bridge instead of lighthouse for triggering the CI. --- .lighthouse/triggers.yaml | 32 ---------- .../pipeline-build-hash.yaml | 38 +++++------ .../pipeline-format.yaml | 64 +++++++++---------- .../pipeline-rust-clippy.yaml | 49 +++++++------- .../pipeline-rust-test.yaml | 51 +++++++-------- .webhook_bridge/webhook_bridge.toml | 25 ++++++++ 6 files changed, 127 insertions(+), 132 deletions(-) delete mode 100644 .lighthouse/triggers.yaml rename .lighthouse/pipeline-build-natter.yaml => .webhook_bridge/pipeline-build-hash.yaml (86%) rename {.lighthouse => .webhook_bridge}/pipeline-format.yaml (87%) rename {.lighthouse => .webhook_bridge}/pipeline-rust-clippy.yaml (87%) rename {.lighthouse => .webhook_bridge}/pipeline-rust-test.yaml (86%) create mode 100644 .webhook_bridge/webhook_bridge.toml diff --git a/.lighthouse/triggers.yaml b/.lighthouse/triggers.yaml deleted file mode 100644 index eeb89d1..0000000 --- a/.lighthouse/triggers.yaml +++ /dev/null @@ -1,32 +0,0 @@ -apiVersion: config.lighthouse.jenkins-x.io/v1alpha1 -kind: TriggerConfig -spec: - postsubmits: - - name: build-natter - source: "pipeline-build-natter.yaml" - # Override https-based url from lighthouse events. - clone_uri: "git@code.fizz.buzz:talexander/natter.git" - branches: - - ^main$ - - ^master$ - - name: rust-test - source: "pipeline-rust-test.yaml" - # Override https-based url from lighthouse events. - clone_uri: "git@code.fizz.buzz:talexander/natter.git" - skip_branches: - # We already run on every commit, so running when the semver tags get pushed is causing needless double-processing. - - "^v[0-9]+\\.[0-9]+\\.[0-9]+$" - - name: rust-clippy - source: "pipeline-rust-clippy.yaml" - # Override https-based url from lighthouse events. - clone_uri: "git@code.fizz.buzz:talexander/natter.git" - skip_branches: - # We already run on every commit, so running when the semver tags get pushed is causing needless double-processing. - - "^v[0-9]+\\.[0-9]+\\.[0-9]+$" - - name: format - source: "pipeline-format.yaml" - # Override https-based url from lighthouse events. - clone_uri: "git@code.fizz.buzz:talexander/natter.git" - skip_branches: - # We already run on every commit, so running when the semver tags get pushed is causing needless double-processing. - - "^v[0-9]+\\.[0-9]+\\.[0-9]+$" diff --git a/.lighthouse/pipeline-build-natter.yaml b/.webhook_bridge/pipeline-build-hash.yaml similarity index 86% rename from .lighthouse/pipeline-build-natter.yaml rename to .webhook_bridge/pipeline-build-hash.yaml index 05ce23d..218d8c3 100644 --- a/.lighthouse/pipeline-build-natter.yaml +++ b/.webhook_bridge/pipeline-build-hash.yaml @@ -1,17 +1,22 @@ -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: PipelineRun metadata: - name: build-natter + name: build spec: + timeouts: + pipeline: "2h0m0s" + tasks: "1h0m0s" + finally: "0h30m0s" + taskRunTemplate: + serviceAccountName: build-bot pipelineSpec: - timeouts: - pipeline: "2h0m0s" - tasks: "1h0m0s" - finally: "0h30m0s" params: - name: image-name description: The name for the built image type: string + - name: target-name + description: The dockerfile target to build + type: string - name: path-to-image-context description: The path to the build context type: string @@ -24,13 +29,11 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo value: task/gitea-set-status/0.1/gitea-set-status.yaml - runAfter: - - fetch-repository params: - name: CONTEXT value: "$(params.JOB_NAME)" @@ -51,7 +54,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -66,12 +69,12 @@ spec: value: $(params.PULL_BASE_SHA) - name: deleteExisting value: "true" - - name: build-image-runner + - name: build-image taskRef: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -88,6 +91,7 @@ spec: - name: EXTRA_ARGS value: - "--destination=$(params.image-name)" # Also write the :latest image + - "--target=$(params.target-name)" - --cache=true - --cache-copy-layers - --cache-repo=harbor.fizz.buzz/kanikocache/cache @@ -101,8 +105,6 @@ spec: workspace: git-source - name: dockerconfig workspace: docker-credentials - runAfter: - - fetch-repository finally: - name: report-success when: @@ -113,7 +115,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -142,7 +144,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -179,11 +181,11 @@ spec: - name: docker-credentials secret: secretName: harbor-plain - serviceAccountName: build-bot - timeout: 240h0m0s params: - name: image-name value: "harbor.fizz.buzz/private/natter" + - name: target-name + value: "" - name: path-to-image-context value: . - name: path-to-dockerfile diff --git a/.lighthouse/pipeline-format.yaml b/.webhook_bridge/pipeline-format.yaml similarity index 87% rename from .lighthouse/pipeline-format.yaml rename to .webhook_bridge/pipeline-format.yaml index 245c4dd..ce07c3c 100644 --- a/.lighthouse/pipeline-format.yaml +++ b/.webhook_bridge/pipeline-format.yaml @@ -1,17 +1,22 @@ -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: PipelineRun metadata: name: rust-format spec: + timeouts: + pipeline: "2h0m0s" + tasks: "1h0m0s" + finally: "0h30m0s" + taskRunTemplate: + serviceAccountName: build-bot pipelineSpec: - timeouts: - pipeline: "2h0m0s" - tasks: "1h0m0s" - finally: "0h30m0s" params: - name: image-name description: The name for the built image type: string + - name: target-name + description: The dockerfile target to build + type: string - name: path-to-image-context description: The path to the build context type: string @@ -24,13 +29,11 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo value: task/gitea-set-status/0.1/gitea-set-status.yaml - runAfter: - - fetch-repository params: - name: CONTEXT value: "$(params.JOB_NAME)" @@ -51,7 +54,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -71,7 +74,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -87,6 +90,7 @@ spec: value: "gcr.io/kaniko-project/executor:v1.12.1" - name: EXTRA_ARGS value: + - "--target=$(params.target-name)" - --cache=true - --cache-copy-layers - --cache-repo=harbor.fizz.buzz/kanikocache/cache @@ -100,8 +104,6 @@ spec: workspace: git-source - name: dockerconfig workspace: docker-credentials - runAfter: - - fetch-repository - name: run-cargo-fmt taskSpec: metadata: {} @@ -109,11 +111,10 @@ spec: - name: docker-image type: string description: Docker image to run. - default: alpine:3.19 + default: alpine:3.20 stepTemplate: - image: alpine:3.19 - name: "" - resources: + image: alpine:3.20 + computeResources: requests: cpu: 10m memory: 600Mi @@ -150,11 +151,10 @@ spec: - name: docker-image type: string description: Docker image to run. - default: alpine:3.19 + default: alpine:3.20 stepTemplate: - image: alpine:3.19 - name: "" - resources: + image: alpine:3.20 + computeResources: requests: cpu: 10m memory: 600Mi @@ -170,14 +170,11 @@ spec: args: - | prettier --write --no-error-on-unmatched-pattern "default_environment/**/*.js" "default_environment/**/*.css" - env: - - name: CARGO_TARGET_DIR - value: /target workspaces: - name: source workspace: git-source runAfter: - - run-cargo-fmt + - build-image params: - name: docker-image value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" @@ -186,7 +183,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -211,6 +208,7 @@ spec: - name: source workspace: git-source runAfter: + - run-cargo-fmt - run-prettier finally: - name: report-success @@ -222,7 +220,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -251,7 +249,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -278,11 +276,10 @@ spec: - name: docker-image type: string description: Docker image to run. - default: alpine:3.19 + default: alpine:3.20 stepTemplate: - image: alpine:3.19 - name: "" - resources: + image: alpine:3.20 + computeResources: requests: cpu: 10m memory: 600Mi @@ -328,10 +325,11 @@ spec: - name: docker-credentials secret: secretName: harbor-plain - serviceAccountName: build-bot params: - name: image-name - value: "harbor.fizz.buzz/private/natter-development" + value: "harbor.fizz.buzz/private/natter-development-format" + - name: target-name + value: "" - name: path-to-image-context value: docker/natter_development/ - name: path-to-dockerfile diff --git a/.lighthouse/pipeline-rust-clippy.yaml b/.webhook_bridge/pipeline-rust-clippy.yaml similarity index 87% rename from .lighthouse/pipeline-rust-clippy.yaml rename to .webhook_bridge/pipeline-rust-clippy.yaml index 4a02f3d..05675ec 100644 --- a/.lighthouse/pipeline-rust-clippy.yaml +++ b/.webhook_bridge/pipeline-rust-clippy.yaml @@ -1,17 +1,22 @@ -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: PipelineRun metadata: name: rust-clippy spec: + taskRunTemplate: + serviceAccountName: build-bot + timeouts: + pipeline: "2h0m0s" + tasks: "1h0m40s" + finally: "0h30m0s" pipelineSpec: - timeouts: - pipeline: "2h0m0s" - tasks: "1h0m40s" - finally: "0h30m0s" params: - name: image-name description: The name for the built image type: string + - name: target-name + description: The dockerfile target to build + type: string - name: path-to-image-context description: The path to the build context type: string @@ -24,13 +29,11 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo value: task/gitea-set-status/0.1/gitea-set-status.yaml - runAfter: - - fetch-repository params: - name: CONTEXT value: "$(params.JOB_NAME)" @@ -51,7 +54,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -71,7 +74,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -87,6 +90,7 @@ spec: value: "gcr.io/kaniko-project/executor:v1.12.1" - name: EXTRA_ARGS value: + - "--target=$(params.target-name)" - --cache=true - --cache-copy-layers - --cache-repo=harbor.fizz.buzz/kanikocache/cache @@ -100,8 +104,6 @@ spec: workspace: git-source - name: dockerconfig workspace: docker-credentials - runAfter: - - fetch-repository - name: run-cargo-clippy taskSpec: metadata: {} @@ -109,11 +111,10 @@ spec: - name: docker-image type: string description: Docker image to run. - default: alpine:3.19 + default: alpine:3.20 stepTemplate: - image: alpine:3.19 - name: "" - resources: + image: alpine:3.20 + computeResources: requests: cpu: 10m memory: 600Mi @@ -163,7 +164,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -192,7 +193,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -219,11 +220,10 @@ spec: - name: docker-image type: string description: Docker image to run. - default: alpine:3.19 + default: alpine:3.20 stepTemplate: - image: alpine:3.19 - name: "" - resources: + image: alpine:3.20 + computeResources: requests: cpu: 10m memory: 600Mi @@ -269,10 +269,11 @@ spec: - name: docker-credentials secret: secretName: harbor-plain - serviceAccountName: build-bot params: - name: image-name - value: "harbor.fizz.buzz/private/natter-development" + value: "harbor.fizz.buzz/private/natter-development-clippy" + - name: target-name + value: "" - name: path-to-image-context value: docker/natter_development/ - name: path-to-dockerfile diff --git a/.lighthouse/pipeline-rust-test.yaml b/.webhook_bridge/pipeline-rust-test.yaml similarity index 86% rename from .lighthouse/pipeline-rust-test.yaml rename to .webhook_bridge/pipeline-rust-test.yaml index 87e6c40..cf20e81 100644 --- a/.lighthouse/pipeline-rust-test.yaml +++ b/.webhook_bridge/pipeline-rust-test.yaml @@ -1,17 +1,22 @@ -apiVersion: tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 kind: PipelineRun metadata: name: rust-test spec: + timeouts: + pipeline: "2h0m0s" + tasks: "1h0m40s" + finally: "0h30m0s" + taskRunTemplate: + serviceAccountName: build-bot pipelineSpec: - timeouts: - pipeline: "2h0m0s" - tasks: "1h0m40s" - finally: "0h30m0s" params: - name: image-name description: The name for the built image type: string + - name: target-name + description: The dockerfile target to build + type: string - name: path-to-image-context description: The path to the build context type: string @@ -24,13 +29,11 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo value: task/gitea-set-status/0.1/gitea-set-status.yaml - runAfter: - - fetch-repository params: - name: CONTEXT value: "$(params.JOB_NAME)" @@ -51,7 +54,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -71,11 +74,11 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo - value: task/kaniko/0.6//kaniko.yaml + value: task/kaniko/0.6/kaniko.yaml params: - name: IMAGE value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" @@ -87,6 +90,7 @@ spec: value: "gcr.io/kaniko-project/executor:v1.12.1" - name: EXTRA_ARGS value: + - "--target=$(params.target-name)" - --cache=true - --cache-copy-layers - --cache-repo=harbor.fizz.buzz/kanikocache/cache @@ -100,8 +104,6 @@ spec: workspace: git-source - name: dockerconfig workspace: docker-credentials - runAfter: - - fetch-repository - name: run-cargo-test taskSpec: metadata: {} @@ -109,11 +111,10 @@ spec: - name: docker-image type: string description: Docker image to run. - default: alpine:3.19 + default: alpine:3.20 stepTemplate: - image: alpine:3.19 - name: "" - resources: + image: alpine:3.20 + computeResources: requests: cpu: 10m memory: 600Mi @@ -153,7 +154,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -182,7 +183,7 @@ spec: resolver: git params: - name: url - value: https://github.com/tektoncd/catalog.git + value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git - name: revision value: df36b3853a5657fd883015cdbf07ad6466918acf - name: pathInRepo @@ -209,11 +210,10 @@ spec: - name: docker-image type: string description: Docker image to run. - default: alpine:3.19 + default: alpine:3.20 stepTemplate: - image: alpine:3.19 - name: "" - resources: + image: alpine:3.20 + computeResources: requests: cpu: 10m memory: 600Mi @@ -259,10 +259,11 @@ spec: - name: docker-credentials secret: secretName: harbor-plain - serviceAccountName: build-bot params: - name: image-name - value: "harbor.fizz.buzz/private/natter-development" + value: "harbor.fizz.buzz/private/natter-development-test" + - name: target-name + value: "" - name: path-to-image-context value: docker/natter_development/ - name: path-to-dockerfile diff --git a/.webhook_bridge/webhook_bridge.toml b/.webhook_bridge/webhook_bridge.toml new file mode 100644 index 0000000..5a2e580 --- /dev/null +++ b/.webhook_bridge/webhook_bridge.toml @@ -0,0 +1,25 @@ +version = "0.0.1" + +[[push]] + name = "rust-test" + source = "pipeline-rust-test.yaml" + clone_uri = "git@code.fizz.buzz:talexander/natter.git" + skip_branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ] + +[[push]] + name = "clippy" + source = "pipeline-rust-clippy.yaml" + clone_uri = "git@code.fizz.buzz:talexander/natter.git" + skip_branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ] + +[[push]] + name = "format" + source = "pipeline-format.yaml" + clone_uri = "git@code.fizz.buzz:talexander/natter.git" + skip_branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ] + +[[push]] + name = "build" + source = "pipeline-build-hash.yaml" + clone_uri = "git@code.fizz.buzz:talexander/natter.git" + branches = [ "^main$", "^master$" ]