Skip to content
Merged
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
26 changes: 26 additions & 0 deletions .github/workflows/gsoc-issues-auto-close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: gsoc-issues-auto-close

on:
issues:
types: [opened]

jobs:
close-untemplated-issue:
if: >
contains(fromJSON('["FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "NONE"]'), github.event.issue.author_association) &&
!contains(github.event.issue.body, 'Environment (`conda list`)') &&
!contains(github.event.issue.body, '**Is your feature request related to a problem? Please describe.**')
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
NUMBER: ${{ github.event.issue.number }}
BODY: |
👋 Welcome @${{ github.event.issue.user.login }}! Thank you for opening an issue in this repository!

Since this issue doesn't follow one of our issue templates, we are assuming this is a Google Summer of Code issue and hence closing it.

If you don't know what Google Summer of Code is and aren't applying to it, please open a new issue using one of the templates.

If you are planning to apply to the program please don't open a new issue, we don't have the capacity to review Google Summer of Code issues at the moment.
steps:
- run: gh issue close "$NUMBER" --repo "$GITHUB_REPOSITORY" --comment "$BODY"
29 changes: 0 additions & 29 deletions .github/workflows/mailmap.yml

This file was deleted.

46 changes: 0 additions & 46 deletions .github/workflows/publish-mailmap.yml

This file was deleted.

168 changes: 73 additions & 95 deletions .github/workflows/util.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,131 +2,109 @@ name: utility

on:
pull_request_target:
types: [opened]
branches:
- master
workflow_run:
workflows: [mailmap]
types: [completed]

# pull_request_target runs with secrets, so no job checks out or runs PR code.
permissions:
contents: read
issues: read
pull-requests: read

jobs:
resolve-pull-request:
mailmap:
runs-on: ubuntu-latest
outputs:
number: ${{ github.event.pull_request.number || (steps.find-workflow-run-pr.outputs.matching-pr-count == '1' && steps.find-workflow-run-pr.outputs.head-sha == github.event.workflow_run.head_sha && steps.find-workflow-run-pr.outputs.number || '') }}
login: ${{ github.event.pull_request.user.login || steps.find-workflow-run-pr.outputs.author }}
association: ${{ steps.get-author-association.outputs.value }}
gsoc: ${{ steps.get-author-association.outputs.gsoc }}
steps:
- id: find-workflow-run-pr
if: github.event_name == 'workflow_run'
uses: juliangruber/find-pull-request-action@v1
with:
github-token: ${{ github.token }}
branch: ${{ github.event.workflow_run.head_repository.owner.login }}:${{ github.event.workflow_run.head_branch }}
base: master
state: open

- id: get-author-association
if: github.event_name == 'pull_request_target' || steps.find-workflow-run-pr.outputs.matching-pr-count == '1'
uses: actions/github-script@v9
- name: Check PR authors
env:
NUMBER: ${{ github.event.pull_request.number || steps.find-workflow-run-pr.outputs.number }}
with:
script: |
const { data: pr } = await github.rest.pulls.get({
...context.repo,
pull_number: Number(process.env.NUMBER)
});
core.setOutput('value', pr.author_association);
core.setOutput('gsoc', /gsoc|google summer of code/i.test(`${pr.title}\n${pr.body ?? ''}`));

close-gsoc-pull-request:
needs: resolve-pull-request
if: >
github.event_name == 'pull_request_target' &&
contains(fromJSON('["FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "NONE"]'), needs.resolve-pull-request.outputs.association) &&
needs.resolve-pull-request.outputs.gsoc == 'true'
GH_TOKEN: ${{ github.token }}
NUMBER: ${{ github.event.pull_request.number }}
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
authors=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$NUMBER/commits" --paginate --jq '.[].commit.author | "\(.name) <\(.email)>"')
gh api "repos/$HEAD_REPO/contents/.mailmap?ref=$HEAD_SHA" -H 'Accept: application/vnd.github.raw' | grep -F "$authors" || {
echo "Committer name or email couldn't be found in .mailmap"
echo "$authors"
exit 1
}

comment-on-mailmap-failure:
needs: mailmap
if: failure()
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
NUMBER: ${{ needs.resolve-pull-request.outputs.number }}
steps:
- run: gh pr edit "$NUMBER" --repo "$GITHUB_REPOSITORY" --add-label 'GSoC :sun_with_face:'

- uses: peter-evans/create-or-update-comment@v5
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ needs.resolve-pull-request.outputs.number }}
issue-number: ${{ github.event.pull_request.number }}
body: |
👋 Hi @${{ needs.resolve-pull-request.outputs.login }}, thanks for your interest in TARDIS.
*\*beep\* \*bop\**

Hi, human.

This pull request mentions Google Summer of Code. We don't have the capacity to review GSoC pull requests at the moment, so we are closing it.
I'm the @tardis-bot and couldn't find your records in my database. I think we don't know each other, or you changed your credentials recently.

If this is not a Google Summer of Code pull request, please reopen it.
Please add your **name** and **email** to `.mailmap` in your current branch and push the changes to this pull request.

