-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adds a Tekton Task and Pipeline which will run catlin on catalog tasks. - Add corresponding TriggerTemplate. - Modify EventListener to add catlin jobs. Signed-off-by: vinamra28 <vinjain@redhat.com>
- Loading branch information
1 parent
74ed364
commit b19b758
Showing
5 changed files
with
209 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: catlin-lint | ||
namespace: tektonci | ||
spec: | ||
description: >- | ||
This task detects changes in the pull request using git diff | ||
and stores the changed tasks names in a workspace and passes | ||
that to the catlin so that catlin can validate only changed | ||
files. | ||
workspaces: | ||
- name: store-changed-files | ||
description: Stores list of changed tasks | ||
params: | ||
- name: gitCloneDepth | ||
description: Number of commits in the change + 1 | ||
resources: | ||
inputs: | ||
- name: source | ||
type: git | ||
steps: | ||
- name: find-changed-tasks | ||
image: docker.io/alpine/git:v2.26.2@sha256:23618034b0be9205d9cc0846eb711b12ba4c9b468efdd8a59aac1d7b1a23363f | ||
workingDir: $(resources.inputs.source.path) | ||
script: | | ||
function detect_new_changed_tasks() { | ||
# detect for changes in the task manifest | ||
git --no-pager diff --name-only HEAD~$(( $(params.gitCloneDepth) - 1 ))|grep 'task/[^\/]*/[^\/]*/*[^/]*.yaml'|xargs -I {} dirname {} | ||
} | ||
all_tests=$(detect_new_changed_tasks |sort -u || true) | ||
echo -n $all_tests > $(workspaces.store-changed-files.path)/changed-files.txt | ||
- name: lint-catalog | ||
image: gcr.io/tekton-releases/dogfooding/catlin:latest | ||
workingDir: $(resources.inputs.source.path) | ||
script: | | ||
catlin validate $(cat $(workspaces.store-changed-files.path)/changed-files.txt) | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Pipeline | ||
metadata: | ||
name: catlin-linter | ||
namespace: tektonci | ||
spec: | ||
workspaces: | ||
- name: store-changed-files | ||
description: Stores list of changed tasks | ||
resources: | ||
- name: source | ||
type: git | ||
params: | ||
- name: gitCloneDepth | ||
description: Number of commits in the change + 1 | ||
- name: gitHubCommand | ||
description: The command that was used to trigger testing | ||
- name: checkName | ||
description: The name of the GitHub check that this pipeline is used for | ||
tasks: | ||
- name: lint-catalog | ||
conditions: | ||
- conditionRef: "check-name-matches" | ||
params: | ||
- name: gitHubCommand | ||
value: $(params.gitHubCommand) | ||
- name: checkName | ||
value: $(params.checkName) | ||
taskRef: | ||
name: catlin-lint | ||
workspaces: | ||
- name: store-changed-files | ||
workspace: store-changed-files | ||
resources: | ||
inputs: | ||
- name: source | ||
resource: source | ||
params: | ||
- name: gitCloneDepth | ||
value: $(params.gitCloneDepth) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
apiVersion: triggers.tekton.dev/v1alpha1 | ||
kind: TriggerTemplate | ||
metadata: | ||
name: tekton-catalog-ci-pipeline | ||
namespace: tektonci | ||
annotations: | ||
triggers.tekton.dev/old-escape-quotes: "true" | ||
spec: | ||
params: | ||
- name: buildUUID | ||
description: UUID used to track a CI Pipeline Run in logs | ||
- name: package | ||
description: org/repo | ||
- name: pullRequestNumber | ||
description: The pullRequestNumber | ||
- name: pullRequestUrl | ||
description: The HTML URL for the pull request | ||
- name: gitRepository | ||
description: The git repository that hosts context and Dockerfile | ||
- name: gitRevision | ||
description: The Git revision to be used. | ||
- name: gitCloneDepth | ||
description: Number of commits in the change + 1 | ||
- name: gitHubCommand | ||
description: | | ||
The GitHub command that was used a trigger. This is only available when | ||
this template is triggered by a comment. The default value is for the | ||
case of a pull_request event. | ||
default: "" | ||
- name: labels | ||
description: List of labels currently on the Pull Request | ||
resourcetemplates: | ||
- apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
generateName: catalog-catlin-run- | ||
labels: | ||
prow.k8s.io/build-id: $(tt.params.buildUUID) | ||
tekton.dev/check-name: pull-catalog-catlin-lint | ||
tekton.dev/kind: ci | ||
tekton.dev/pr-number: $(tt.params.pullRequestNumber) | ||
annotations: | ||
tekton.dev/gitRevision: "$(tt.params.gitRevision)" | ||
tekton.dev/gitURL: "$(tt.params.gitRepository)" | ||
spec: | ||
serviceAccountName: tekton-ci-jobs | ||
pipelineRef: | ||
name: catlin-linter | ||
workspaces: | ||
- name: store-changed-files | ||
emptyDir: {} | ||
params: | ||
- name: gitCloneDepth | ||
value: $(tt.params.gitCloneDepth) | ||
- name: gitHubCommand | ||
value: $(tt.params.gitHubCommand) | ||
- name: checkName | ||
value: pull-catalog-catlin-lint | ||
resources: | ||
- name: source | ||
resourceSpec: | ||
type: git | ||
params: | ||
- name: revision | ||
value: $(tt.params.gitRevision) | ||
- name: url | ||
value: $(tt.params.gitRepository) | ||
- name: depth | ||
value: $(tt.params.gitCloneDepth) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters