|
| 1 | +name: maya tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + workflow_dispatch: # Manual trigger |
| 6 | + |
| 7 | +jobs: |
| 8 | + collect_tests: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + outputs: |
| 11 | + tests_collected: ${{ steps.check_tests.outputs.tests_collected }} |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + - name: Set up Python |
| 15 | + uses: actions/setup-python@v5 |
| 16 | + with: |
| 17 | + python-version: '3.x' |
| 18 | + |
| 19 | + - name: Install dependencies |
| 20 | + run: | |
| 21 | + python -m pip install --upgrade pip |
| 22 | + pip install pytest |
| 23 | +
|
| 24 | + - name: Check for tests |
| 25 | + id: check_tests |
| 26 | + run: | |
| 27 | + #!/bin/bash |
| 28 | + set +e # Disable exit on error |
| 29 | + pytest --collect-only |
| 30 | + exit_code=$? |
| 31 | + set -e # Re-enable exit on error |
| 32 | + |
| 33 | + if [ $exit_code -eq 5 ]; then |
| 34 | + echo "tests_collected=0" >> $GITHUB_OUTPUT |
| 35 | + echo "No tests were collected." |
| 36 | + else |
| 37 | + collected=$(pytest --collect-only | grep -oP 'collected \K\d+') |
| 38 | + echo "tests_collected=$collected" >> $GITHUB_OUTPUT |
| 39 | + echo "Collected $collected tests." |
| 40 | + fi |
| 41 | +
|
| 42 | + no_tests_found: |
| 43 | + needs: collect_tests |
| 44 | + if: needs.collect_tests.outputs.tests_collected == '0' |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - name: No tests found |
| 48 | + run: echo "No tests were collected. Skipping test execution." |
| 49 | + |
| 50 | + |
| 51 | + maya: |
| 52 | + needs: collect_tests |
| 53 | + if: needs.collect_tests.outputs.tests_collected != '0' |
| 54 | + runs-on: ubuntu-latest |
| 55 | + |
| 56 | + strategy: |
| 57 | + |
| 58 | + fail-fast: false |
| 59 | + |
| 60 | + matrix: |
| 61 | + # add or remove versions as needed, a job per version will be created |
| 62 | + # supported tags here: https://github.com/mottosso/docker-maya/ |
| 63 | + maya_version: ["2024",] |
| 64 | + |
| 65 | + container: mottosso/maya:${{ matrix.maya_version }} # ty mottosso! |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Checkout code |
| 69 | + uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - name: Install dependencies |
| 72 | + run: | |
| 73 | + mayapy -m pip install --upgrade pip |
| 74 | + mayapy -m pip install pip-tools |
| 75 | + pip-compile requirements.in |
| 76 | + pip-compile requirements-test.in |
| 77 | + mayapy -m pip install --user -r requirements-test.txt |
| 78 | +
|
| 79 | + - name: Set Maya environment variables |
| 80 | + run: | |
| 81 | + export XDG_RUNTIME_DIR=/var/tmp/runtime-root |
| 82 | + export MAYA_DISABLE_ADP=1 |
| 83 | +
|
| 84 | + - name: Run tests |
| 85 | + run: mayapy -m pytest tests |
0 commit comments