forked from NemoMi/zeroeye
-
Notifications
You must be signed in to change notification settings - Fork 7
62 lines (48 loc) · 1.86 KB
/
Copy pathdiagnostic-build-log.yml
File metadata and controls
62 lines (48 loc) · 1.86 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
name: Diagnostic build log
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
require-diagnostic-build-log:
name: Require diagnostic build log bundle in PR
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify new diagnostic .logd and .json are committed in this PR
shell: bash
run: |
set -euo pipefail
base_sha="${{ github.event.pull_request.base.sha }}"
head_sha="${{ github.event.pull_request.head.sha }}"
echo "Checking PR diff from ${base_sha} to ${head_sha}"
mapfile -t new_logd < <(
git diff --name-only --diff-filter=A "${base_sha}...${head_sha}" -- 'diagnostic/*.logd'
)
mapfile -t new_json < <(
git diff --name-only --diff-filter=A "${base_sha}...${head_sha}" -- 'diagnostic/*.json'
)
if [ "${#new_logd[@]}" -eq 0 ]; then
echo "::error::This PR must commit a new diagnostic .logd file under diagnostic/."
exit 1
fi
if [ "${#new_json[@]}" -eq 0 ]; then
echo "::error::This PR must commit a new diagnostic .json file under diagnostic/."
exit 1
fi
echo "Found new diagnostic .logd file(s):"
printf ' - %s\n' "${new_logd[@]}"
echo "Found new diagnostic .json file(s):"
printf ' - %s\n' "${new_json[@]}"
for file in "${new_logd[@]}" "${new_json[@]}"; do
if [ ! -f "${file}" ]; then
echo "::error file=${file}::Diagnostic file path is not a file."
exit 1
fi
if [ ! -s "${file}" ]; then
echo "::error file=${file}::Diagnostic file is empty."
exit 1
fi
done