|
| 1 | +name: ci-tests-python |
| 2 | +on: |
| 3 | + push: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +env: |
| 9 | + ############################################################################## |
| 10 | + # Please fill in: |
| 11 | + # (Ref. https://docs.github.com/en/github-ae@latest/actions/learn-github-actions/variables) |
| 12 | + ############################################################################## |
| 13 | + # Target python version intended to use to run tests into. Defaults to 3.10.2 |
| 14 | + ############################################################################## |
| 15 | + TARGET_PYTHON_VERSION: 3.10.2 |
| 16 | + ############################################################################## |
| 17 | + # Target folder where tests reside. Defaults to "tests" |
| 18 | + ############################################################################## |
| 19 | + TESTS_DIRECTORY: tests |
| 20 | + ############################################################################## |
| 21 | + |
| 22 | +jobs: |
| 23 | + run_unit_tests: |
| 24 | + ############################################################################ |
| 25 | + # Please fill in with the Runner(s) in which to execute this action |
| 26 | + # Ref. https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow |
| 27 | + # Ref. https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners |
| 28 | + ############################################################################ |
| 29 | + runs-on: ubuntu-20.04 |
| 30 | + ############################################################################ |
| 31 | + |
| 32 | + ############################################################################ |
| 33 | + # Minimum permissions required by EnricoMi/publish-unit-test-result-action@v2 |
| 34 | + # Ref. https://github.com/EnricoMi/publish-unit-test-result-action#support-fork-repositories-and-dependabot-branches |
| 35 | + ############################################################################ |
| 36 | + permissions: |
| 37 | + contents: read |
| 38 | + issues: read |
| 39 | + checks: write |
| 40 | + pull-requests: write |
| 41 | + |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v3 |
| 44 | + |
| 45 | + - name: Setup Python |
| 46 | + uses: actions/setup-python@v4 |
| 47 | + with: |
| 48 | + python-version: {{ '${{ env.TARGET_PYTHON_VERSION }}' }} |
| 49 | + |
| 50 | + - name: Install poetry |
| 51 | + run: | |
| 52 | + python -m pip install pipx && python -m pipx install poetry |
| 53 | +
|
| 54 | + - name: Configure poetry |
| 55 | + run: | |
| 56 | + poetry config virtualenvs.in-project true |
| 57 | +
|
| 58 | + - name: Cache the virtualenv |
| 59 | + uses: actions/cache@v3 |
| 60 | + with: |
| 61 | + path: ./.venv |
| 62 | + key: {{ '${{ runner.os }}' }}-venv-{{ '${{ hashFiles(\'**/poetry.lock\') }}' }} |
| 63 | + |
| 64 | + - name: Install dependencies |
| 65 | + run: | |
| 66 | + poetry install |
| 67 | +
|
| 68 | + - name: Run tests |
| 69 | + run: | |
| 70 | + poetry run python -m pytest {{ '${{ env.TESTS_DIRECTORY }}' }} --doctest-modules --junit-xml=junit/ci-result-junit.xml |
| 71 | +
|
| 72 | + - name: Publish Unit Test Results |
| 73 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
| 74 | + if: success() |
| 75 | + with: |
| 76 | + files: junit/ci-result-junit.xml |
| 77 | + action_fail: true |
| 78 | + action_fail_on_inconclusive: true |
0 commit comments