Skip to content

Commit

Permalink
GH1090 Fix comment commands not checking out the correct branch (#1094)
Browse files Browse the repository at this point in the history
* GH1090 Fix comment commands not checking out the correct branch

* GH1090 Add comment to the workflow file
  • Loading branch information
loicdiridollou authored Jan 13, 2025
1 parent 3f42941 commit 3547cda
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions .github/workflows/comment_commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,10 @@ jobs:
if: (github.event.issue.pull_request) && contains(fromJSON('["/pandas_nightly", "/pyright_strict", "/mypy_nightly"]'), github.event.comment.body)

steps:
- uses: actions/checkout@v4

- name: Install project dependencies
uses: ./.github/setup
with:
os: ubuntu-latest
python-version: "3.11"

- name: Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}
# run the tests based on the value of the comment
id: tests-step
run: poetry run poe ${{ fromJSON(env.RUN_COMMAND)[github.event.comment.body] }}

- name: Get head sha and store value
- name: Get head sha, branch name and store value
# get the sha of the last commit to attach the results of the tests
if: always()
id: get-sha
id: get-branch-info
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -48,6 +35,25 @@ jobs:
pull_number: ${{ github.event.issue.number }}
})
core.setOutput('sha', pr.data.head.sha)
core.setOutput('branch', pr.data.head.ref)
- name: Checkout code on the correct branch
uses: actions/checkout@v4
with:
# context is not aware which branch to checkout so it would otherwise
# default to main
ref: ${{ steps.get-branch-info.outputs.branch }}

- name: Install project dependencies
uses: ./.github/setup
with:
os: ubuntu-latest
python-version: "3.12"

- name: Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}
# run the tests based on the value of the comment
id: tests-step
run: poetry run poe ${{ fromJSON(env.RUN_COMMAND)[github.event.comment.body] }}

- name: Report results of the tests and publish
# publish the results to a check run no matter the pass or fail
Expand All @@ -58,7 +64,7 @@ jobs:
script: |
github.rest.checks.create({
name: '${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}',
head_sha: '${{ steps.get-sha.outputs.sha }}',
head_sha: '${{ steps.get-branch-info.outputs.sha }}',
status: 'completed',
conclusion: '${{ steps.tests-step.outcome }}',
output: {
Expand Down

0 comments on commit 3547cda

Please sign in to comment.