[Feat] Async tests #4290
This file contains hidden or 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
| name: Python | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| schedule: | |
| - cron: "0 8 * * *" | |
| concurrency: | |
| group: check-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: test with ${{ matrix.py }} on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| py: | |
| - "3.13" | |
| - "3.12" | |
| - "3.11" | |
| - "3.10" | |
| - "3.9" | |
| - "3.8" | |
| os: | |
| - ubuntu-latest | |
| - macos-latest | |
| - windows-latest | |
| async: | |
| - true | |
| - false | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup python for test ${{ matrix.py }} | |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
| with: | |
| python-version: ${{ matrix.py }} | |
| - name: Install tox | |
| run: python -m pip install "tox-gh>=1.2" poetry | |
| - name: Setup test suite | |
| run: tox -vv --notest | |
| - name: Run test suite | |
| run: tox --skip-pkg-install | |
| env: | |
| COVERAGE_FILE: "coverage.${{ matrix.os }}.${{ matrix.py }}.${{matrix.async}}" | |
| ASYNC_MODE: ${{matrix.async}} | |
| - name: Store coverage file | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: "coverage.${{ matrix.os }}.${{ matrix.py }}.${{matrix.async}}" | |
| path: "coverage.${{ matrix.os }}.${{ matrix.py }}.${{matrix.async}}" | |
| if-no-files-found: error | |
| coverage: | |
| if: github.event_name != 'schedule' | |
| name: Coverage | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| pull-requests: write | |
| contents: write | |
| env: | |
| COVERAGE_FILE: "coverage" | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | |
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| id: download | |
| with: | |
| pattern: coverage.* | |
| merge-multiple: true | |
| - name: Setup Python for coverage | |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
| with: | |
| python-version: "3.13" | |
| - name: Install coverage | |
| run: python -m pip install "coverage[toml]>=7.3.1" | |
| - name: Combine coverage files | |
| run: | | |
| coverage combine coverage.* | |
| coverage report | |
| - name: Coverage comment | |
| id: coverage_comment | |
| uses: py-cov-action/python-coverage-comment-action@b3d7e98bf5528b07d6951ef7a93e2b156f960112 # v3.1.0 | |
| with: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| MERGE_COVERAGE_FILES: false | |
| ANNOTATE_MISSING_LINES: true | |
| VERBOSE: true | |
| - name: Store Pull Request comment to be posted | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' | |
| with: | |
| name: python-coverage-comment-action | |
| path: python-coverage-comment-action.txt | |
| gitleaks: | |
| name: gitleaks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | |
| with: | |
| fetch-depth: 0 | |
| - uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2.3.9 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }} |