|
| 1 | +# |
| 2 | +# The reviewdog workflow steps use reporter: github-pr-review, |
| 3 | +# which submits mypy and pylint warnings using review comment |
| 4 | +# on the pull request. It needs write permissions for the pull request |
| 5 | +# to post the comments and can only be used in the context of a pull request. |
| 6 | +# |
| 7 | +name: mypy, pylint and coverage PR review comments |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_run: |
| 11 | + workflows: ["Trigger PR review"] # The name of the triggering workflow in main.yml |
| 12 | + types: [in_progress] |
| 13 | + |
| 14 | +concurrency: # Cancel old workflows with same triggering workflow, repository and branch: |
| 15 | + group: ${{ github.workflow }}-${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + pull-requests: write |
| 21 | + |
| 22 | +jobs: |
| 23 | + mypy-pylint-comments: |
| 24 | + if: github.event.workflow_run.event == 'pull_request' |
| 25 | + runs-on: ubuntu-22.04 |
| 26 | + env: |
| 27 | + GITHUB_EVENT_PATH: event.json |
| 28 | + GITHUB_EVENT_NAME: ${{ github.event.workflow_run.event }} |
| 29 | + GITHUB_SHA: ${{ github.event.workflow_run.head_sha }} |
| 30 | + steps: |
| 31 | + - run: | |
| 32 | + echo "Triggered repo: ${{ github.event.workflow_run.head_repository.full_name }}" |
| 33 | + - run: | |
| 34 | + echo "Triggered by: ${{ github.event.workflow_run.event }}" |
| 35 | + - run: | |
| 36 | + echo "SHA of triggering workflow: ${{ github.event.workflow_run.head_sha }}" |
| 37 | + - name: EVENT_PATH is ${{ env.GITHUB_EVENT_PATH }}/${{ env.GITHUB_EVENT_NAME}}, SHA is ${{ env.GITHUB_SHA }} |
| 38 | + run: echo "GITHUB_SHA=$GITHUB_SHA" |
| 39 | + # env: |
| 40 | + # GITHUB_SHA: ${{ github.event.workflow_run.head_sha }} |
| 41 | + |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + repository: ${{ github.event.workflow_run.head_repository.full_name }} |
| 45 | + ref: ${{ github.event.workflow_run.head_sha }} |
| 46 | + |
| 47 | + - run: cat ${GITHUB_EVENT_PATH} |
| 48 | + |
| 49 | + - uses: actions/setup-python@v5 |
| 50 | + with: |
| 51 | + python-version: 3.11 |
| 52 | + |
| 53 | + - name: Install uv and activate the environment |
| 54 | + uses: astral-sh/setup-uv@v6 |
| 55 | + with: |
| 56 | + activate-environment: true |
| 57 | + |
| 58 | + - name: Run tox to run pytest in the defined tox environments |
| 59 | + run: | |
| 60 | + uv pip install pylint tox types-setuptools -r pyproject.toml --extra mypy; |
| 61 | + tox -e py311-covcp |
| 62 | + continue-on-error: true |
| 63 | + env: |
| 64 | + DIFF_COVERAGE_MIN: 0 # reviewdog-action-code-coverage shows coverage |
| 65 | + |
| 66 | + - name: Download PR event payload |
| 67 | + uses: actions/download-artifact@v4 |
| 68 | + with: |
| 69 | + name: pr-event |
| 70 | + |
| 71 | + - uses: tsuyoshicho/action-mypy@v4 |
| 72 | + name: Run mypy with reviewdog to submit GitHub checks for warnings |
| 73 | + with: |
| 74 | + install_types: false |
| 75 | + reporter: github-pr-review |
| 76 | + level: warning |
| 77 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + |
| 79 | + - uses: dciborow/[email protected] |
| 80 | + name: Run pylint with reviewdog to submit GitHub checks for warnings |
| 81 | + with: |
| 82 | + reporter: github-pr-review |
| 83 | + glob_pattern: "xcp tests" |
| 84 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + |
| 86 | + - uses: aki77/reviewdog-action-code-coverage@v2 |
| 87 | + with: |
| 88 | + lcov_path: coverage.lcov |
| 89 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments