-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
250 lines (219 loc) · 9.21 KB
/
action.yml
File metadata and controls
250 lines (219 loc) · 9.21 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: Validate Integration
description: >
Validates Autohive integrations — structure, code quality, and README updates.
Posts a sticky PR comment with results.
inputs:
base_ref:
description: >
Git ref to diff against for detecting changed directories (e.g. origin/main).
Required when directories is not provided.
required: false
directories:
description: >
Space-separated list of integration directories to validate.
If not provided, directories are auto-detected via git diff against base_ref.
required: false
python_version:
description: Python version to use
required: false
default: '3.13'
post_comment:
description: Post a sticky PR comment with results (requires pull-requests write permission)
required: false
default: 'true'
outputs:
directories:
description: Space-separated list of integration directories that were validated
value: ${{ steps.detect.outputs.dirs }}
structure_result:
description: "'success' or 'failure'"
value: ${{ steps.structure.outcome }}
code_result:
description: "'success' or 'failure'"
value: ${{ steps.code.outcome }}
readme_result:
description: "'success' or 'failure'"
value: ${{ steps.readme.outcome }}
version_result:
description: "'success' or 'failure'"
value: ${{ steps.version.outcome }}
tests_result:
description: "'success' or 'failure'"
value: ${{ steps.tests.outcome }}
structure_output:
description: Full output of the structure check
value: ${{ steps.structure.outputs.output }}
code_output:
description: Full output of the code check
value: ${{ steps.code.outputs.output }}
readme_output:
description: Full output of the README check
value: ${{ steps.readme.outputs.output }}
version_output:
description: Full output of the version check
value: ${{ steps.version.outputs.output }}
tests_output:
description: Full output of the test runner
value: ${{ steps.tests.outputs.output }}
runs:
using: composite
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}
- name: Install dev tools
shell: bash
run: pip install -r ${{ github.action_path }}/requirements-dev.txt -q
- name: Detect changed directories
id: detect
shell: bash
run: |
if [ -n "${{ inputs.directories }}" ]; then
echo "dirs=${{ inputs.directories }}" >> $GITHUB_OUTPUT
elif [ -n "${{ inputs.base_ref }}" ]; then
DIRS=$(python ${{ github.action_path }}/scripts/get_changed_dirs.py "${{ inputs.base_ref }}")
echo "dirs=$DIRS" >> $GITHUB_OUTPUT
else
echo "::error::Either 'base_ref' or 'directories' input is required"
exit 1
fi
MSG=$(git log -1 --format=%s ${{ github.event.pull_request.head.sha }})
echo "commit_msg=$MSG" >> $GITHUB_OUTPUT
- name: Structure Check
id: structure
if: steps.detect.outputs.dirs != ''
continue-on-error: true
shell: bash
run: |
set +e
OUTPUT=$(python ${{ github.action_path }}/scripts/validate_integration.py ${{ steps.detect.outputs.dirs }} 2>&1)
EXIT_CODE=$?
echo "$OUTPUT"
echo 'output<<EOF' >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
if echo "$OUTPUT" | grep -q "⚠️"; then
echo "has_warnings=true" >> $GITHUB_OUTPUT
fi
exit $EXIT_CODE
- name: Code Check
id: code
if: steps.detect.outputs.dirs != ''
continue-on-error: true
shell: bash
run: |
set +e
OUTPUT=$(python ${{ github.action_path }}/scripts/check_code.py ${{ steps.detect.outputs.dirs }} 2>&1)
EXIT_CODE=$?
echo "$OUTPUT"
echo 'output<<EOF' >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
if echo "$OUTPUT" | grep -q "⚠️"; then
echo "has_warnings=true" >> $GITHUB_OUTPUT
fi
exit $EXIT_CODE
- name: Tests
id: tests
if: steps.detect.outputs.dirs != ''
continue-on-error: true
shell: bash
run: |
set +e
OUTPUT=$(python ${{ github.action_path }}/scripts/run_tests.py ${{ steps.detect.outputs.dirs }} 2>&1)
EXIT_CODE=$?
echo "$OUTPUT"
echo 'output<<EOF' >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
if echo "$OUTPUT" | grep -q "⚠️"; then
echo "has_warnings=true" >> $GITHUB_OUTPUT
fi
exit $EXIT_CODE
- name: README Check
id: readme
if: steps.detect.outputs.dirs != ''
continue-on-error: true
shell: bash
run: |
set +e
OUTPUT=$(python ${{ github.action_path }}/scripts/check_readme.py "${{ inputs.base_ref }}" ${{ steps.detect.outputs.dirs }} 2>&1)
EXIT_CODE=$?
echo "$OUTPUT"
echo 'output<<EOF' >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
if echo "$OUTPUT" | grep -q "⚠️"; then
echo "has_warnings=true" >> $GITHUB_OUTPUT
fi
exit $EXIT_CODE
- name: Version Check
id: version
if: steps.detect.outputs.dirs != '' && inputs.base_ref != ''
continue-on-error: true
shell: bash
run: |
set +e
OUTPUT=$(python ${{ github.action_path }}/scripts/check_version_bump.py "${{ inputs.base_ref }}" ${{ steps.detect.outputs.dirs }} 2>&1)
EXIT_CODE=$?
echo "$OUTPUT"
echo 'output<<EOF' >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
if echo "$OUTPUT" | grep -q "⚠️"; then
echo "has_warnings=true" >> $GITHUB_OUTPUT
fi
exit $EXIT_CODE
- name: Delete stale PR comment
if: always() && steps.detect.outputs.dirs == '' && inputs.post_comment == 'true'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: validation-results
delete: true
- name: Post PR comment
if: always() && steps.detect.outputs.dirs != '' && inputs.post_comment == 'true'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: validation-results
message: |
## 🔍 Integration Validation Results
**Commit:** [`${{ github.event.pull_request.head.sha }}`](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha }}) · ${{ steps.detect.outputs.commit_msg }}
**Updated:** ${{ github.event.pull_request.updated_at }}
**Changed directories:** `${{ steps.detect.outputs.dirs }}`
| Check | Result |
|-------|--------|
| Structure | ${{ steps.structure.outcome == 'failure' && '❌ Failed' || (steps.structure.outputs.has_warnings == 'true' && '⚠️ Passed with warnings' || '✅ Passed') }} |
| Code | ${{ steps.code.outcome == 'failure' && '❌ Failed' || (steps.code.outputs.has_warnings == 'true' && '⚠️ Passed with warnings' || '✅ Passed') }} |
| Tests | ${{ steps.tests.outcome == 'failure' && '❌ Failed' || (steps.tests.outputs.has_warnings == 'true' && '⚠️ Passed with warnings' || '✅ Passed') }} |
| README | ${{ steps.readme.outcome == 'failure' && '❌ Failed' || (steps.readme.outputs.has_warnings == 'true' && '⚠️ Passed with warnings' || '✅ Passed') }} |
| Version | ${{ steps.version.outcome == 'failure' && '❌ Failed' || (steps.version.outputs.has_warnings == 'true' && '⚠️ Passed with warnings' || '✅ Passed') }} |
<details><summary>${{ steps.structure.outcome == 'failure' && '❌' || (steps.structure.outputs.has_warnings == 'true' && '⚠️' || '✅') }} Structure Check output</summary>
```
${{ steps.structure.outputs.output }}
```
</details>
<details><summary>${{ steps.code.outcome == 'failure' && '❌' || (steps.code.outputs.has_warnings == 'true' && '⚠️' || '✅') }} Code Check output</summary>
```
${{ steps.code.outputs.output }}
```
</details>
<details><summary>${{ steps.tests.outcome == 'failure' && '❌' || (steps.tests.outputs.has_warnings == 'true' && '⚠️' || '✅') }} Tests output</summary>
```
${{ steps.tests.outputs.output }}
```
</details>
<details><summary>${{ steps.readme.outcome == 'failure' && '❌' || (steps.readme.outputs.has_warnings == 'true' && '⚠️' || '✅') }} README Check output</summary>
```
${{ steps.readme.outputs.output }}
```
</details>
<details><summary>${{ steps.version.outcome == 'failure' && '❌' || (steps.version.outputs.has_warnings == 'true' && '⚠️' || '✅') }} Version Check output</summary>
```
${{ steps.version.outputs.output }}
```
</details>
- name: Fail if any check failed
if: always() && (steps.structure.outcome == 'failure' || steps.code.outcome == 'failure' || steps.tests.outcome == 'failure' || steps.readme.outcome == 'failure' || steps.version.outcome == 'failure')
shell: bash
run: exit 1