forked from macports/macports-ports
-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (195 loc) · 6.79 KB
/
main.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
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
name: "lint & build changed ports"
on:
pull_request:
branches:
- master
paths-ignore:
- '.github/**'
push:
branches-ignore:
- master
permissions:
contents: read
jobs:
build:
name: ${{ matrix.os }}
timeout-minutes: 0
concurrency:
cancel-in-progress: true
group: ${{ github.ref }}/${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-11, macos-12, macos-13]
steps:
- name: Checkout ports
uses: actions/checkout@v3
with:
fetch-depth: 64
path: ports
- name: Checkout mpbb
uses: actions/checkout@v3
with:
repository: macports/mpbb
path: mpbb
- name: Bootstrap MacPorts
run: . ports/.github/workflows/bootstrap.sh
- name: Determine list of changed ports
id: portlist
run: |
set -eu
# Add getopt, mpbb and the MacPorts paths to $PATH for the subsequent
# steps.
echo "/opt/mports/bin" >> $GITHUB_PATH
echo "${PWD}/mpbb" >> $GITHUB_PATH
echo "/opt/local/bin" >> $GITHUB_PATH
echo "/opt/local/sbin" >> $GITHUB_PATH
portlist=$( \
git -C ports/ diff --name-only --diff-filter=AM macports/master...@ \
| grep -E '^[^._/][^/]*/[^/]+/(Portfile$|files/)' \
| cut -d/ -f2 \
| sort -u \
| tr '\n' ' ' \
| sed 's/ $//')
echo "$portlist"
echo "portlist=$portlist" >> $GITHUB_OUTPUT
- name: Determine list of subports from portlist
id: subportlist
run: |
set -eu
echo "#### Changed Ports" >> $GITHUB_STEP_SUMMARY
subportlist=""
for port in $portlist; do
echo "::group::Listing subports for ${port}"
new_subports=$(mpbb \
--work-dir /tmp/mpbb \
list-subports \
--archive-site= \
--archive-site-private= \
--include-deps=no \
"$port" \
| tr '\n' ' ')
for subport in $new_subports; do
echo "$subport"
echo "- ${subport}" >> $GITHUB_STEP_SUMMARY
subportlist="$subportlist $subport"
done
echo "::endgroup::"
done
echo "subportlist=${subportlist}" >> $GITHUB_OUTPUT
env:
portlist: ${{ steps.portlist.outputs.portlist }}
- name: Run port lint for all changed subports
run: |
set -eu
echo "#### Lint Results" >> $GITHUB_STEP_SUMMARY
fail=0
for subport in $subportlist; do
echo "::group::${subport}"
path=$(port file "$subport")
messagetype="warning"
if ! messages=$(port -q lint "$subport" 2>&1); then
messagetype="error"
fail=1
fi
if [ -n "$messages" ]; then
echo "$messages"
if [ "$fail" -eq 1 ]; then
echo "##### ❌ ${subport}" >> $GITHUB_STEP_SUMMARY
else
echo "##### ⚠️ ${subport}" >> $GITHUB_STEP_SUMMARY
fi
printf '```\n%s```\n' "$messages" >> $GITHUB_STEP_SUMMARY
# See https://github.com/actions/toolkit/issues/193#issuecomment-605394935
encoded_messages="port lint ${subport}:%0A"
encoded_messages+="$(echo "${messages}" | sed -E 's/$/%0A/g' | tr -d '\n')"
echo "::${messagetype} file=${path#${PWD}/ports/},line=1,col=1::${encoded_messages}"
else
echo "##### ✅ ${subport}" >> $GITHUB_STEP_SUMMARY
fi
echo "::endgroup::"
done
exit "$fail"
env:
subportlist: ${{ steps.subportlist.outputs.subportlist }}
- name: Build changed subports
run: |
set -eu
echo "#### Build Results" >> $GITHUB_STEP_SUMMARY
fail=0
for subport in $subportlist; do
workdir="/tmp/mpbb/$subport"
mkdir -p "$workdir/logs"
echo "##### ${subport}" >> $GITHUB_STEP_SUMMARY
touch "$workdir/logs/dependencies-progress.txt"
echo "::group::Cleaning up between ports"
sudo mpbb --work-dir "$workdir" cleanup
echo "::endgroup::"
echo "::group::Installing dependencies for ${subport}"
sudo mpbb \
--work-dir "$workdir" \
install-dependencies \
"$subport" >"$workdir/logs/install-dependencies.log" 2>&1 &
deps_pid=$!
tail -f "$workdir/logs/dependencies-progress.txt" 2>/dev/null &
tail_pid=$!
set +e
wait "$deps_pid"
deps_exit=$?
set -e
kill "$tail_pid" || true
if [ "$deps_exit" -ne 0 ]; then
echo "::endgroup::"
echo "::error::Failed to install dependencies for ${subport}"
echo "⚠️ Failed to install dependencies" >> $GITHUB_STEP_SUMMARY
fail=1
continue
fi
echo "::endgroup::"
echo "::group::Installing ${subport}"
set +e
sudo mpbb \
--work-dir "$workdir" \
install-port \
--source \
"$subport"
install_exit=$?
set -e
if [ "$install_exit" -ne 0 ]; then
echo "::endgroup::"
echo "::error::Failed to install ${subport}"
echo "❌ Failed to install, see the log for more details" >> $GITHUB_STEP_SUMMARY
lognum=0
for logfile in $(find $(port work "${subport}") -name config.log \
-or -name CMakeError.log -or -name meson-log.txt); do
mkdir -p "$workdir/logs/$lognum"
echo "$logfile" > "$workdir/logs/$lognum/path.txt"
cp "$logfile" "$workdir/logs/$lognum/"
lognum=$(( $lognum + 1))
done
fail=1
continue
fi
echo "✅ Successfully built" >> $GITHUB_STEP_SUMMARY
echo "::endgroup::"
done
exit "$fail"
env:
subportlist: ${{ steps.subportlist.outputs.subportlist }}
- name: Make logfiles readable
if: always()
run: |
mkdir -p /tmp/mpbb
sudo find \
/tmp/mpbb \
-maxdepth 1 \
-mindepth 1 \
-type d \
-print \
-exec chmod -R go+rX {} \;
- name: Archive build logs
if: always()
uses: actions/upload-artifact@v3
with:
name: logs-${{ matrix.os }}.zip
path: /tmp/mpbb/*/logs