Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment: Add GitHub action to enforce tasks are checked off #1693

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/task-checklist/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: Task Checklist
runs:
using: 'node20'
main: 'index.js'
63 changes: 63 additions & 0 deletions .github/actions/task-checklist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const core = require('@actions/core');
const github = require('@actions/github');

// Detects tasks in the form:
// - [ ] Task 1
//
// Also handles whitespace around any of the characters,
// and the three different ways to make a list (dash, asterisk, plus)
const INCOMPLETE_TASKS_REGEX = /^\s*[-*+]\s+\[ \]\s+(.*)/gm;

// This regex finds regions which we should EXCLUDE from the task checklist action.
//
// - s flag required so that ".*?" matches over multiple lines
// - "?" in ".*?" ensures that we match the smallest possible string
// - note that m flag is not required.
const DISABLE_COMMENT_REGEX =
/<!--\s*task-checklist-ignore-start\s*-->.*?<!--\s*task-checklist-ignore-end\s*-->/gs;

const run = () => {
const body = github.context.payload.pull_request?.body;
if (!body) {
console.log('PR description empty, skipping this check.');
return;
}

const bodyWithoutDisables = body.replace(DISABLE_COMMENT_REGEX, '');
if (body !== bodyWithoutDisables) {
console.log(
'Found at least one "task-checklist-ignore-start"/"task-checklist-ignore-end" block. Items in these blocks will be ignored.'
);
console.log('---');
}

const matches = [...bodyWithoutDisables.matchAll(INCOMPLETE_TASKS_REGEX)].map(
(match) => match[1]
);

if (!matches.length) {
console.log('No tasks marked as incomplete. Great work!');
return;
}

const plural = matches.length > 1 ? 's' : '';
console.error(`Found incomplete task${plural}:`);
for (const match of matches) {
console.error(`- ${match}`);
}

console.log('---');
console.log(
'False positive? Insert <!-- task-checklist-ignore-start --> and <!-- task-checklist-ignore-end --> in the section(s) of your PR where you want to skip the check.'
);
console.log('However, with great power comes great responsibility...');
console.log('---');

core.setFailed(`
Found ${matches.length} task${plural} in the PR description not marked as completed.

Please complete all tasks in your PR description before merging.
`);
};

run();
11 changes: 11 additions & 0 deletions .github/actions/task-checklist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "task-checklist",
"private": "true",
"version": "1.0.0",
"main": "index.js",
"license": "Apache-2.0",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0"
}
}
170 changes: 170 additions & 0 deletions .github/actions/task-checklist/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@actions/core@^1.10.1":
version "1.10.1"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@actions/core/-/core-1.10.1.tgz#61108e7ac40acae95ee36da074fa5850ca4ced8a"
integrity sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==
dependencies:
"@actions/http-client" "^2.0.1"
uuid "^8.3.2"

"@actions/github@^6.0.0":
version "6.0.0"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@actions/github/-/github-6.0.0.tgz#65883433f9d81521b782a64cc1fd45eef2191ea7"
integrity sha512-alScpSVnYmjNEXboZjarjukQEzgCRmjMv6Xj47fsdnqGS73bjJNDpiiXmp8jr0UZLdUB6d9jW63IcmddUP+l0g==
dependencies:
"@actions/http-client" "^2.2.0"
"@octokit/core" "^5.0.1"
"@octokit/plugin-paginate-rest" "^9.0.0"
"@octokit/plugin-rest-endpoint-methods" "^10.0.0"

"@actions/http-client@^2.0.1", "@actions/http-client@^2.2.0":
version "2.2.1"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@actions/http-client/-/http-client-2.2.1.tgz#ed3fe7a5a6d317ac1d39886b0bb999ded229bb38"
integrity sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw==
dependencies:
tunnel "^0.0.6"
undici "^5.25.4"

"@fastify/busboy@^2.0.0":
version "2.1.1"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d"
integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==

"@octokit/auth-token@^4.0.0":
version "4.0.0"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/auth-token/-/auth-token-4.0.0.tgz#40d203ea827b9f17f42a29c6afb93b7745ef80c7"
integrity sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==

"@octokit/core@^5.0.1":
version "5.2.0"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/core/-/core-5.2.0.tgz#ddbeaefc6b44a39834e1bb2e58a49a117672a7ea"
integrity sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==
dependencies:
"@octokit/auth-token" "^4.0.0"
"@octokit/graphql" "^7.1.0"
"@octokit/request" "^8.3.1"
"@octokit/request-error" "^5.1.0"
"@octokit/types" "^13.0.0"
before-after-hook "^2.2.0"
universal-user-agent "^6.0.0"

"@octokit/endpoint@^9.0.1":
version "9.0.5"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/endpoint/-/endpoint-9.0.5.tgz#e6c0ee684e307614c02fc6ac12274c50da465c44"
integrity sha512-ekqR4/+PCLkEBF6qgj8WqJfvDq65RH85OAgrtnVp1mSxaXF03u2xW/hUdweGS5654IlC0wkNYC18Z50tSYTAFw==
dependencies:
"@octokit/types" "^13.1.0"
universal-user-agent "^6.0.0"

"@octokit/graphql@^7.1.0":
version "7.1.0"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/graphql/-/graphql-7.1.0.tgz#9bc1c5de92f026648131f04101cab949eeffe4e0"
integrity sha512-r+oZUH7aMFui1ypZnAvZmn0KSqAUgE1/tUXIWaqUCa1758ts/Jio84GZuzsvUkme98kv0WFY8//n0J1Z+vsIsQ==
dependencies:
"@octokit/request" "^8.3.0"
"@octokit/types" "^13.0.0"
universal-user-agent "^6.0.0"

