-
Notifications
You must be signed in to change notification settings - Fork 225
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
[DO NOT MERGE THIS PR] Add slash command "/black" to format PRs #645
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: black-command | ||
on: | ||
repository_dispatch: | ||
types: [black-command] | ||
jobs: | ||
black: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout the pull request branch | ||
- uses: actions/checkout@v2 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} | ||
ref: ${{ github.event.client_payload.pull_request.head.ref }} | ||
|
||
# Setup Python environment | ||
- uses: actions/setup-python@v1 | ||
|
||
# Install black | ||
- name: Install black | ||
run: pip install black | ||
|
||
# Execute black in check mode | ||
- name: Black | ||
id: black | ||
run: echo ::set-output name=format::$(black --check --quiet . || echo "true") | ||
|
||
# Execute black and commit the change to the PR branch | ||
- name: Commit to the PR branch | ||
if: steps.black.outputs.format == 'true' | ||
run: | | ||
black . | ||
git config --global user.name 'actions-bot' | ||
git config --global user.email '58130806+actions-bot@users.noreply.github.com' | ||
git commit -am "[black-command] fixes" | ||
git push | ||
|
||
- name: Add reaction | ||
uses: peter-evans/create-or-update-comment@v1 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
repository: ${{ github.event.client_payload.github.payload.repository.full_name }} | ||
comment-id: ${{ github.event.client_payload.github.payload.comment.id }} | ||
reaction-type: hooray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Slash Command Dispatch | ||
on: | ||
issue_comment: | ||
# Type "edited" added here for test purposes. Where possible, avoid | ||
# using to prevent processing unnecessary events. | ||
types: [created, edited] | ||
jobs: | ||
slashCommandDispatch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Slash Command Dispatch | ||
uses: peter-evans/slash-command-dispatch@v2 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
commands: black | ||
issue-type: pull-request |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whose Personal Access Token (PAT) is this, and what scope does it have? I see it's stored as a secret in the PyGMT repo (though I can't see the secret itself), and know that it's needed to let the Github Action 'bot' do the work. Just asking because I realize at conda-forge/gmt-feedstock#100 (comment) that we might need to use a PAT there too. Was wondering if we could have a GMT organization-wide secret PAT for these Github Actions that require permission to make commits.
Alternatively, we could look into using https://github.com/tibdex/github-app-token - i.e. make an organization GMT Github App, and use that App to generate what is basically a PAT token on the fly (rather than one of our personal ones). See also https://github.com/peter-evans/create-pull-request/blob/master/docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens for instructions on how to set this up. I'd help out with this but haven't got admin permissions in the GMT organization 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a PAT of my own account, with the
repo
scope.It seems impossible to have an organization-wide PAT. The only way is someone generates a PAT and saves it as an organization-wide secret.
Yes, it looks promising.
Perhaps you can ask for admin permissions if necessary.
BTW, this PR doesn't work. The working one is PR #646.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, shall we try using tibdex/github-app-token then? The step by step instructions at https://github.com/peter-evans/create-pull-request/blob/master/docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens seem fairly straightforward. After we make the GMT-bot Github App, we can 'install' it here on GenericMappingTools/pygmt and at GenericMappingTools/gmt-feedstock to authenticate these bots.
And yes, I'll review things on #646 later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe hold on for a while, Github is experiencing some degraded performance (see https://www.githubstatus.com/incidents/28js6274ybpb. Noticed this in one of my other PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the github incident is resolved, right?