-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathmain.yml
185 lines (164 loc) · 5.42 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
trigger:
branches:
include:
- "update/*"
pr:
- "*"
resources:
repositories:
- repository: mpbb
type: github
endpoint: macports
name: macports/mpbb
jobs:
- job: build
displayName: "macOS-10.14"
timeoutInMinutes: 0
pool:
vmImage: 'macOS-10.14'
steps:
- checkout: self
fetchDepth: 64
path: s/ports
- checkout: mpbb
path: s/mpbb
- bash: . ports/.github/azure-workflows/bootstrap.sh
displayName: Bootstrap MacPorts
- bash: |
set -eu
# Add getopt, mpbb and the MacPorts paths to $PATH for the subsequent
# steps.
echo "##vso[task.prependpath]/opt/mports/bin"
echo "##vso[task.prependpath]${PWD}/mpbb"
echo "##vso[task.prependpath]/opt/local/bin"
echo "##vso[task.prependpath]/opt/local/sbin"
IFS='/' read -r -a portlist <<<$( \
git -C ports/ diff --name-only --diff-filter=AM macports/master...@ \
| grep -E '[^\._/][^/]*/[^/]+/(Portfile|files/)' \
| cut -d/ -f2 \
| sort -u \
| tr '\n' '/')
echo "${portlist[@]}"
echo "##vso[task.setvariable variable=portlist;isoutput=true]${portlist[@]}"
displayName: Determine list of changed ports
name: portlist
- bash: |
set -eu
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"
subportlist="$subportlist $subport"
done
echo "##[endgroup]"
done
echo "##vso[task.setvariable variable=subportlist;isoutput=true]${subportlist}"
env:
portlist: $(portlist.portlist)
displayName: Determine list of subports from portlist
name: subportlist
- bash: |
set -eu
fail=0
for subport in $subportlist; do
echo "##[group]${subport}"
path=$(port file "$subport")
messagetype="warning"
if ! messages=$(port -q lint --nitpick "$subport" 2>&1); then
messagetype="error"
fail=1
fi
if [ -n "$messages" ]; then
echo "$messages"
# See https://github.com/actions/toolkit/issues/193#issuecomment-605394935
encoded_messages="port lint --nitpick ${subport}:%0A"
encoded_messages+="$(echo "${messages}" | sed -E 's/$/%0A/g' | tr -d '\n')"
echo "##vso[task.logissue type=${messagetype};sourcepath=${path#${PWD}/ports/};linenumber=1;columnnumber=1]${encoded_messages}"
fi
echo "##[endgroup]"
done
exit "$fail"
env:
subportlist: $(subportlist.subportlist)
displayName: Run port lint for all changed subports
- bash: |
set -eu
fail=0
for subport in $subportlist; do
workdir="/tmp/mpbb/$subport"
mkdir -p "$workdir/logs"
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}"
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}"
fail=1
continue
fi
echo "##[endgroup]"
done
exit "$fail"
displayName: Build changed subports
env:
subportlist: $(subportlist.subportlist)
- bash: |
sudo find \
/tmp/mpbb \
-maxdepth 1 \
-mindepth 1 \
-type d \
-print \
-exec chmod -R go+rX {} \;
condition: always()
displayName: Make logfiles readable
- bash: |
cd /tmp/mpbb
zip \
logs.zip \
*/logs/*
condition: always()
displayName: Archive build logs
- publish: /tmp/mpbb/logs.zip
artifact: logs.zip
condition: always()
displayName: Publish build logs archive