From 507382052d7377bb0fbe8310517ec99d5261f085 Mon Sep 17 00:00:00 2001 From: Adam Cmiel Date: Wed, 24 Jul 2024 10:14:39 +0200 Subject: [PATCH 1/2] .tekton/pull-request: re-format CEL expression Also add comments. Signed-off-by: Adam Cmiel --- .tekton/pull-request.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.tekton/pull-request.yaml b/.tekton/pull-request.yaml index 55279e1dd..907939458 100644 --- a/.tekton/pull-request.yaml +++ b/.tekton/pull-request.yaml @@ -4,7 +4,15 @@ kind: PipelineRun metadata: name: build-definitions-pull-request annotations: - pipelinesascode.tekton.dev/on-cel-expression: (event == "pull_request" && target_branch == "main" && ( !has(body.pull_request) || !body.pull_request.draft) ) || (event == "push" && target_branch.startsWith("gh-readonly-queue/main/")) + pipelinesascode.tekton.dev/on-cel-expression: | + ( + // PR to "main" branch, not draft + event == "pull_request" && target_branch == "main" + && (!has(body.pull_request) || !body.pull_request.draft) + ) || ( + // PR enters the merge queue + event == "push" && target_branch.startsWith("gh-readonly-queue/main/") + ) pipelinesascode.tekton.dev/task: "[task/git-clone/0.1/git-clone.yaml, .tekton/tasks/buildah.yaml, .tekton/tasks/yaml-lint.yaml, .tekton/tasks/e2e-test.yaml, task/sast-snyk-check/0.1/sast-snyk-check.yaml]" pipelinesascode.tekton.dev/task-2: "yaml-lint" pipelinesascode.tekton.dev/max-keep-runs: "5" From 75cebe2abf468a9150e68c012c4a9af1719a82c5 Mon Sep 17 00:00:00 2001 From: Adam Cmiel Date: Wed, 24 Jul 2024 10:42:26 +0200 Subject: [PATCH 2/2] .tekton/pull-request: run conditionally Don't run the pipeline if the only changed files are - *.md - .github/* - renovate.json Signed-off-by: Adam Cmiel --- .tekton/pull-request.yaml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.tekton/pull-request.yaml b/.tekton/pull-request.yaml index 907939458..9561ce669 100644 --- a/.tekton/pull-request.yaml +++ b/.tekton/pull-request.yaml @@ -6,12 +6,18 @@ metadata: annotations: pipelinesascode.tekton.dev/on-cel-expression: | ( - // PR to "main" branch, not draft - event == "pull_request" && target_branch == "main" - && (!has(body.pull_request) || !body.pull_request.draft) - ) || ( - // PR enters the merge queue - event == "push" && target_branch.startsWith("gh-readonly-queue/main/") + ( + // PR to "main" branch, not draft + event == "pull_request" && target_branch == "main" + && (!has(body.pull_request) || !body.pull_request.draft) + ) || ( + // PR enters the merge queue + event == "push" && target_branch.startsWith("gh-readonly-queue/main/") + ) + ) && ( + // Don't run pipeline if only these files changed. Note that 'files.all' is an object + // coming from PaC (list of all changed files) while the second 'all' is a CEL macro. + !files.all.all(x, x.matches(r"^(renovate\.json|.*\.md|\.github/.*)$")) ) pipelinesascode.tekton.dev/task: "[task/git-clone/0.1/git-clone.yaml, .tekton/tasks/buildah.yaml, .tekton/tasks/yaml-lint.yaml, .tekton/tasks/e2e-test.yaml, task/sast-snyk-check/0.1/sast-snyk-check.yaml]" pipelinesascode.tekton.dev/task-2: "yaml-lint"