From a227d7797187d437f14a93b2aff5c6f578827e6b Mon Sep 17 00:00:00 2001 From: "Eric T. Johnson" Date: Fri, 10 May 2024 15:32:34 -0400 Subject: [PATCH 1/3] Add GH actions workflow to check PR labels --- .github/workflows/check-labels.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/check-labels.yaml diff --git a/.github/workflows/check-labels.yaml b/.github/workflows/check-labels.yaml new file mode 100644 index 0000000000..c73f323c56 --- /dev/null +++ b/.github/workflows/check-labels.yaml @@ -0,0 +1,27 @@ +# based on https://stackoverflow.com/a/75036059 and +# https://github.com/astropy/astropy/blob/main/.github/workflows/check_milestone.yml +name: Check PR labels + +on: + # So it cannot be skipped. + pull_request_target: + types: [opened, synchronize, labeled, unlabeled] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-labels: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v7 + with: + script: | + const requiredLabels = ['bug', 'enhancement', 'new feature', 'docs', 'infrastructure', 'dead code', 'refactor']; + let labels = context.payload.pull_request.labels; + + core.info(`Current labels: ${labels.map(l => l.name).join(', ')}`); + if (labels.filter(l => requiredLabels.includes(l.name)).length === 0) { + core.setFailed('Please label this pull request with one of: bug, enhancement, new feature, docs or infrastructure.'); + } From 1545d431fab66094922641d470a687d2408f34b5 Mon Sep 17 00:00:00 2001 From: "Eric T. Johnson" Date: Fri, 10 May 2024 16:42:33 -0400 Subject: [PATCH 2/3] Switch to github.head_ref for concurrency key It looks like `github.ref` points to the target branch when triggered by `pull_request_target`, while `github.head_ref` is always the source branch. --- .github/workflows/check-labels.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-labels.yaml b/.github/workflows/check-labels.yaml index c73f323c56..5e8dcdb7a8 100644 --- a/.github/workflows/check-labels.yaml +++ b/.github/workflows/check-labels.yaml @@ -8,7 +8,7 @@ on: types: [opened, synchronize, labeled, unlabeled] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.head_ref }} cancel-in-progress: true jobs: From 0cbd9c0744fe33ca7873c394b63a24ab756e8440 Mon Sep 17 00:00:00 2001 From: "Eric T. Johnson" Date: Fri, 10 May 2024 16:58:16 -0400 Subject: [PATCH 3/3] Remove mergeable config file --- .github/mergeable.yml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .github/mergeable.yml diff --git a/.github/mergeable.yml b/.github/mergeable.yml deleted file mode 100644 index 0fa8986004..0000000000 --- a/.github/mergeable.yml +++ /dev/null @@ -1,13 +0,0 @@ -# config file for mergeable: https://github.com/mergeability/mergeable -version: 2 -mergeable: - - when: pull_request.* - validate: - - do: title - must_exclude: - regex: ^\[?WIP\b - message: "WIP pull requests can't be merged." - - do: label - must_include: - regex: 'bug|enhancement|new feature|docs|infrastructure|dead code|refactor' - message: "Please label this pull request with one of: bug, enhancement, new feature, docs or infrastructure."