- run: gh pr close "$NUMBER" --repo "$GITHUB_REPOSITORY"
In case you need to map an existing alias, follow [this example](https://docs.enterprise.codescene.io/versions/2.0.0/getting-started/ensure-you-use-a-mailmap.html).

close-missing-mailmap-entry:
needs: resolve-pull-request
close-gsoc-pull-request:
if: >
github.event_name == 'workflow_run' &&
needs.resolve-pull-request.outputs.number != '' &&
contains(fromJSON('["FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "NONE"]'), needs.resolve-pull-request.outputs.association) &&
needs.resolve-pull-request.outputs.gsoc == 'false' &&
github.event.workflow_run.conclusion == 'failure'
github.event.action == 'opened' &&
contains(fromJSON('["FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "NONE"]'), github.event.pull_request.author_association) &&
(contains(github.event.pull_request.title, 'gsoc') || contains(github.event.pull_request.title, 'google summer of code') ||
contains(github.event.pull_request.body, 'gsoc') || contains(github.event.pull_request.body, 'google summer of code'))
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
NUMBER: ${{ needs.resolve-pull-request.outputs.number }}
NUMBER: ${{ github.event.pull_request.number }}
BODY: |
👋 Hi @${{ github.event.pull_request.user.login }}, thanks for your interest in TARDIS.

This pull request mentions Google Summer of Code. We don't have the capacity to review GSoC pull requests at the moment, so we are closing it.

If this is not a Google Summer of Code pull request, please reopen it.
steps:
- uses: peter-evans/find-comment@v3
id: find-close-notice
with:
issue-number: ${{ needs.resolve-pull-request.outputs.number }}
body-includes: we are assuming this is a Google Summer of Code pull request
- run: gh pr edit "$NUMBER" --repo "$GITHUB_REPOSITORY" --add-label 'GSoC :sun_with_face:'
- run: gh pr close "$NUMBER" --repo "$GITHUB_REPOSITORY" --comment "$BODY"

- if: steps.find-close-notice.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v5
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ needs.resolve-pull-request.outputs.number }}
body: |
👋 Welcome @${{ needs.resolve-pull-request.outputs.login }}! Thank you for your first contribution to this repository!
first-time-contributor:
if: >
github.event.action == 'opened' &&
contains(fromJSON('["FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "NONE"]'), github.event.pull_request.author_association) &&
!(contains(github.event.pull_request.title, 'gsoc') || contains(github.event.pull_request.title, 'google summer of code') ||
contains(github.event.pull_request.body, 'gsoc') || contains(github.event.pull_request.body, 'google summer of code'))
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
NUMBER: ${{ github.event.pull_request.number }}
steps:
# Read .mailmap from master so a PR cannot add its own entry to avoid closing.
- id: master-mailmap
run: |
authors=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$NUMBER/commits" --paginate --jq '.[].commit.author | "\(.name) <\(.email)>"')
mailmap=$(gh api "repos/$GITHUB_REPOSITORY/contents/.mailmap?ref=master" -H 'Accept: application/vnd.github.raw')
grep -qF "$authors" <<< "$mailmap" && echo found=true >> "$GITHUB_OUTPUT" || echo found=false >> "$GITHUB_OUTPUT"

- if: steps.master-mailmap.outputs.found == 'false'
env:
BODY: |
👋 Welcome @${{ github.event.pull_request.user.login }}! Thank you for your first contribution to this repository!

Since this pull request doesn't add your entry to `.mailmap`, we are assuming this is a Google Summer of Code pull request and hence closing it.
Since your name and email are not in `.mailmap` on the master branch, we are assuming this is a Google Summer of Code pull request and hence closing it.

If you don't know what Google Summer of Code is and aren't applying to it, please reopen this pull request.

If you are planning to apply to the program please keep it closed, we don't have the capacity to review GSoC pull requests at the moment.
run: gh pr close "$NUMBER" --repo "$GITHUB_REPOSITORY" --comment "$BODY"

- if: steps.find-close-notice.outputs.comment-id == ''
run: gh pr close "$NUMBER" --repo "$GITHUB_REPOSITORY"

welcome-first-time-contributor:
needs: resolve-pull-request
if: >
github.event_name == 'workflow_run' &&
needs.resolve-pull-request.outputs.number != '' &&
contains(fromJSON('["FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "NONE"]'), needs.resolve-pull-request.outputs.association) &&
needs.resolve-pull-request.outputs.gsoc == 'false' &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: peter-evans/find-comment@v3
id: find-welcome-comment
with:
issue-number: ${{ needs.resolve-pull-request.outputs.number }}
body-includes: A reviewer will take a look at your pull request soon

- if: steps.find-welcome-comment.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v5
with:
token: ${{ secrets.BOT_TOKEN }}
issue-number: ${{ needs.resolve-pull-request.outputs.number }}
body: |
👋 Welcome @${{ needs.resolve-pull-request.outputs.login }}! Thank you for your first contribution to this repository!
- if: steps.master-mailmap.outputs.found == 'true'
env:
BODY: |
👋 Welcome @${{ github.event.pull_request.user.login }}! Thank you for your first contribution to this repository!

A reviewer will take a look at your pull request soon.

Please mark the pull request as draft if you are not ready for review yet or if there are things you will be adding.
run: gh pr comment "$NUMBER" --repo "$GITHUB_REPOSITORY" --body "$BODY"
3 changes: 0 additions & 3 deletions docs/current_developers/continuous_integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ The following pairs use this setup:
* - ``compare-regdata``
- ``publish-regdata-comparison``
- Regression-data comparison page and comment
* - ``mailmap``
- ``publish-mailmap``
- Failure guidance comment
* - ``orcid-check``
- ``publish-orcid``
- Missing-ORCID guidance comment
Expand Down
Loading