|
| 1 | +name: pytest |
| 2 | +on: push |
| 3 | +jobs: |
| 4 | + run_pytest: |
| 5 | + name: run-tests (${{ matrix.python-version }}, ${{ matrix.os }}) |
| 6 | + runs-on: ${{ matrix.os }} |
| 7 | + defaults: |
| 8 | + run: |
| 9 | + shell: bash -l {0} |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + python-version: ["3.11", "3.12","3.13"] |
| 14 | + os: ["ubuntu-latest"] |
| 15 | + steps: |
| 16 | + - name: Check out repository code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + - name: Install Conda environment with Micromamba |
| 19 | + uses: conda-incubator/setup-miniconda@v3 |
| 20 | + with: |
| 21 | + environment-file: tests/test-env.yml |
| 22 | + python: ${{ matrix.python-version }} |
| 23 | + channels: conda-forge,phygbu |
| 24 | + channel-priority: flexible |
| 25 | + activate-environment: test-environment |
| 26 | + auto-activate-base: false |
| 27 | + - name: Conda information |
| 28 | + run: | |
| 29 | + conda info |
| 30 | + conda list |
| 31 | + conda config --show-sources |
| 32 | + conda config --show |
| 33 | + - name: install package |
| 34 | + run: pip install --no-deps . |
| 35 | + - name: Install headless server |
| 36 | + run: | |
| 37 | + sudo apt-get update |
| 38 | + sudo apt-get install xvfb |
| 39 | + sudo apt-get install qtbase5-dev |
| 40 | + - name: Test with xvfb |
| 41 | + run: | |
| 42 | + xvfb-run --auto-servernum /usr/share/miniconda/envs/test-environment/bin/pytest -n 2 --cov-report= --cov=Stoner --junitxml pytest.xml |
| 43 | + coverage xml |
| 44 | + env: |
| 45 | + TZ: Europe/London |
| 46 | + LC_CTYPE: en_GB.UTF-8 |
| 47 | + GH_ACTION: True |
| 48 | + - name: Cleanup X11 server |
| 49 | + uses: bcomnes/cleanup-xvfb@v1 |
| 50 | + - name: Coveralls Parallel |
| 51 | + uses: coverallsapp/github-action@v2 |
| 52 | + with: |
| 53 | + flag-name: run-${{ join(matrix.*, '-') }} |
| 54 | + format: cobertura |
| 55 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + - name: Upload Unit Test Results |
| 57 | + if: always() |
| 58 | + uses: actions/upload-artifact@v4 |
| 59 | + with: |
| 60 | + name: Unit Test Results (Python ${{ matrix.python-version }}) |
| 61 | + path: pytest.xml |
| 62 | + - name: Post Coveraage result to Codacy |
| 63 | + run: | |
| 64 | + export CODACY_PROJECT_TOKEN=${{ secrets.CODACY_PROJECT_TOKEN }} |
| 65 | + bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage.xml |
| 66 | +
|
| 67 | + publish-test-results: |
| 68 | + name: "Publish Unit Tests Results" |
| 69 | + needs: run_pytest |
| 70 | + runs-on: ubuntu-latest |
| 71 | + if: always() |
| 72 | + |
| 73 | + steps: |
| 74 | + - name: Download Artifacts |
| 75 | + uses: actions/download-artifact@v4 |
| 76 | + with: |
| 77 | + path: artifacts |
| 78 | + |
| 79 | + - name: Publish Unit Test Results |
| 80 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
| 81 | + with: |
| 82 | + files: artifacts/**/*.xml |
| 83 | + |
| 84 | + coverage-finish: |
| 85 | + needs: run_pytest |
| 86 | + runs-on: ubuntu-latest |
| 87 | + steps: |
| 88 | + - name: Coveralls Finished |
| 89 | + uses: coverallsapp/github-action@v2 |
| 90 | + with: |
| 91 | + parallel-finished: true |
| 92 | + carryforward: "run-1,run-2" |
0 commit comments