-
Notifications
You must be signed in to change notification settings - Fork 8
128 lines (120 loc) · 4.61 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Acceptance tests
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
merge_group:
types:
- checks_requested
jobs:
pre_job:
# continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
# All of these options are optional, so you can remove them if you are happy with the defaults
skip_after_successful_duplicate: 'true'
paths:
- "src/**/*.hpp"
- "src/**/*.cpp"
- "tests/**/*.hpp"
- "tests/**/*.cpp"
- "simulations/**/*.hpp"
- "simulations/**/*.cpp"
- "**/CMakeLists.txt"
- "vendor/**"
cancel_others: 'false'
cpu_tests:
strategy:
matrix:
toolchain: [tests_toolchain, tests_release_toolchain, tests_release_omp_toolchain]
fail-fast: false
name: CPU Test (${{ matrix.toolchain }})
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true' && github.event.pull_request.draft == false
uses: ./.github/workflows/cpu_tests.yml
with:
toolchain: ${{ matrix.toolchain }}
merge_target: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
pr_number: ${{ github.event.pull_request.number }}
gpu_tests:
name: GPU Test
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true' && github.event.pull_request.draft == false
uses: ./.github/workflows/gpu_tests.yml
with:
merge_target: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
pr_number: ${{ github.event.pull_request.number }}
set_draft_failing:
runs-on: ubuntu-latest
needs: [cpu_tests, gpu_tests]
if: github.event_name == 'pull_request' && failure()
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Set PR to draft to avoid unnecessary runs
run: |
isDraft=$(gh pr view ${{ github.event.pull_request.number }} --json isDraft | jq ."isDraft")
if [[ "${isDraft}" != "true" ]]
then
gh pr ready ${{ github.event.pull_request.number }} --undo
gh pr comment ${{ github.event.pull_request.number }} -b "This PR is failing tests so it has been put back into draft. Please remove the draft status when the tests pass."
gh pr edit ${{ github.event.pull_request.number }} --remove-label "Ready to review"
fi
shell: bash
env:
GH_TOKEN: ${{ github.token }}
set_draft_cancelled:
runs-on: ubuntu-latest
needs: [cpu_tests, gpu_tests]
if: github.event_name == 'pull_request' && cancelled()
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Set PR to draft to avoid unnecessary runs
run: |
isDraft=$(gh pr view ${{ github.event.pull_request.number }} --json isDraft | jq ."isDraft")
if [[ "${isDraft}" != "true" ]]
then
gh pr ready ${{ github.event.pull_request.number }} --undo
gh pr comment ${{ github.event.pull_request.number }} -b "It seems like you haven't finished working on this PR so it has been put back into draft. Please remove the draft status when the PR can run tests without being interrupted."
gh pr edit ${{ github.event.pull_request.number }} --remove-label "Ready to review"
fi
shell: bash
env:
GH_TOKEN: ${{ github.token }}
set_labels:
runs-on: ubuntu-latest
needs: [cpu_tests, gpu_tests]
name: Set PR labels
if: github.event_name == 'pull_request' && success()
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Set PR labels for reviews
run: |
isDraft=$(gh pr view ${{ github.event.pull_request.number }} --json isDraft | jq ."isDraft")
if [[ "${isDraft}" != "true" ]]
then
STATES=$(gh pr checks ${{ github.event.pull_request.number }} --required --json state)
N_PASSES=$(echo $STATES | grep -o "\"state\":\"SUCCESS\"" | wc -l)
if [[ ${N_PASSES} == 10 ]]
then
# If all required tests are passing then mark as ready to review
gh pr edit ${{ github.event.pull_request.number }} --add-label "Ready to review"
fi
fi
env:
GH_TOKEN: ${{ github.token }}