"@octokit/openapi-types@^20.0.0":
version "20.0.0"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/openapi-types/-/openapi-types-20.0.0.tgz#9ec2daa0090eeb865ee147636e0c00f73790c6e5"
integrity sha512-EtqRBEjp1dL/15V7WiX5LJMIxxkdiGJnabzYx5Apx4FkQIFgAfKumXeYAqqJCj1s+BMX4cPFIFC4OLCR6stlnA==

"@octokit/openapi-types@^22.2.0":
version "22.2.0"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/openapi-types/-/openapi-types-22.2.0.tgz#75aa7dcd440821d99def6a60b5f014207ae4968e"
integrity sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg==

"@octokit/plugin-paginate-rest@^9.0.0":
version "9.2.1"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.2.1.tgz#2e2a2f0f52c9a4b1da1a3aa17dabe3c459b9e401"
integrity sha512-wfGhE/TAkXZRLjksFXuDZdmGnJQHvtU/joFQdweXUgzo1XwvBCD4o4+75NtFfjfLK5IwLf9vHTfSiU3sLRYpRw==
dependencies:
"@octokit/types" "^12.6.0"

"@octokit/plugin-rest-endpoint-methods@^10.0.0":
version "10.4.1"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.4.1.tgz#41ba478a558b9f554793075b2e20cd2ef973be17"
integrity sha512-xV1b+ceKV9KytQe3zCVqjg+8GTGfDYwaT1ATU5isiUyVtlVAO3HNdzpS4sr4GBx4hxQ46s7ITtZrAsxG22+rVg==
dependencies:
"@octokit/types" "^12.6.0"

"@octokit/request-error@^5.1.0":
version "5.1.0"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/request-error/-/request-error-5.1.0.tgz#ee4138538d08c81a60be3f320cd71063064a3b30"
integrity sha512-GETXfE05J0+7H2STzekpKObFe765O5dlAKUTLNGeH+x47z7JjXHfsHKo5z21D/o/IOZTUEI6nyWyR+bZVP/n5Q==
dependencies:
"@octokit/types" "^13.1.0"
deprecation "^2.0.0"
once "^1.4.0"

"@octokit/request@^8.3.0", "@octokit/request@^8.3.1":
version "8.4.0"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/request/-/request-8.4.0.tgz#7f4b7b1daa3d1f48c0977ad8fffa2c18adef8974"
integrity sha512-9Bb014e+m2TgBeEJGEbdplMVWwPmL1FPtggHQRkV+WVsMggPtEkLKPlcVYm/o8xKLkpJ7B+6N8WfQMtDLX2Dpw==
dependencies:
"@octokit/endpoint" "^9.0.1"
"@octokit/request-error" "^5.1.0"
"@octokit/types" "^13.1.0"
universal-user-agent "^6.0.0"

"@octokit/types@^12.6.0":
version "12.6.0"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/types/-/types-12.6.0.tgz#8100fb9eeedfe083aae66473bd97b15b62aedcb2"
integrity sha512-1rhSOfRa6H9w4YwK0yrf5faDaDTb+yLyBUKOCV4xtCDB5VmIPqd/v9yr9o6SAzOAlRxMiRiCic6JVM1/kunVkw==
dependencies:
"@octokit/openapi-types" "^20.0.0"

"@octokit/types@^13.0.0", "@octokit/types@^13.1.0":
version "13.5.0"
resolved "https://packages.atlassian.com/api/npm/npm-remote/@octokit/types/-/types-13.5.0.tgz#4796e56b7b267ebc7c921dcec262b3d5bfb18883"
integrity sha512-HdqWTf5Z3qwDVlzCrP8UJquMwunpDiMPt5er+QjGzL4hqr/vBVY/MauQgS1xWxCDT1oMx1EULyqxncdCY/NVSQ==
dependencies:
"@octokit/openapi-types" "^22.2.0"

before-after-hook@^2.2.0:
version "2.2.3"
resolved "https://packages.atlassian.com/api/npm/npm-remote/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c"
integrity sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==

deprecation@^2.0.0:
version "2.3.1"
resolved "https://packages.atlassian.com/api/npm/npm-remote/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919"
integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==

once@^1.4.0:
version "1.4.0"
resolved "https://packages.atlassian.com/api/npm/npm-remote/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==
dependencies:
wrappy "1"

tunnel@^0.0.6:
version "0.0.6"
resolved "https://packages.atlassian.com/api/npm/npm-remote/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==

undici@^5.25.4:
version "5.28.4"
resolved "https://packages.atlassian.com/api/npm/npm-remote/undici/-/undici-5.28.4.tgz#6b280408edb6a1a604a9b20340f45b422e373068"
integrity sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==
dependencies:
"@fastify/busboy" "^2.0.0"

universal-user-agent@^6.0.0:
version "6.0.1"
resolved "https://packages.atlassian.com/api/npm/npm-remote/universal-user-agent/-/universal-user-agent-6.0.1.tgz#15f20f55da3c930c57bddbf1734c6654d5fd35aa"
integrity sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==

uuid@^8.3.2:
version "8.3.2"
resolved "https://packages.atlassian.com/api/npm/npm-remote/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

wrappy@1:
version "1.0.2"
resolved "https://packages.atlassian.com/api/npm/npm-remote/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
22 changes: 22 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### What is this change?

Describe what change you are making here.

### Why are we making this change?

Give the full context for your change here.

### How are we making this change?

(Optional.)

---

### PR checklist

Don't delete me!

I have...

- [ ] Updated or added applicable tests
- [ ] Updated the documentation in `website/`
15 changes: 15 additions & 0 deletions .github/workflows/task-checklist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Check all tasks are completed

on:
check_run:
pull_request:
types: [opened, edited]

jobs:
task-checklist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: cd .github/actions/task-checklist && yarn install
- uses: ./.github/actions/task-checklist
Loading