Skip to content

Commit 83763bd

Browse files
GH613 Concentrate action in one with selector
1 parent 3e9efc1 commit 83763bd

File tree

1 file changed

+12
-111
lines changed

1 file changed

+12
-111
lines changed

.github/workflows/comment_commands.yml

Lines changed: 12 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -6,63 +6,16 @@ on:
66
permissions:
77
checks: write
88

9-
jobs:
10-
pandas_nightly:
11-
runs-on: ubuntu-latest
12-
timeout-minutes: 10
13-
if: (github.event.issue.pull_request) && github.event.comment.body == '/pandas_nightly'
14-
15-
steps:
16-
- uses: actions/checkout@v4
17-
18-
- name: Install project dependencies
19-
uses: ./.github/setup
20-
with:
21-
os: ubuntu-latest
22-
python-version: "3.11"
9+
env:
10+
RUN_COMMAND: '{"/pandas_nightly": "pytest --nightly", "/pyright_strict": "pyright_strict", "/mypy_nightly": "mypy --mypy_nightly"}'
11+
DISPLAY_COMMAND: '{"/pandas_nightly": "Pandas nightly tests", "/pyright_strict": "Pyright strict tests", "/mypy_nightly": "Mypy nightly tests"}'
2312

24-
- name: Run pytest (against pandas nightly)
25-
id: tests-step
26-
run: poetry run poe pytest --nightly
27-
28-
- name: Get head sha and store value
29-
if: always()
30-
id: get-sha
31-
uses: actions/github-script@v7
32-
with:
33-
github-token: ${{ secrets.GITHUB_TOKEN }}
34-
script: |
35-
const pr = await github.rest.pulls.get({
36-
owner: context.repo.owner,
37-
repo: context.repo.repo,
38-
pull_number: ${{ github.event.issue.number }}
39-
})
40-
core.setOutput('sha', pr.data.head.sha)
41-
#
42-
- name: Report results of the tests and publish
43-
if: always()
44-
uses: actions/github-script@v7
45-
with:
46-
github-token: ${{ secrets.GITHUB_TOKEN }}
47-
script: |
48-
github.rest.checks.create({
49-
name: 'Pandas nightly tests',
50-
head_sha: '${{ steps.get-sha.outputs.sha }}',
51-
status: 'completed',
52-
conclusion: '${{ steps.tests-step.outcome }}',
53-
output: {
54-
title: 'Run pandas nightly tests',
55-
summary: 'Results: ${{ steps.tests-step.outcome }}',
56-
text: 'See the actions run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
57-
},
58-
owner: context.repo.owner,
59-
repo: context.repo.repo
60-
})
61-
62-
mypy_nightly:
13+
jobs:
14+
optional_tests:
15+
name: "Optional tests run"
6316
runs-on: ubuntu-latest
6417
timeout-minutes: 10
65-
if: (github.event.issue.pull_request) && github.event.comment.body == '/mypy_nightly'
18+
if: (github.event.issue.pull_request) && contains(fromJSON('["/pandas_nightly", "/pyright_strict", "/mypy_nightly"]'), github.event.comment.body)
6619

6720
steps:
6821
- uses: actions/checkout@v4
@@ -73,9 +26,9 @@ jobs:
7326
os: ubuntu-latest
7427
python-version: "3.11"
7528

76-
- name: Run mypy tests with mypy nightly
29+
- name: Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}
7730
id: tests-step
78-
run: poetry run poe mypy --mypy_nightly
31+
run: poetry run poe ${{ fromJSON(env.RUN_COMMAND)[github.event.comment.body] }}
7932

8033
- name: Get head sha and store value
8134
if: always()
@@ -98,66 +51,14 @@ jobs:
9851
github-token: ${{ secrets.GITHUB_TOKEN }}
9952
script: |
10053
github.rest.checks.create({
101-
name: 'Mypy nightly tests',
102-
head_sha: '${{ steps.get-sha.outputs.sha }}',
103-
status: 'completed',
104-
conclusion: '${{ steps.tests-step.outcome }}',
105-
output: {
106-
title: 'Run mypy nightly tests',
107-
summary: 'Results: ${{ steps.tests-step.outcome }}',
108-
text: 'See the actions run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
109-
},
110-
owner: context.repo.owner,
111-
repo: context.repo.repo
112-
})
113-
114-
pyright_strict:
115-
runs-on: ubuntu-latest
116-
timeout-minutes: 10
117-
if: (github.event.issue.pull_request) && github.event.comment.body == '/pyright_strict'
118-
119-
steps:
120-
- uses: actions/checkout@v4
121-
122-
- name: Install project dependencies
123-
uses: ./.github/setup
124-
with:
125-
os: ubuntu-latest
126-
python-version: "3.11"
127-
128-
- name: Run pyright tests with full strict mode
129-
id: tests-step
130-
run: poetry run poe pyright_strict
131-
132-
- name: Get head sha and store value
133-
if: always()
134-
id: get-sha
135-
uses: actions/github-script@v7
136-
with:
137-
github-token: ${{ secrets.GITHUB_TOKEN }}
138-
script: |
139-
const pr = await github.rest.pulls.get({
140-
owner: context.repo.owner,
141-
repo: context.repo.repo,
142-
pull_number: ${{ github.event.issue.number }}
143-
})
144-
core.setOutput('sha', pr.data.head.sha)
145-
#
146-
- name: Report results of the tests and publish
147-
if: always()
148-
uses: actions/github-script@v7
149-
with:
150-
github-token: ${{ secrets.GITHUB_TOKEN }}
151-
script: |
152-
github.rest.checks.create({
153-
name: 'Pyright strict tests',
54+
name: '${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}',
15455
head_sha: '${{ steps.get-sha.outputs.sha }}',
15556
status: 'completed',
15657
conclusion: '${{ steps.tests-step.outcome }}',
15758
output: {
158-
title: 'Run pyright strict tests',
59+
title: 'Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}',
15960
summary: 'Results: ${{ steps.tests-step.outcome }}',
160-
text: 'See the actions run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
61+
text: 'See the actions run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
16162
},
16263
owner: context.repo.owner,
16364
repo: context.repo.repo

0 commit comments

Comments
 (0)