1
- name : Testing pipeline
1
+ name : Run tests
2
2
3
3
on :
4
4
push :
10
10
types : [created]
11
11
12
12
jobs :
13
+ get-main-ref :
14
+ runs-on : ubuntu-latest
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')"
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 }}"
28
+ outputs :
29
+ branch : ${{ steps.from-pr.outputs.branch || steps.from-branch.outputs.branch }}
30
+
13
31
sanity-run :
14
32
runs-on : ubuntu-latest
15
33
name : Run tests on lowest supported Python version on Ubuntu as a sanity-check before doing anything else
34
+ needs : get-main-ref
16
35
steps :
17
36
- name : Checkout current branch
18
37
uses : actions/checkout@v4
19
38
with :
20
- ref : ${{ github.head_ref || github.ref_name }}
39
+ ref : ${{ needs.get-main-ref.outputs.branch }}
21
40
- uses : actions/setup-python@v5
22
41
with :
23
42
python-version : ' 3.9'
@@ -29,12 +48,12 @@ jobs:
29
48
if : ${{ (github.ref == 'refs/heads/main') || (contains(github.event.comment.html_url, '/pull/') && (contains(github.event.comment.body, '/full-build') || contains(github.event.comment.body, '/mutate'))) }}
30
49
runs-on : ubuntu-latest
31
50
name : Run all tests, run static type analysis, coverage, and mutation tests
32
- needs : sanity-run
51
+ needs : [get-main-ref, sanity-run]
33
52
steps :
34
53
- name : Checkout current branch
35
54
uses : actions/checkout@v4
36
55
with :
37
- ref : ${{ github.head_ref || github.ref_name }}
56
+ ref : ${{ needs.get-main-ref.outputs.branch }}
38
57
- uses : actions/setup-python@v5
39
58
with :
40
59
python-version : ' 3.12'
48
67
if : ${{ (github.ref == 'refs/heads/main') || (contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/full-build')) }}
49
68
runs-on : ${{ matrix.os }}
50
69
name : ${{ matrix.os }} / ${{ matrix.env }}
51
- needs : main
70
+ needs : [get- main-ref, main]
52
71
strategy :
53
72
matrix :
54
73
os : [windows-latest, ubuntu-latest, macos-latest]
64
83
- name : Checkout current branch
65
84
uses : actions/checkout@v4
66
85
with :
67
- ref : ${{ github.head_ref || github.ref_name }}
86
+ ref : ${{ needs.get-main-ref.outputs.branch }}
68
87
- uses : actions/setup-python@v5
69
88
with :
70
89
python-version : ${{ matrix.env }}
0 commit comments