|
1 |
| -name: Testing pipeline |
| 1 | +name: Typecheck & run tests |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - 'main'
|
7 | 7 | - 'feature/*'
|
8 | 8 | - 'bugfix/*'
|
| 9 | + issue_comment: |
| 10 | + types: [created] |
9 | 11 |
|
10 | 12 | jobs:
|
11 |
| - sanity-run: |
| 13 | + get-main-ref: |
12 | 14 | runs-on: ubuntu-latest
|
13 |
| - name: Run tests on lowest supported Python version on Ubuntu as a sanity-check before doing anything else |
| 15 | + name: Get ref to check out (based on branch or PR) |
| 16 | + steps: |
| 17 | + - name: Get PR's branch name |
| 18 | + id: from-pr |
| 19 | + if: ${{ contains(github.event.comment.html_url, '/pull/') }} |
| 20 | + run: | |
| 21 | + PR=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" ${{ github.event.issue.pull_request.url }}) |
| 22 | + echo "branch=$(echo $PR | jq -r '.head.ref')" >> "$GITHUB_OUTPUT" |
| 23 | + echo "onPR=true" >> "$GITHUB_OUTPUT" |
| 24 | + - name: Get current branch name |
| 25 | + id: from-branch |
| 26 | + if: ${{ !contains(github.event.comment.html_url, '/pull/') }} |
| 27 | + run: | |
| 28 | + echo "branch=${{ github.head_ref || github.ref_name }}" >> "$GITHUB_OUTPUT" |
| 29 | + echo "onPR=false" >> "$GITHUB_OUTPUT" |
| 30 | + outputs: |
| 31 | + branch: ${{ steps.from-pr.outputs.branch || steps.from-branch.outputs.branch }} |
| 32 | + onPR: ${{ steps.from-pr.output.onPR || steps.from-branch.outputs.onPR }} |
| 33 | + |
| 34 | + coverage: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + name: Run tests on lowest supported Python version on Ubuntu |
| 37 | + needs: [get-main-ref] |
14 | 38 | steps:
|
15 | 39 | - name: Checkout current branch
|
16 | 40 | uses: actions/checkout@v4
|
17 | 41 | with:
|
18 |
| - ref: ${{ github.ref_name }} |
| 42 | + ref: ${{ needs.get-main-ref.outputs.branch }} |
19 | 43 | - uses: actions/setup-python@v5
|
20 | 44 | with:
|
21 | 45 | python-version: '3.9'
|
22 | 46 | - run: python -m pip install --upgrade setuptools virtualenv
|
23 | 47 | - run: pip install -r requirements-dev.txt
|
24 | 48 | - run: pytest --cov=hooks --cov-fail-under=100
|
25 | 49 |
|
26 |
| - main: |
| 50 | + type-check: |
| 51 | + if: ${{ !needs.get-main-ref.outputs.onPR || (contains(github.event.comment.body, '/type-check') || contains(github.event.comment.body, '/all-tests')) }} |
27 | 52 | runs-on: ubuntu-latest
|
28 |
| - name: Run all tests, run static type analysis, coverage, and mutation tests |
29 |
| - needs: sanity-run |
| 53 | + name: Type checking |
| 54 | + needs: [get-main-ref] |
30 | 55 | steps:
|
31 | 56 | - name: Checkout current branch
|
32 | 57 | uses: actions/checkout@v4
|
33 | 58 | with:
|
34 |
| - ref: ${{ github.ref_name }} |
| 59 | + ref: ${{ needs.get-main-ref.outputs.branch }} |
35 | 60 | - uses: actions/setup-python@v5
|
36 | 61 | with:
|
37 |
| - python-version: '3.12' |
| 62 | + python-version: '3.9' |
38 | 63 | - run: python -m pip install --upgrade setuptools virtualenv
|
39 | 64 | - run: pip install -r requirements-dev.txt
|
40 | 65 | - run: mypy hooks
|
41 |
| - - run: pytest --cov=hooks --cov-fail-under=100 |
| 66 | + |
| 67 | + mutate: |
| 68 | + if: ${{ !needs.get-main-ref.outputs.onPR || (contains(github.event.comment.body, '/mutate') || contains(github.event.comment.body, '/all-tests')) }} |
| 69 | + runs-on: ubuntu-latest |
| 70 | + name: Mutation tests |
| 71 | + needs: [get-main-ref, coverage] |
| 72 | + steps: |
| 73 | + - name: Checkout current branch |
| 74 | + uses: actions/checkout@v4 |
| 75 | + with: |
| 76 | + ref: ${{ needs.get-main-ref.outputs.branch }} |
| 77 | + - uses: actions/setup-python@v5 |
| 78 | + with: |
| 79 | + python-version: '3.12' |
| 80 | + - run: python -m pip install --upgrade setuptools virtualenv |
| 81 | + - run: pip install -r requirements-dev.txt |
| 82 | + - run: pytest --cov=hooks |
42 | 83 | - run: mutmut run --paths-to-mutate "./hooks/" --use-coverage --no-progress
|
43 | 84 |
|
44 | 85 | combos:
|
45 |
| - if: github.ref == 'refs/heads/main' |
| 86 | + if: ${{ !needs.get-main-ref.outputs.onPR || (contains(github.event.comment.body, '/combos') || contains(github.event.comment.body, '/all-tests')) }} |
46 | 87 | runs-on: ${{ matrix.os }}
|
47 |
| - name: ${{ matrix.os }} / ${{ matrix.env }} |
48 |
| - needs: main |
| 88 | + name: Tests on ${{ matrix.os }} with Python ${{ matrix.env }} |
| 89 | + needs: [get-main-ref, coverage] |
49 | 90 | strategy:
|
50 | 91 | matrix:
|
51 | 92 | os: [windows-latest, ubuntu-latest, macos-latest]
|
|
61 | 102 | - name: Checkout current branch
|
62 | 103 | uses: actions/checkout@v4
|
63 | 104 | with:
|
64 |
| - ref: ${{ github.ref_name }} |
| 105 | + ref: ${{ needs.get-main-ref.outputs.branch }} |
65 | 106 | - uses: actions/setup-python@v5
|
66 | 107 | with:
|
67 | 108 | python-version: ${{ matrix.env }}
|
|
0 commit comments