|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + strategy: |
| 8 | + fail-fast: false |
| 9 | + matrix: |
| 10 | + python-version: ["3.7", "3.8", "3.9", "3.10"] |
| 11 | + django-version: ["2.2", "3.2", "4.0"] |
| 12 | + grappelli: ["0"] |
| 13 | + exclude: |
| 14 | + - python-version: "3.7" |
| 15 | + django-version: "4.0" |
| 16 | + - python-version: "3.10" |
| 17 | + django-version: "2.2" |
| 18 | + # Exclude some version combos that don't need to be tested (since |
| 19 | + # the combination of python and django versions is unlikely to |
| 20 | + # be germane to django-nested-admin) |
| 21 | + - python-version: "3.8" |
| 22 | + django-version: "3.2" |
| 23 | + - python-version: "3.9" |
| 24 | + django-version: "4.0" |
| 25 | + include: |
| 26 | + - grappelli: "0" |
| 27 | + name-suffix: "" |
| 28 | + - grappelli: "1" |
| 29 | + name-suffix: " + grappelli" |
| 30 | + python-version: "3.7" |
| 31 | + django-version: "2.2" |
| 32 | + - grappelli: "1" |
| 33 | + name-suffix: " + grappelli" |
| 34 | + python-version: "3.10" |
| 35 | + django-version: "3.2" |
| 36 | + |
| 37 | + runs-on: ubuntu-latest |
| 38 | + name: Django ${{ matrix.django-version }} (Python ${{ matrix.python-version }})${{ matrix.name-suffix }} |
| 39 | + |
| 40 | + env: |
| 41 | + DJANGO: ${{ matrix.django-version }} |
| 42 | + GRAPPELLI: ${{ matrix.grappelli }} |
| 43 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 44 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 45 | + NODE_ENV: test |
| 46 | + |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v2 |
| 49 | + |
| 50 | + - name: Set up Python ${{ matrix.python-version }} |
| 51 | + uses: actions/setup-python@v2 |
| 52 | + with: |
| 53 | + python-version: ${{ matrix.python-version }} |
| 54 | + |
| 55 | + - name: Setup chromedriver |
| 56 | + uses: nanasess/setup-chromedriver@v1.0.5 |
| 57 | + |
| 58 | + - name: Install tox |
| 59 | + run: | |
| 60 | + python3 -m pip install tox tox-gh-actions |
| 61 | +
|
| 62 | + - name: Cache instrumented static files |
| 63 | + id: cache-test-dist |
| 64 | + uses: actions/cache@v2 |
| 65 | + with: |
| 66 | + path: nested_admin/tests/static |
| 67 | + key: test-dist-${{ hashFiles('package-lock.json', '.github/workflows/test.yml', 'webpack.config.js', 'package.json', '.*rc*', 'frontend/**') }} |
| 68 | + |
| 69 | + - name: Cache node_modules |
| 70 | + id: cache-node_modules |
| 71 | + uses: actions/cache@v2 |
| 72 | + with: |
| 73 | + path: node_modules |
| 74 | + key: node_modules-${{ hashFiles('package-lock.json') }} |
| 75 | + |
| 76 | + - name: Setup nodejs 12 |
| 77 | + if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true' |
| 78 | + uses: actions/setup-node@v2 |
| 79 | + with: |
| 80 | + node-version: '12' |
| 81 | + |
| 82 | + - name: npm ci |
| 83 | + if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true' |
| 84 | + run: | |
| 85 | + npm ci || npm ci || npm ci |
| 86 | +
|
| 87 | + - name: Build instrumented static files |
| 88 | + if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true' |
| 89 | + run: | |
| 90 | + npm run build |
| 91 | +
|
| 92 | + - name: Run tests |
| 93 | + run: | |
| 94 | + tox -- -vvv --selenosis-driver=chrome-headless --numprocesses=4 --exitfirst || \ |
| 95 | + tox -- -vvv --selenosis-driver=chrome-headless |
| 96 | + env: |
| 97 | + PIXELMATCH_BIN: ${{ env.GITHUB_WORKSPACE }}/node_modules/.bin/pixelmatch |
| 98 | + |
| 99 | + - name: Upload junit xml |
| 100 | + if: always() |
| 101 | + uses: actions/upload-artifact@v2 |
| 102 | + with: |
| 103 | + name: junit-reports |
| 104 | + path: reports/*.xml |
| 105 | + |
| 106 | + - name: Upload python coverage |
| 107 | + run: | |
| 108 | + tox -e coverage-report |
| 109 | + tox -e codecov |
| 110 | + env: |
| 111 | + CODECOV_NAME: ${{ github.workflow }} |
| 112 | + |
| 113 | + - name: Upload js coverage |
| 114 | + run: npm run report && npm run codecov |
| 115 | + env: |
| 116 | + CODECOV_NAME: ${{ github.workflow }} |
| 117 | + |
| 118 | + report: |
| 119 | + if: always() |
| 120 | + needs: build |
| 121 | + runs-on: ubuntu-latest |
| 122 | + name: "Report Test Results" |
| 123 | + steps: |
| 124 | + - uses: actions/download-artifact@v2 |
| 125 | + with: |
| 126 | + name: junit-reports |
| 127 | + |
| 128 | + - name: Publish tests report |
| 129 | + uses: mikepenz/action-junit-report@5703ba1461f35871cde0208140d737d3e1eef38f |
| 130 | + with: |
| 131 | + report_paths: ./*.xml |
| 132 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 133 | + require_tests: true |
| 134 | + fail_on_failure: true |
| 135 | + check_name: Test Report |
| 136 | + |
| 137 | + success: |
| 138 | + needs: report |
| 139 | + runs-on: ubuntu-latest |
| 140 | + name: Test Successful |
| 141 | + steps: |
| 142 | + - name: Success |
| 143 | + run: echo Test Successful |
0 commit comments