-
Notifications
You must be signed in to change notification settings - Fork 2
140 lines (140 loc) · 5.19 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
name: Pull Request
on: pull_request
permissions:
contents: read
concurrency:
group: pull-request-${{github.ref}}
cancel-in-progress: true
jobs:
label:
name: Label
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
timeout-minutes: 5
steps:
- name: Apply labels
uses: actions/[email protected]
with:
repo-token: ${{github.token}}
analyze-changes:
name: Analyze Changes
timeout-minutes: 5
runs-on: ubuntu-latest
outputs:
run-build: ${{steps.analyze-changes.outputs.run-build}}
run-check-licenses: ${{steps.analyze-changes.outputs.run-check-licenses}}
run-format-check-c-cpp: ${{steps.analyze-changes.outputs.run-format-check-c-cpp}}
run-format-check-md: ${{steps.analyze-changes.outputs.run-format-check-md}}
changes-externals: ${{steps.analyze-changes.outputs.changes-externals}}
changes-c-cpp: ${{steps.analyze-changes.outputs.changes-c-cpp}}
changes-md: ${{steps.analyze-changes.outputs.changes-md}}
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Analyze changes
id: analyze-changes
shell: bash
run: |
build_ignore=()
while IFS= read -r line || [[ "$line" ]]; do
build_ignore+=(':!'"$line")
done < .build-ignore
build_changes=$(
git diff --name-status origin/master HEAD -- ${build_ignore[@]} |
sort
)
if [ -z "$build_changes" ]; then
build=false
else
build=true
fi
changes_externals=$(
git diff --name-only origin/master HEAD -- \
externals/ ':!externals/CMakeLists.txt' ':!externals/*/*' ':!externals/RmlUI.txt'
)
if [ -z "$changes_externals" ]; then
check_licenses=false
else
check_licenses=true
fi
changes_c_cpp=$(
git diff --diff-filter=d --name-only origin/master HEAD -- \
'*.c' '*.cpp' '*.h' '*.hpp' '*.inl' .clang-format
)
if [ -z "$changes_c_cpp" ]; then
format_check_c_cpp=false
else
format_check_c_cpp=true
changes_c_cpp=$(
echo "$changes_c_cpp" | grep -v .clang-format || true | sort
)
fi
changes_md=$(
git diff --diff-filter=d --name-only origin/master HEAD -- \
'*.md' .markdownlintrc .markdownlintignore
)
if [ -z "$changes_md" ]; then
format_check_md=false
else
format_check_md=true
changes_md=$(
echo "$changes_md" | grep -v .markdownlint || true | sort
)
fi
echo "Run build: $build"
echo "Run license check: $check_licenses"
echo "Run format check (C/C++): $format_check_c_cpp"
echo "Run format check (Markdown): $format_check_md"
if [ -z "$build_changes" ]; then
echo 'Changes affecting build: [none]'
else
echo -e "Changes affecting build:\n$build_changes"
fi
if [ -z "$changes_externals" ]; then
echo 'Changes (Externals): [none]'
else
echo -e "Changes (Externals):\n$changes_externals"
fi
if [ -z "$changes_c_cpp" ]; then
echo 'Changes (C/C++): [none]'
else
echo -e "Changes (C/C++):\n$changes_c_cpp"
fi
if [ -z "$changes_md" ]; then
echo 'Changes (Markdown): [none]'
else
echo -e "Changes (Markdown):\n$changes_md"
fi
delimiter=$(head -c 16 /dev/urandom | base64)
echo "run-build=$build" >> $GITHUB_OUTPUT
echo "run-check-licenses=$check_licenses" >> $GITHUB_OUTPUT
echo "run-format-check-c-cpp=$format_check_c_cpp" >> $GITHUB_OUTPUT
echo "run-format-check-md=$format_check_md" >> $GITHUB_OUTPUT
echo "changes-externals<<$delimiter" >> $GITHUB_OUTPUT
echo "$changes_externals" >> $GITHUB_OUTPUT
echo "$delimiter" >> $GITHUB_OUTPUT
echo "changes-c-cpp<<$delimiter" >> $GITHUB_OUTPUT
echo "$changes_c_cpp" >> $GITHUB_OUTPUT
echo "$delimiter" >> $GITHUB_OUTPUT
echo "changes-md<<$delimiter" >> $GITHUB_OUTPUT
echo "$changes_md" >> $GITHUB_OUTPUT
echo "$delimiter" >> $GITHUB_OUTPUT
ci:
name: CI
needs:
- analyze-changes
uses: ./.github/workflows/.shared-ci.yml
secrets: inherit
with:
run-build: ${{needs.analyze-changes.outputs.run-build == 'true'}}
run-check-licenses: ${{needs.analyze-changes.outputs.run-check-licenses == 'true'}}
run-format-check-c-cpp: ${{needs.analyze-changes.outputs.run-format-check-c-cpp == 'true'}}
run-format-check-md: ${{needs.analyze-changes.outputs.run-format-check-md == 'true'}}
changes-externals: ${{needs.analyze-changes.outputs.changes-externals}}
changes-c-cpp: ${{needs.analyze-changes.outputs.changes-c-cpp}}
changes-md: ${{needs.analyze-changes.outputs.changes-md}}
use-sccache: ${{github.actor != 'dependabot[bot]'}}