|
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 | + - name: Get current branch name |
| 24 | + id: from-branch |
| 25 | + if: ${{ !contains(github.event.comment.html_url, '/pull/') }} |
| 26 | + run: | |
| 27 | + echo "branch=${{ github.head_ref || github.ref_name }}" >> "$GITHUB_OUTPUT" |
| 28 | + outputs: |
| 29 | + branch: ${{ steps.from-pr.outputs.branch || steps.from-branch.outputs.branch }} |
| 30 | + |
| 31 | + coverage: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + name: Run tests on lowest supported Python version on Ubuntu |
| 34 | + needs: [get-main-ref] |
14 | 35 | steps:
|
15 | 36 | - name: Checkout current branch
|
16 | 37 | uses: actions/checkout@v4
|
17 | 38 | with:
|
18 |
| - ref: ${{ github.ref_name }} |
| 39 | + ref: ${{ needs.get-main-ref.outputs.branch }} |
19 | 40 | - uses: actions/setup-python@v5
|
20 | 41 | with:
|
21 | 42 | python-version: '3.9'
|
22 | 43 | - run: python -m pip install --upgrade setuptools virtualenv
|
23 | 44 | - run: pip install -r requirements-dev.txt
|
24 | 45 | - run: pytest --cov=hooks --cov-fail-under=100
|
25 | 46 |
|
26 |
| - main: |
| 47 | + type-check: |
| 48 | + if: ${{ (github.ref == 'refs/heads/main') || (contains(github.event.comment.html_url, '/pull/') && (contains(github.event.comment.body, '/type-check') || contains(github.event.comment.body, '/full-build'))) }} |
27 | 49 | runs-on: ubuntu-latest
|
28 |
| - name: Run all tests, run static type analysis, coverage, and mutation tests |
29 |
| - needs: sanity-run |
| 50 | + name: Type checking |
| 51 | + needs: [get-main-ref] |
30 | 52 | steps:
|
31 | 53 | - name: Checkout current branch
|
32 | 54 | uses: actions/checkout@v4
|
33 | 55 | with:
|
34 |
| - ref: ${{ github.ref_name }} |
| 56 | + ref: ${{ needs.get-main-ref.outputs.branch }} |
35 | 57 | - uses: actions/setup-python@v5
|
36 | 58 | with:
|
37 |
| - python-version: '3.12' |
| 59 | + python-version: '3.9' |
38 | 60 | - run: python -m pip install --upgrade setuptools virtualenv
|
39 | 61 | - run: pip install -r requirements-dev.txt
|
40 | 62 | - run: mypy hooks
|
41 |
| - - run: pytest --cov=hooks --cov-fail-under=100 |
| 63 | + |
| 64 | + mutate: |
| 65 | + if: ${{ (github.ref == 'refs/heads/main') || (contains(github.event.comment.html_url, '/pull/') && (contains(github.event.comment.body, '/mutate') || contains(github.event.comment.body, '/full-build'))) }} |
| 66 | + runs-on: ubuntu-latest |
| 67 | + name: Mutation tests |
| 68 | + needs: [get-main-ref, coverage] |
| 69 | + steps: |
| 70 | + - name: Checkout current branch |
| 71 | + uses: actions/checkout@v4 |
| 72 | + with: |
| 73 | + ref: ${{ needs.get-main-ref.outputs.branch }} |
| 74 | + - uses: actions/setup-python@v5 |
| 75 | + with: |
| 76 | + python-version: '3.12' |
| 77 | + - run: python -m pip install --upgrade setuptools virtualenv |
| 78 | + - run: pip install -r requirements-dev.txt |
| 79 | + - run: pytest --cov=hooks |
42 | 80 | - run: mutmut run --paths-to-mutate "./hooks/" --use-coverage --no-progress
|
43 | 81 |
|
44 | 82 | combos:
|
45 |
| - if: github.ref == 'refs/heads/main' |
| 83 | + if: ${{ (github.ref == 'refs/heads/main') || (contains(github.event.comment.html_url, '/pull/') && (contains(github.event.comment.body, '/combos') || contains(github.event.comment.body, '/full-build'))) }} |
46 | 84 | runs-on: ${{ matrix.os }}
|
47 |
| - name: ${{ matrix.os }} / ${{ matrix.env }} |
48 |
| - needs: main |
| 85 | + name: Tests on ${{ matrix.os }} with Python ${{ matrix.env }} |
| 86 | + needs: [get-main-ref, coverage] |
49 | 87 | strategy:
|
50 | 88 | matrix:
|
51 | 89 | os: [windows-latest, ubuntu-latest, macos-latest]
|
|
61 | 99 | - name: Checkout current branch
|
62 | 100 | uses: actions/checkout@v4
|
63 | 101 | with:
|
64 |
| - ref: ${{ github.ref_name }} |
| 102 | + ref: ${{ needs.get-main-ref.outputs.branch }} |
65 | 103 | - uses: actions/setup-python@v5
|
66 | 104 | with:
|
67 | 105 | python-version: ${{ matrix.env }}
|
|
0 commit comments