From 2e851e03237850a8ea081f65e00d068336aa63bd Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Mon, 12 Aug 2024 10:00:49 -0700 Subject: [PATCH 1/7] Modify optional workflows to be triggered by comments --- .github/workflows/comment_commands.yml | 164 +++++++++++++++++++++++++ .github/workflows/optional.yml | 56 --------- 2 files changed, 164 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/comment_commands.yml delete mode 100644 .github/workflows/optional.yml diff --git a/.github/workflows/comment_commands.yml b/.github/workflows/comment_commands.yml new file mode 100644 index 000000000..4adf4ecf8 --- /dev/null +++ b/.github/workflows/comment_commands.yml @@ -0,0 +1,164 @@ +name: Comment Commands to Trigger CI +on: + issue_comment: + types: created + +permissions: + checks: write + +jobs: + pandas_nightly: + runs-on: ubuntu-latest + timeout-minutes: 10 + if: (github.event.issue.pull_request) && github.event.comment.body == '/pandas_nightly' + + steps: + - uses: actions/checkout@v4 + + - name: Install project dependencies + uses: ./.github/setup + with: + os: ubuntu-latest + python-version: "3.11" + + - name: Run pytest (against pandas nightly) + id: tests-step + run: poetry run poe pytest --nightly + + - name: Get head sha and store value + if: always() + id: get-sha + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: ${{ github.event.issue.number }} + }) + core.setOutput('sha', pr.data.head.sha) + # + - name: Report results of the tests and publish + if: always() + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.checks.create({ + name: 'Pandas nightly tests', + head_sha: '${{ steps.get-sha.outputs.sha }}', + status: 'completed', + conclusion: '${{ steps.tests-step.outcome }}', + output: { + title: 'Run pandas nightly tests', + summary: 'Results: ${{ steps.tests-step.outcome }}', + text: 'See the actions run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}', + }, + owner: context.repo.owner, + repo: context.repo.repo + }) + + mypy_nightly: + runs-on: ubuntu-latest + timeout-minutes: 10 + if: (github.event.issue.pull_request) && github.event.comment.body == '/mypy_nightly' + + steps: + - uses: actions/checkout@v4 + + - name: Install project dependencies + uses: ./.github/setup + with: + os: ubuntu-latest + python-version: "3.11" + + - name: Run mypy tests with mypy nightly + id: tests-step + run: poetry run poe mypy --mypy_nightly + + - name: Get head sha and store value + if: always() + id: get-sha + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: ${{ github.event.issue.number }} + }) + core.setOutput('sha', pr.data.head.sha) + + - name: Report results of the tests and publish + if: always() + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.checks.create({ + name: 'Mypy nightly tests', + head_sha: '${{ steps.get-sha.outputs.sha }}', + status: 'completed', + conclusion: '${{ steps.tests-step.outcome }}', + output: { + title: 'Run mypy nightly tests', + summary: 'Results: ${{ steps.tests-step.outcome }}', + text: 'See the actions run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}', + }, + owner: context.repo.owner, + repo: context.repo.repo + }) + + pyright_strict: + runs-on: ubuntu-latest + timeout-minutes: 10 + if: (github.event.issue.pull_request) && github.event.comment.body == '/pyright_strict' + + steps: + - uses: actions/checkout@v4 + + - name: Install project dependencies + uses: ./.github/setup + with: + os: ubuntu-latest + python-version: "3.11" + + - name: Run pyright tests with full strict mode + id: tests-step + run: poetry run poe pyright_strict + + - name: Get head sha and store value + if: always() + id: get-sha + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: ${{ github.event.issue.number }} + }) + core.setOutput('sha', pr.data.head.sha) + # + - name: Report results of the tests and publish + if: always() + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.checks.create({ + name: 'Pyright strict tests', + head_sha: '${{ steps.get-sha.outputs.sha }}', + status: 'completed', + conclusion: '${{ steps.tests-step.outcome }}', + output: { + title: 'Run pyright strict tests', + summary: 'Results: ${{ steps.tests-step.outcome }}', + text: 'See the actions run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}', + }, + owner: context.repo.owner, + repo: context.repo.repo + }) diff --git a/.github/workflows/optional.yml b/.github/workflows/optional.yml deleted file mode 100644 index 4cbeccc03..000000000 --- a/.github/workflows/optional.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: 'Optional' - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - nightly: - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v3 - - - name: Install project dependencies - uses: ./.github/setup - with: - os: ubuntu-latest - python-version: '3.11' - - - name: Run pytest (against pandas nightly) - run: poetry run poe pytest --nightly - - mypy_nightly: - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v3 - - - name: Install project dependencies - uses: ./.github/setup - with: - os: ubuntu-latest - python-version: '3.11' - - - name: Run mypy tests with mypy nightly - run: poetry run poe mypy --mypy_nightly - - pyright_strict: - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - uses: actions/checkout@v3 - - - name: Install project dependencies - uses: ./.github/setup - with: - os: ubuntu-latest - python-version: '3.11' - - - name: Run pyright tests with full strict mode - run: poetry run poe pyright_strict From 732a84216761b44e98fdd6e9882c34c9f0243562 Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Mon, 12 Aug 2024 10:18:56 -0700 Subject: [PATCH 2/7] Restore optional.yml --- .github/workflows/optional.yml | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/optional.yml diff --git a/.github/workflows/optional.yml b/.github/workflows/optional.yml new file mode 100644 index 000000000..ffaefefa5 --- /dev/null +++ b/.github/workflows/optional.yml @@ -0,0 +1,56 @@ +name: "Optional" + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + nightly: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v3 + + - name: Install project dependencies + uses: ./.github/setup + with: + os: ubuntu-latest + python-version: "3.11" + + - name: Run pytest (against pandas nightly) + run: poetry run poe pytest --nightly + + mypy_nightly: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v3 + + - name: Install project dependencies + uses: ./.github/setup + with: + os: ubuntu-latest + python-version: "3.11" + + - name: Run mypy tests with mypy nightly + run: poetry run poe mypy --mypy_nightly + + pyright_strict: + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v3 + + - name: Install project dependencies + uses: ./.github/setup + with: + os: ubuntu-latest + python-version: "3.11" + + - name: Run pyright tests with full strict mode + run: poetry run poe pyright_strict From 4eaf6f0e5cb1e7061407a6865ac60eb0b40ab28a Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Mon, 12 Aug 2024 10:20:25 -0700 Subject: [PATCH 3/7] Restore optional.yml --- .github/workflows/optional.yml | 50 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/optional.yml b/.github/workflows/optional.yml index ffaefefa5..4cbeccc03 100644 --- a/.github/workflows/optional.yml +++ b/.github/workflows/optional.yml @@ -1,4 +1,4 @@ -name: "Optional" +name: 'Optional' on: push: @@ -12,45 +12,45 @@ jobs: timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: Install project dependencies - uses: ./.github/setup - with: - os: ubuntu-latest - python-version: "3.11" + - name: Install project dependencies + uses: ./.github/setup + with: + os: ubuntu-latest + python-version: '3.11' - - name: Run pytest (against pandas nightly) - run: poetry run poe pytest --nightly + - name: Run pytest (against pandas nightly) + run: poetry run poe pytest --nightly mypy_nightly: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: Install project dependencies - uses: ./.github/setup - with: - os: ubuntu-latest - python-version: "3.11" + - name: Install project dependencies + uses: ./.github/setup + with: + os: ubuntu-latest + python-version: '3.11' - - name: Run mypy tests with mypy nightly - run: poetry run poe mypy --mypy_nightly + - name: Run mypy tests with mypy nightly + run: poetry run poe mypy --mypy_nightly pyright_strict: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: Install project dependencies - uses: ./.github/setup - with: - os: ubuntu-latest - python-version: "3.11" + - name: Install project dependencies + uses: ./.github/setup + with: + os: ubuntu-latest + python-version: '3.11' - - name: Run pyright tests with full strict mode - run: poetry run poe pyright_strict + - name: Run pyright tests with full strict mode + run: poetry run poe pyright_strict From 83763bd06eb1558de6c8d4a21d7b31905abbbee8 Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Sun, 1 Sep 2024 21:04:28 -0400 Subject: [PATCH 4/7] GH613 Concentrate action in one with selector --- .github/workflows/comment_commands.yml | 123 +++---------------------- 1 file changed, 12 insertions(+), 111 deletions(-) diff --git a/.github/workflows/comment_commands.yml b/.github/workflows/comment_commands.yml index 4adf4ecf8..fa022ed0d 100644 --- a/.github/workflows/comment_commands.yml +++ b/.github/workflows/comment_commands.yml @@ -6,63 +6,16 @@ on: permissions: checks: write -jobs: - pandas_nightly: - runs-on: ubuntu-latest - timeout-minutes: 10 - if: (github.event.issue.pull_request) && github.event.comment.body == '/pandas_nightly' - - steps: - - uses: actions/checkout@v4 - - - name: Install project dependencies - uses: ./.github/setup - with: - os: ubuntu-latest - python-version: "3.11" +env: + RUN_COMMAND: '{"/pandas_nightly": "pytest --nightly", "/pyright_strict": "pyright_strict", "/mypy_nightly": "mypy --mypy_nightly"}' + DISPLAY_COMMAND: '{"/pandas_nightly": "Pandas nightly tests", "/pyright_strict": "Pyright strict tests", "/mypy_nightly": "Mypy nightly tests"}' - - name: Run pytest (against pandas nightly) - id: tests-step - run: poetry run poe pytest --nightly - - - name: Get head sha and store value - if: always() - id: get-sha - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const pr = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: ${{ github.event.issue.number }} - }) - core.setOutput('sha', pr.data.head.sha) - # - - name: Report results of the tests and publish - if: always() - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.checks.create({ - name: 'Pandas nightly tests', - head_sha: '${{ steps.get-sha.outputs.sha }}', - status: 'completed', - conclusion: '${{ steps.tests-step.outcome }}', - output: { - title: 'Run pandas nightly tests', - summary: 'Results: ${{ steps.tests-step.outcome }}', - text: 'See the actions run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}', - }, - owner: context.repo.owner, - repo: context.repo.repo - }) - - mypy_nightly: +jobs: + optional_tests: + name: "Optional tests run" runs-on: ubuntu-latest timeout-minutes: 10 - if: (github.event.issue.pull_request) && github.event.comment.body == '/mypy_nightly' + if: (github.event.issue.pull_request) && contains(fromJSON('["/pandas_nightly", "/pyright_strict", "/mypy_nightly"]'), github.event.comment.body) steps: - uses: actions/checkout@v4 @@ -73,9 +26,9 @@ jobs: os: ubuntu-latest python-version: "3.11" - - name: Run mypy tests with mypy nightly + - name: Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }} id: tests-step - run: poetry run poe mypy --mypy_nightly + run: poetry run poe ${{ fromJSON(env.RUN_COMMAND)[github.event.comment.body] }} - name: Get head sha and store value if: always() @@ -98,66 +51,14 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | github.rest.checks.create({ - name: 'Mypy nightly tests', - head_sha: '${{ steps.get-sha.outputs.sha }}', - status: 'completed', - conclusion: '${{ steps.tests-step.outcome }}', - output: { - title: 'Run mypy nightly tests', - summary: 'Results: ${{ steps.tests-step.outcome }}', - text: 'See the actions run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}', - }, - owner: context.repo.owner, - repo: context.repo.repo - }) - - pyright_strict: - runs-on: ubuntu-latest - timeout-minutes: 10 - if: (github.event.issue.pull_request) && github.event.comment.body == '/pyright_strict' - - steps: - - uses: actions/checkout@v4 - - - name: Install project dependencies - uses: ./.github/setup - with: - os: ubuntu-latest - python-version: "3.11" - - - name: Run pyright tests with full strict mode - id: tests-step - run: poetry run poe pyright_strict - - - name: Get head sha and store value - if: always() - id: get-sha - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const pr = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: ${{ github.event.issue.number }} - }) - core.setOutput('sha', pr.data.head.sha) - # - - name: Report results of the tests and publish - if: always() - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.checks.create({ - name: 'Pyright strict tests', + name: '${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}', head_sha: '${{ steps.get-sha.outputs.sha }}', status: 'completed', conclusion: '${{ steps.tests-step.outcome }}', output: { - title: 'Run pyright strict tests', + title: 'Run ${{ fromJSON(env.DISPLAY_COMMAND)[github.event.comment.body] }}', summary: 'Results: ${{ steps.tests-step.outcome }}', - text: 'See the actions run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}', + text: 'See the actions run at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}', }, owner: context.repo.owner, repo: context.repo.repo From a484f2b62cd205814a3370027b116238c1bbfada Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Mon, 2 Sep 2024 21:55:16 -0400 Subject: [PATCH 5/7] GH613 Adding documentation to tests.md and workflow file --- .github/workflows/comment_commands.yml | 6 ++++++ docs/tests.md | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/comment_commands.yml b/.github/workflows/comment_commands.yml index fa022ed0d..6a348673e 100644 --- a/.github/workflows/comment_commands.yml +++ b/.github/workflows/comment_commands.yml @@ -7,7 +7,9 @@ permissions: checks: write env: + # store mapping of commands to use with poetry RUN_COMMAND: '{"/pandas_nightly": "pytest --nightly", "/pyright_strict": "pyright_strict", "/mypy_nightly": "mypy --mypy_nightly"}' + # store mapping of labels to display in the check runs DISPLAY_COMMAND: '{"/pandas_nightly": "Pandas nightly tests", "/pyright_strict": "Pyright strict tests", "/mypy_nightly": "Mypy nightly tests"}' jobs: @@ -15,6 +17,7 @@ jobs: name: "Optional tests run" runs-on: ubuntu-latest timeout-minutes: 10 + # if more commends are added, they will need to be added here too as we don't have avvecc to env at this stage if: (github.event.issue.pull_request) && contains(fromJSON('["/pandas_nightly", "/pyright_strict", "/mypy_nightly"]'), github.event.comment.body) steps: @@ -27,10 +30,12 @@ jobs: 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 + # get the sha of the last commit to attach the results of the tests if: always() id: get-sha uses: actions/github-script@v7 @@ -45,6 +50,7 @@ jobs: core.setOutput('sha', pr.data.head.sha) - name: Report results of the tests and publish + # publish the results to a check run no matter the pass or fail if: always() uses: actions/github-script@v7 with: diff --git a/docs/tests.md b/docs/tests.md index fdf2dd5e8..3b8984e0f 100644 --- a/docs/tests.md +++ b/docs/tests.md @@ -5,7 +5,7 @@ Here are the most important options. Fore more details, please use `poe --help`. - Run all tests (against both source and installed stubs): `poe test_all` -- Run tests against the source code: `poe test` +- Run tests against the source code: `poe test` - Run only mypy: `poe mypy` - Run only pyright: `poe pyright` - Run only pytest: `poe pytest` @@ -20,3 +20,9 @@ The following tests are **optional**. Some of them are run by the CI but it is o - Use mypy nightly to validate the annotations: `poe mypy --mypy_nightly` - Use pyright in full strict mode: `poe pyright_strict` - Run stubtest to compare the installed pandas-stubs against pandas (this will fail): `poe stubtest`. If you have created an allowlist to ignore certain errors: `poe stubtest path_to_the_allow_list` + +Among the tests above, the following can be run directly during a PR by commenting in the discussion. + +- Run pytest against pandas nightly by commenting `\pandas_nightly` +- Use mypy nightly to validate the annotations by commenting `\mypy_nightly` +- Use pyright in full strict mode by commenting `\pyright_strict` From e959636e3677ad33e4343c85322aeff448e87295 Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Mon, 2 Sep 2024 22:14:53 -0400 Subject: [PATCH 6/7] Fix typo in workflow file --- .github/workflows/comment_commands.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment_commands.yml b/.github/workflows/comment_commands.yml index 6a348673e..3dbc97a42 100644 --- a/.github/workflows/comment_commands.yml +++ b/.github/workflows/comment_commands.yml @@ -17,7 +17,7 @@ jobs: name: "Optional tests run" runs-on: ubuntu-latest timeout-minutes: 10 - # if more commends are added, they will need to be added here too as we don't have avvecc to env at this stage + # if more commands are added, they will need to be added here too as we don't have avvecc to env at this stage if: (github.event.issue.pull_request) && contains(fromJSON('["/pandas_nightly", "/pyright_strict", "/mypy_nightly"]'), github.event.comment.body) steps: From 1686d67ad59aaa90e9ca9789787a832cfe45a398 Mon Sep 17 00:00:00 2001 From: Loic Diridollou Date: Tue, 3 Sep 2024 17:53:40 -0400 Subject: [PATCH 7/7] PR feedback --- .github/workflows/comment_commands.yml | 2 +- docs/tests.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/comment_commands.yml b/.github/workflows/comment_commands.yml index 3dbc97a42..c85cdca8e 100644 --- a/.github/workflows/comment_commands.yml +++ b/.github/workflows/comment_commands.yml @@ -17,7 +17,7 @@ jobs: name: "Optional tests run" runs-on: ubuntu-latest timeout-minutes: 10 - # if more commands are added, they will need to be added here too as we don't have avvecc to env at this stage + # if more commands are added, they will need to be added here too as we don't have access to env at this stage if: (github.event.issue.pull_request) && contains(fromJSON('["/pandas_nightly", "/pyright_strict", "/mypy_nightly"]'), github.event.comment.body) steps: diff --git a/docs/tests.md b/docs/tests.md index 3b8984e0f..4101bc83e 100644 --- a/docs/tests.md +++ b/docs/tests.md @@ -23,6 +23,6 @@ The following tests are **optional**. Some of them are run by the CI but it is o Among the tests above, the following can be run directly during a PR by commenting in the discussion. -- Run pytest against pandas nightly by commenting `\pandas_nightly` -- Use mypy nightly to validate the annotations by commenting `\mypy_nightly` -- Use pyright in full strict mode by commenting `\pyright_strict` +- Run pytest against pandas nightly by commenting `/pandas_nightly` +- Use mypy nightly to validate the annotations by commenting `/mypy_nightly` +- Use pyright in full strict mode by commenting `/pyright_strict`