-
Notifications
You must be signed in to change notification settings - Fork 2
175 lines (165 loc) · 6.26 KB
/
pull_request.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Pull Request
run-name: |
PR #${{ github.event.pull_request.number }} [${{ github.event_name == 'pull_request' && 'updated' || 'reviewed' }}, ${{ github.event_name == 'pull_request' && github.event.action || github.event.review.state }}${{ github.event.pull_request.draft && ', draft' || '' }}] ${{github.event.pull_request.title}}
on:
pull_request:
branches:
- master
paths-ignore:
# No sense in doing these tests for these file
- 'README.md'
- 'docs/**/*'
types:
- opened
- synchronize
- ready_for_review
- converted_to_draft
pull_request_review:
types: [submitted]
concurrency:
group: pr-test-${{ github.ref }}-${{github.event_name}}
cancel-in-progress: true
permissions:
packages: read
contents: read
jobs:
check-trigger:
runs-on: ubuntu-latest
outputs:
VALIDATE_BASIC: ${{ steps.config.outputs.VALIDATE_BASIC }}
VALIDATE_DEB: ${{ steps.config.outputs.VALIDATE_DEB }}
VALIDATE_FULL: ${{ steps.config.outputs.VALIDATE_FULL }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Clone uno
uses: actions/checkout@v4
with:
path: src/uno
submodules: true
- name: "Generate job configuration"
id: config
run: |
case ${{ github.event_name }} in
pull_request_review)
case "${{ github.event.review.state }}" in
approved)
# A new review was submitted, and the review state is "approved":
# perform a full validation (ci build on more platforms + deb validation)
full=y
# If the PR is still in draft: perform also a basic validation
if [ "${{ github.event.pull_request.draft }}" = true ]; then
basic=y
fi
;;
*)
# A new review was submitted, but the state is not "approved": nothing to do yet
;;
esac
;;
pull_request)
case "${{ github.event.pull_request.draft }}" in
true)
# The PR was updated but it is still in draft: nothing to do
;;
false)
# The PR was updated, and it is not a draft: perform a basic validation if:
# - PR.state == 'opened':
# -> PR opened as non-draft, perform an initial check
# - PR.state == 'synchronized':
# -> PR updated by new commits.
# TODO(asorbini) assert(${{ github.event.action }} != 'approved')
# (assumption is that any commit will invalidate a previous 'approved')
# - PR.state == 'ready_for_review':
# -> PR moved out of draft, run basic validation only if not already 'approved'.
# (assumption: a basic validation was already performed on the `pull_request_review`
# event for the approval.)
case "${{ github.event.action }}" in
opened|synchronize)
basic=y
;;
ready_for_review)
# (assumption: if the PR is not "mergeable" it must have not been approved.
# Ideally: we would just query the review state, but that doesn't seem to
# be available on the pull_request object, see:
# https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request)
# So we use the GitHub API to query the state,
# see: https://stackoverflow.com/a/77647838
(cd src/uno; gh repo set-default ${{ github.repository }})
review_state=$(cd src/uno; gh pr view 11 --json reviewDecision --jq '.reviewDecision')
case "${review_state}" in
APPROVED)
test_not_needed=y
;;
*)
basic=y
;;
esac
;;
*)
;;
esac
;;
esac
;;
esac
(
# echo CHECK_FAILED=${check_failed}
echo VALIDATE_BASIC=${basic}
echo VALIDATE_FULL=${full}
echo VALIDATE_DEB=${full}
) >> ${GITHUB_OUTPUT}
basic-validation:
needs: check-trigger
if: ${{ needs.check-trigger.outputs.VALIDATE_BASIC }}
strategy:
matrix:
build-platform: [amd64]
base-image: ["ubuntu:22.04"]
uno-middleware: ['']
test-without-license: [false]
uses: ./.github/workflows/ci.yml
secrets: inherit
with:
build-platform: ${{matrix.build-platform}}
base-image: ${{matrix.base-image}}
uno-middleware: ${{matrix.uno-middleware}}
test-without-license: ${{matrix.test-without-license}}
full-validation:
needs: check-trigger
if: ${{ needs.check-trigger.outputs.VALIDATE_FULL }}
strategy:
matrix:
build-platform: [amd64, arm64]
base-image: ["ubuntu:22.04"]
uno-middleware: ['']
test-without-license: [false, true]
exclude:
- build-platform: amd64
base-image: "ubuntu:22.04"
uno-middleware: ''
test-without-license: false
- build-platform: arm64
base-image: "ubuntu:22.04"
uno-middleware: ''
test-without-license: true
uses: ./.github/workflows/ci.yml
secrets: inherit
with:
build-platform: ${{matrix.build-platform}}
base-image: ${{matrix.base-image}}
uno-middleware: ${{matrix.uno-middleware}}
test-without-license: ${{matrix.test-without-license}}
deb-validation:
needs: check-trigger
if: ${{ needs.check-trigger.outputs.VALIDATE_DEB }}
strategy:
matrix:
base-tag: ["ubuntu:22.04"]
platform: [amd64]
uses: ./.github/workflows/_deb_build.yml
secrets: inherit
with:
base-tag: ${{ matrix.base-tag }}
platform: ${{ matrix.platform }}
pull-request: true