|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +jobs: |
| 12 | + changes: |
| 13 | + name: "Check for changes" |
| 14 | + runs-on: ubuntu-latest |
| 15 | + outputs: |
| 16 | + changes: ${{ steps.changes.outputs.src }} |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v2 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + - uses: dorny/paths-filter@v2 |
| 22 | + id: changes |
| 23 | + with: |
| 24 | + filters: | |
| 25 | + python: &python |
| 26 | + - 'kanren/**/*.py' |
| 27 | + - 'tests/**/*.py' |
| 28 | + - '*.py' |
| 29 | + src: |
| 30 | + - *python |
| 31 | + - '.github/**/*.yml' |
| 32 | + - 'setup.cfg' |
| 33 | + - 'requirements.txt' |
| 34 | + - '.coveragerc' |
| 35 | + - '.pre-commit-config.yaml' |
| 36 | +
|
| 37 | + style: |
| 38 | + name: Check code style |
| 39 | + needs: changes |
| 40 | + runs-on: ubuntu-latest |
| 41 | + if: ${{ needs.changes.outputs.changes == 'true' }} |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v2 |
| 44 | + - uses: actions/setup-python@v2 |
| 45 | + with: |
| 46 | + python-version: 3.8 |
| 47 | + - uses: pre-commit/[email protected] |
| 48 | + |
| 49 | + test: |
| 50 | + needs: |
| 51 | + - changes |
| 52 | + - style |
| 53 | + runs-on: ubuntu-latest |
| 54 | + if: ${{ needs.changes.outputs.changes == 'true' && needs.style.result == 'success' }} |
| 55 | + strategy: |
| 56 | + matrix: |
| 57 | + python-version: |
| 58 | + - 3.6 |
| 59 | + - 3.7 |
| 60 | + - 3.8 |
| 61 | + - pypy3 |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v2 |
| 64 | + - uses: actions/setup-python@v2 |
| 65 | + with: |
| 66 | + python-version: ${{ matrix.python-version }} |
| 67 | + - name: Install dependencies |
| 68 | + run: | |
| 69 | + python -m pip install --upgrade pip |
| 70 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 71 | + - name: Test with pytest |
| 72 | + run: | |
| 73 | + pytest -v tests/ --cov=kanren --cov-report=xml:./coverage.xml |
| 74 | + - name: Coveralls |
| 75 | + uses: AndreMiras/coveralls-python-action@develop |
| 76 | + with: |
| 77 | + parallel: true |
| 78 | + flag-name: run-${{ matrix.python-version }} |
| 79 | + |
| 80 | + all-checks: |
| 81 | + if: ${{ always() }} |
| 82 | + runs-on: ubuntu-latest |
| 83 | + name: "All tests" |
| 84 | + needs: [changes, style, test] |
| 85 | + steps: |
| 86 | + - name: Check build matrix status |
| 87 | + if: ${{ needs.changes.outputs.changes == 'true' && (needs.style.result != 'success' || needs.test.result != 'success') }} |
| 88 | + run: exit 1 |
| 89 | + |
| 90 | + upload-coverage: |
| 91 | + name: "Upload coverage" |
| 92 | + needs: [changes, all-checks] |
| 93 | + if: ${{ needs.changes.outputs.changes == 'true' && needs.all-checks.result == 'success' }} |
| 94 | + runs-on: ubuntu-latest |
| 95 | + steps: |
| 96 | + - name: Coveralls Finished |
| 97 | + uses: AndreMiras/coveralls-python-action@develop |
| 98 | + with: |
| 99 | + parallel-finished: true |
0 commit comments