From 4b85236c5fb238c1858dea72f51fac343be7fe1c Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 6 Apr 2024 10:57:04 -0400 Subject: [PATCH] Inline clippy pipeline spec. --- ...-clippy.yaml => pipeline-rust-clippy.yaml} | 158 ++++++++++++++---- .lighthouse/triggers.yaml | 58 +++---- 2 files changed, 152 insertions(+), 64 deletions(-) rename .lighthouse/{pipeline-clippy.yaml => pipeline-rust-clippy.yaml} (59%) diff --git a/.lighthouse/pipeline-clippy.yaml b/.lighthouse/pipeline-rust-clippy.yaml similarity index 59% rename from .lighthouse/pipeline-clippy.yaml rename to .lighthouse/pipeline-rust-clippy.yaml index e66457d..63dbcb4 100644 --- a/.lighthouse/pipeline-clippy.yaml +++ b/.lighthouse/pipeline-rust-clippy.yaml @@ -1,9 +1,13 @@ apiVersion: tekton.dev/v1beta1 kind: PipelineRun metadata: - name: clippy + name: rust-clippy spec: pipelineSpec: + timeouts: + pipeline: "2h0m0s" + tasks: "1h0m40s" + finally: "0h30m0s" params: - name: image-name description: The name for the built image @@ -14,35 +18,17 @@ spec: - name: path-to-dockerfile description: The path to the Dockerfile type: string - - name: GIT_USER_NAME - description: The username for git - type: string - default: "fluxcdbot" - - name: GIT_USER_EMAIL - description: The email for git - type: string - default: "fluxcdbot@users.noreply.github.com" tasks: - - name: do-stuff - taskSpec: - metadata: {} - stepTemplate: - image: alpine:3.19 - name: "" - resources: - requests: - cpu: 10m - memory: 600Mi - workingDir: /workspace/source - steps: - - image: alpine:3.19 - name: do-stuff-step - script: | - #!/usr/bin/env sh - echo "hello world" - name: report-pending taskRef: - name: gitea-set-status + resolver: git + params: + - name: url + value: 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: @@ -62,7 +48,14 @@ spec: value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)" - name: fetch-repository taskRef: - name: git-clone + resolver: git + params: + - name: url + value: https://github.com/tektoncd/catalog.git + - name: revision + value: df36b3853a5657fd883015cdbf07ad6466918acf + - name: pathInRepo + value: task/git-clone/0.9/git-clone.yaml workspaces: - name: output workspace: git-source @@ -75,7 +68,14 @@ spec: value: "true" - name: build-image taskRef: - name: kaniko + resolver: git + params: + - name: url + value: https://github.com/tektoncd/catalog.git + - name: revision + value: df36b3853a5657fd883015cdbf07ad6466918acf + - name: pathInRepo + value: task/kaniko/0.6/kaniko.yaml params: - name: IMAGE value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" @@ -102,9 +102,47 @@ spec: workspace: docker-credentials runAfter: - fetch-repository - - name: clippy - taskRef: - name: run-docker-image + - name: run-cargo-clippy + taskSpec: + metadata: {} + params: + - name: docker-image + type: string + description: Docker image to run. + default: alpine:3.18 + stepTemplate: + image: alpine:3.18 + name: "" + resources: + requests: + cpu: 10m + memory: 600Mi + workingDir: /workspace/source + workspaces: + - name: source + mountPath: /source + - name: cargo-cache + mountPath: /usr/local/cargo/registry + optional: true + steps: + - name: run + image: $(params.docker-image) + workingDir: "$(workspaces.source.path)" + command: + [ + "cargo", + "clippy", + "--no-deps", + "--all-targets", + "--all-features", + "--", + "-D", + "warnings", + ] + args: [] + env: + - name: CARGO_TARGET_DIR + value: /target workspaces: - name: source workspace: git-source @@ -122,7 +160,14 @@ spec: operator: in values: ["Succeeded", "Completed"] taskRef: - name: gitea-set-status + resolver: git + params: + - name: url + value: https://github.com/tektoncd/catalog.git + - name: revision + value: df36b3853a5657fd883015cdbf07ad6466918acf + - name: pathInRepo + value: task/gitea-set-status/0.1/gitea-set-status.yaml params: - name: CONTEXT value: "$(params.JOB_NAME)" @@ -144,7 +189,14 @@ spec: operator: in values: ["Failed"] taskRef: - name: gitea-set-status + resolver: git + params: + - name: url + value: https://github.com/tektoncd/catalog.git + - name: revision + value: df36b3853a5657fd883015cdbf07ad6466918acf + - name: pathInRepo + value: task/gitea-set-status/0.1/gitea-set-status.yaml params: - name: CONTEXT value: "$(params.JOB_NAME)" @@ -160,9 +212,46 @@ spec: value: failure - name: TARGET_URL value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)" + - name: cargo-cache-autoclean + taskSpec: + metadata: {} + params: + - name: docker-image + type: string + description: Docker image to run. + default: alpine:3.18 + stepTemplate: + image: alpine:3.18 + name: "" + resources: + requests: + cpu: 10m + memory: 600Mi + workingDir: /workspace/source + workspaces: + - name: source + mountPath: /source + - name: cargo-cache + mountPath: /usr/local/cargo/registry + optional: true + steps: + - name: run + image: $(params.docker-image) + workingDir: "$(workspaces.source.path)" + command: [cargo, cache, --autoclean] + args: [] + workspaces: + - name: source + workspace: git-source + - name: cargo-cache + workspace: cargo-cache + params: + - name: docker-image + value: "$(params.image-name):$(tasks.fetch-repository.results.commit)" workspaces: - name: git-source - name: docker-credentials + - name: cargo-cache workspaces: - name: git-source volumeClaimTemplate: @@ -181,7 +270,6 @@ spec: secret: secretName: harbor-plain serviceAccountName: build-bot - timeout: 240h0m0s params: - name: image-name value: "harbor.fizz.buzz/private/organic-clippy" diff --git a/.lighthouse/triggers.yaml b/.lighthouse/triggers.yaml index b63e382..887dbe4 100644 --- a/.lighthouse/triggers.yaml +++ b/.lighthouse/triggers.yaml @@ -2,36 +2,36 @@ apiVersion: config.lighthouse.jenkins-x.io/v1alpha1 kind: TriggerConfig spec: postsubmits: - - name: rustfmt - source: "pipeline-rustfmt.yaml" - # Override https-based url from lighthouse events. - clone_uri: "git@code.fizz.buzz:talexander/organic.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/organic.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-foreign-document-test - source: "pipeline-foreign-document-test.yaml" - # Override https-based url from lighthouse events. - clone_uri: "git@code.fizz.buzz:talexander/organic.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-build - source: "pipeline-rust-build.yaml" - # Override https-based url from lighthouse events. - clone_uri: "git@code.fizz.buzz:talexander/organic.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: rustfmt + # source: "pipeline-rustfmt.yaml" + # # Override https-based url from lighthouse events. + # clone_uri: "git@code.fizz.buzz:talexander/organic.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/organic.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-foreign-document-test + # source: "pipeline-foreign-document-test.yaml" + # # Override https-based url from lighthouse events. + # clone_uri: "git@code.fizz.buzz:talexander/organic.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-build + # source: "pipeline-rust-build.yaml" + # # Override https-based url from lighthouse events. + # clone_uri: "git@code.fizz.buzz:talexander/organic.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: clippy - source: "pipeline-clippy.yaml" + source: "pipeline-rust-clippy.yaml" # Override https-based url from lighthouse events. clone_uri: "git@code.fizz.buzz:talexander/organic.git" skip_branches: