|
| 1 | +# Install package from a given source and run unit-tests. |
| 2 | +# Install the package and run tests on a matrix of supported Python versions and operating systems. |
| 3 | + |
| 4 | +name: '[Reusable]: Package - Test' |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + inputs: |
| 9 | + config: |
| 10 | + type: string |
| 11 | + required: true |
| 12 | + description: Configuration as a JSON string. |
| 13 | + |
| 14 | +jobs: |
| 15 | + test: |
| 16 | + name: ${{ matrix.task.name }} |
| 17 | + permissions: |
| 18 | + id-token: write # For token-less upload of coverage reports to Codecov. |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + task: ${{ fromJSON(inputs.config).tasks }} |
| 23 | + runs-on: ${{ matrix.task.runner }} |
| 24 | + steps: |
| 25 | + - name: Repository Checkout |
| 26 | + if: (fromJSON(inputs.config).test-src != 'pypi') || (fromJSON(inputs.config).pkg-src != 'pypi') |
| 27 | + uses: actions/checkout@v4 # https://github.com/actions/checkout |
| 28 | + with: |
| 29 | + repository: ${{ fromJSON(inputs.config).repository }} |
| 30 | + ref: ${{ fromJSON(inputs.config).ref }} |
| 31 | + fetch-tags: true |
| 32 | + path: repo |
| 33 | + - uses: RepoDynamics/PyTester@v1 |
| 34 | + with: |
| 35 | + python-version: ${{ matrix.task.python }} |
| 36 | + test-src: ${{ fromJSON(inputs.config).test-src }} |
| 37 | + test-path: ${{ fromJSON(inputs.config).test-path }} |
| 38 | + test-name: ${{ fromJSON(inputs.config).test-name }} |
| 39 | + test-version: ${{ fromJSON(inputs.config).test-version }} |
| 40 | + test-req-path: ${{ fromJSON(inputs.config).test-req-path }} |
| 41 | + pkg-src: ${{ fromJSON(inputs.config).pkg-src }} |
| 42 | + pkg-path: ${{ fromJSON(inputs.config).pkg-path }} |
| 43 | + pkg-name: ${{ fromJSON(inputs.config).pkg-name }} |
| 44 | + pkg-version: ${{ fromJSON(inputs.config).pkg-version }} |
| 45 | + pkg-req-path: ${{ fromJSON(inputs.config).pkg-req-path }} |
| 46 | + retries: ${{ fromJSON(inputs.config).retries }} |
| 47 | + retry-sleep-seconds: ${{ fromJSON(inputs.config).retry-sleep-seconds }} |
| 48 | + pyargs: ${{ fromJSON(inputs.config).pyargs }} |
| 49 | + args: ${{ fromJSON(inputs.config).args }} |
| 50 | + overrides: ${{ fromJSON(inputs.config).overrides }} |
| 51 | + - name: uname |
| 52 | + run: uname -a |
| 53 | + - name: Report Upload |
| 54 | + if: ${{ !cancelled() }} |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: ${{ matrix.task.artifact.report.name }} |
| 58 | + path: report |
| 59 | + - name: CodeCov Upload |
| 60 | + if: ${{ !cancelled() && fromJSON(inputs.config).upload-codecov }} |
| 61 | + # https://github.com/marketplace/actions/codecov |
| 62 | + # https://github.com/codecov/codecov-action |
| 63 | + env: |
| 64 | + OS: ${{ runner.os }} |
| 65 | + PYTHON: ${{ matrix.task.python }} |
| 66 | + uses: codecov/codecov-action@v4 |
| 67 | + with: |
| 68 | + # TODO: Check that env_vars are correctly set. (https://github.com/codecov/codecov-action/pull/64) |
| 69 | + codecov_yml_path: repo/${{ fromJSON(inputs.config).codecov-yml-path }} |
| 70 | + directory: report |
| 71 | + env_vars: OS,PYTHON |
| 72 | + fail_ci_if_error: false |
| 73 | + root_dir: repo |
| 74 | + use_oidc: true # https://github.com/codecov/codecov-action/issues/1489#issuecomment-2197308411 |
| 75 | + verbose: true |
| 76 | + report: |
| 77 | + name: Report |
| 78 | + if: ${{ !cancelled() && fromJSON(inputs.config).artifact.report.merge }} |
| 79 | + needs: test |
| 80 | + runs-on: ubuntu-latest |
| 81 | + steps: |
| 82 | + - name: Artifact Merge |
| 83 | + uses: actions/upload-artifact/merge@v4 |
| 84 | + with: |
| 85 | + name: ${{ fromJSON(inputs.config).artifact.report.merge.name }} |
| 86 | + pattern: ${{ fromJSON(inputs.config).artifact.report.merge.pattern }} |
| 87 | + include-hidden-files: ${{ fromJSON(inputs.config).artifact.report.include-hidden }} |
| 88 | + retention-days: ${{ fromJSON(inputs.config).artifact.report.retention-days }} |
| 89 | + separate-directories: 'true' |
| 90 | + delete-merged: 'true' |
0 commit comments