Skip to content

Commit

Permalink
Automate Pull Request Checklist - Check Tasks Completed
Browse files Browse the repository at this point in the history
As described in #910, we
have a submitter checklists in pull requests that enforce with our
standards.

Currently, maintainers and reviewers have to manually check that the
submitter checklist has been checked off and verify each item in the
list. If the submitter checklist has not been checked off, they need
to follow up with the user and request them to follow the standards
and check them off.

In this change, we add automation that checks that the checklist has
been checked off. If there's an incomplete item, the check reports that
there are incomplete tasks but does not fail yet. In a future change, we
will make the check fail if the submitter checklist is not checked off.
  • Loading branch information
jerop committed Dec 16, 2021
1 parent df1c25d commit 3900da1
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tekton/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ spec:
- ref: tekton-ci-webhook-pull-request
- ref: tekton-ci-webhook-pr-labels
- ref: tekton-ci-clone-depth
- ref: tekton-ci-webhook-pr-body
template:
ref: tekton-plumbing-ci-pipeline
```
Expand All @@ -366,6 +367,7 @@ spec:
- ref: tekton-ci-webhook-comment
- ref: tekton-ci-clone-depth
- ref: tekton-ci-webhook-issue-labels
- ref: tekton-ci-webhook-pr-body
template:
ref: tekton-plumbing-ci-pipeline
```
Expand Down
3 changes: 2 additions & 1 deletion tekton/ci/jobs/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ resources:
- e2e-kind.yaml
- tekton-kind-label.yaml
- tekton-golang-lint.yaml
- tekton-yamllint.yaml
- tekton-yamllint.yaml
- tekton-github-tasks-completed.yaml
67 changes: 67 additions & 0 deletions tekton/ci/jobs/tekton-github-tasks-completed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: github-tasks-completed
namespace: tektonci
description: |
Verifies that a PR has all the tasks completed
spec:
params:
- name: body
description: The body of the Pull Request
stepTemplate:
env:
- name: HOME
value: /tekton/home
steps:
- name: install-pyyaml
image: python:3-alpine
script: |
pip install pyyaml --user
- name: check-github-tasks-completed
image: python:3-alpine
script: |
#!/usr/bin/env python
import sys
prBodyText = """$(params.body)"""
incompleteTasks = prBodyText.count("- []")
if incompleteTasks > 0:
msg = "Error: {} incomplete GitHub Tasks found, expecting no incomplete GitHub Tasks".format(incompleteTasks)
print(msg)
# TODO (jerop): comment out in a follow up PR
# Check failed. Return exit code 1.
# sys.exit(1)
else:
print("Found no incomplete GitHub Tasks)
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: tekton-github-tasks-completed
namespace: tektonci
spec:
params:
- name: checkName
description: The name of the GitHub check that this pipeline is used for
- name: gitHubCommand
description: The command that was used to trigger testing
- name: body
description: The body of the Pull Request
tasks:
- name: github-tasks-completed
conditions:
- conditionRef: "check-name-matches"
params:
- name: gitHubCommand
value: $(params.gitHubCommand)
- name: checkName
value: $(params.checkName)
taskRef:
name: github-tasks-completed
params:
- name: body
value: $(params.body)
10 changes: 10 additions & 0 deletions tekton/ci/shared/bindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,13 @@ spec:
params:
- name: labels
value: $(body.issue.labels)
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: tekton-ci-webhook-pr-body
namespace: tektonci
spec:
params:
- name: labels
value: $(body.pull_request.body)
93 changes: 93 additions & 0 deletions tekton/ci/templates/bindings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: tekton-ci-github-base
namespace: tektonci
spec:
params:
- name: buildUUID
value: $(header.X-GitHub-Delivery)
- name: package
value: $(body.repository.full_name)
- name: gitRepository
value: $(body.repository.html_url)
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: tekton-ci-clone-depth
namespace: tektonci
spec:
params:
- name: gitCloneDepth
value: $(extensions.git_clone_depth)
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: tekton-ci-webhook-pull-request
namespace: tektonci
spec:
params:
- name: gitRevision
value: $(body.pull_request.head.sha)
- name: pullRequestNumber
value: $(body.pull_request.number)
- name: pullRequestUrl
value: $(body.pull_request.html_url)
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: tekton-ci-webhook-comment
namespace: tektonci
spec:
params:
- name: gitRevision
value: $(body.extensions.add_pr_body.pull_request_body.head.sha)
- name: pullRequestNumber
value: $(body.extensions.add_pr_body.pull_request_body.number)
- name: pullRequestUrl
value: $(body.issue.pull_request.html_url)
- name: gitHubCommand
value: $(body.comment.body)
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: tekton-ci-webhook-tektoncd-comment
namespace: tektonci
spec:
params:
- name: gitHubCommand
value: $(body.comment.body)
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: tekton-ci-webhook-pr-labels
namespace: tektonci
spec:
params:
- name: labels
value: $(body.pull_request.labels)
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: tekton-ci-webhook-issue-labels
namespace: tektonci
spec:
params:
- name: labels
value: $(body.issue.labels)
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: tekton-ci-webhook-pr-body
namespace: tektonci
spec:
params:
- name: labels
value: $(body.pull_request.body)
24 changes: 24 additions & 0 deletions tekton/ci/website/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ spec:
default: ""
- name: labels
description: List of labels currently on the Pull Request
- name: body
description: The body of the Pull Request
resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: PipelineRun
Expand Down Expand Up @@ -73,3 +75,25 @@ spec:
value: $(tt.params.gitHubCommand)
- name: path
value: sync
- apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: check-github-tasks-completed-
labels:
prow.k8s.io/build-id: $(tt.params.buildUUID)
tekton.dev/check-name: check-pr-submitter-checklist
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:
pipelineRef:
name: tekton-github-tasks-completed
params:
- name: body
value: $(tt.params.body)
- name: checkName
value: check-pr-submitter-checklist
- name: gitHubCommand
value: $(tt.params.gitHubCommand)

0 comments on commit 3900da1

Please sign in to comment.