/
.travis.yml
226 lines (191 loc) · 6.91 KB
/
.travis.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
os: linux
dist: bionic
language: cpp
git:
submodules: false
env:
global:
- SNAPCRAFT_ENABLE_ERROR_REPORTING=0
# regexes for release branch and tag
- MULTIPASS_RELEASE_BRANCH_PATTERN="^release/([0-9\.]+)$"
- MULTIPASS_RELEASE_TAG_PATTERN="^v([0-9]+\.[0-9]+)\.[0-9]+$"
# build label added to the version string
- MULTIPASS_BUILD_LABEL=""
# whether to publish the built packages
- MULTIPASS_PUBLISH=""
# which channel to publish to
- MULTIPASS_SNAP_CHANNEL=""
# options to pass to the build reporter
- MULTIPASS_REPORT_OPTIONS=()
stages:
- name: static
- name: build
if: | # bors and release branches, release tags and all pull requests
(type = push
AND (branch IN (staging, trying, master)
OR branch ~= env(MULTIPASS_RELEASE_BRANCH_PATTERN)
OR branch ~= env(MULTIPASS_RELEASE_TAG_PATTERN)))
OR type = pull_request
- name: process snaps
if: type = cron
jobs:
include:
- stage: static
name: Clang format
if: type = pull_request
addons:
apt:
packages: [clang-format]
script:
- git diff -U0 --no-color origin/${TRAVIS_BRANCH} | clang-format-diff -p1 | tee ${HOME}/clang-diff
- |
if [ "$( stat --printf='%s' ${HOME}/clang-diff )" -ne 0 ]; then
echo "ERROR: please apply the above diff to correct formatting"
exit 1
fi
- &snapcraft-build
stage: build
name: Debug
env: BUILD_TYPE=Debug
git:
depth: false
submodules: true
addons:
snaps:
- &lxd-snap lxd
- &snapcraft-snap
name: snapcraft
classic: true
before_install:
# determine build properties and targets
- &setup-build source tools/setup_build.sh
install:
- sudo apt remove --purge --assume-yes lxd lxd-client
- sudo /snap/bin/lxd waitready
- sudo /snap/bin/lxd init --auto
- sudo adduser $USER lxd
- ccache --max-size=5G
before_script:
# patch build system for the build type being processed
- "[ ! -f tests/travis.patch ] || patch -p1 --no-backup-if-mismatch < tests/travis.patch"
- "[ ! -f tests/travis-${BUILD_TYPE}.patch ] || patch -p1 --no-backup-if-mismatch < tests/travis-${BUILD_TYPE}.patch"
# set up ccache
- sg lxd -c '/snap/bin/lxc profile set default environment.PATH "/usr/lib/ccache:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"'
- sg lxd -c '/snap/bin/lxc profile device add default ccache disk source=${HOME}/.ccache/ path=/root/.ccache'
- ccache --zero-stats
# inject build identifier
- sed -i "/configflags:/a \ - -DMULTIPASS_BUILD_LABEL=${MULTIPASS_BUILD_LABEL}" snap/snapcraft.yaml
script:
- sg lxd -c '/snap/bin/snapcraft build --use-lxd multipass'
- sg lxd -c '/snap/bin/lxc start snapcraft-multipass'
- sg lxd -c
'/snap/bin/lxc exec snapcraft-multipass --
env CTEST_OUTPUT_ON_FAILURE=1
LD_LIBRARY_PATH=/root/stage/usr/lib/x86_64-linux-gnu/:/root/stage/lib/:/root/parts/multipass/build/lib/
/root/parts/multipass/build/bin/multipass_tests'
after_failure:
- cat /tmp/*/trace.txt
after_script:
- ccache --show-stats
cache: ccache
- <<: *snapcraft-build
name: Clang
env: BUILD_TYPE=Clang
script:
- sg lxd -c '/snap/bin/snapcraft build --use-lxd multipass'
- <<: *snapcraft-build
name: RelWithDebInfo
env: BUILD_TYPE=RelWithDebInfo
if: &secure_condition |
repo = canonical/multipass
AND (type != pull_request
OR head_repo = repo)
addons:
snaps:
- *lxd-snap
- *snapcraft-snap
- review-tools
before_install:
- *setup-build
- &decrypt-bot-data |
openssl aes-256-cbc -K $encrypted_1b80fb3c7803_key -iv $encrypted_1b80fb3c7803_iv \
-in tools/bot-data.tar.xz.enc -out tools/bot-data.tar.xz -d
tar --extract --xz --file tools/bot-data.tar.xz --directory ${HOME}
script:
- sg lxd -c '/snap/bin/snapcraft --use-lxd'
- SNAP_ENFORCE_RESQUASHFS=0 /snap/bin/review-tools.snap-review --allow-classic *.snap
after_success:
- &python-requirements pyenv local 3.8.1 && python3 -m pip install --requirement tools/requirements.txt boto3
- BUILDS=()
- >-
[ -n "${MULTIPASS_SNAP_CHANNEL}" ]
&& snapcraft login --with ${HOME}/snap-login
&& snapcraft push multipass_*.snap --release ${MULTIPASS_SNAP_CHANNEL}
&& BUILDS+=("\`snap refresh multipass --channel ${MULTIPASS_SNAP_CHANNEL}\`")
- >-
[ -z "${MULTIPASS_SNAP_CHANNEL}" ]
&& MULTIPASS_REPORT_OPTIONS+=(
--file *.snap
--s3-bucket multipass-ci
--s3-prefix ${MULTIPASS_BUILD_LABEL}
)
&& BUILDS+=('[{filename}]({url})')
- >-
[ -n "${MULTIPASS_PUBLISH}" ]
&& python3 -m tools.report_build "${MULTIPASS_REPORT_OPTIONS[@]}" Snap "${BUILDS[@]}"
- <<: *snapcraft-build
name: Coverage
env: BUILD_TYPE=Coverage
script:
- mkdir "${HOME}/parts"
- sg lxd -c '/snap/bin/lxc profile device add default build disk source=${HOME}/parts path=/root/parts'
- sg lxd -c '/snap/bin/snapcraft build --use-lxd multipass'
- sg lxd -c '/snap/bin/lxc start snapcraft-multipass'
- sg lxd -c
'/snap/bin/lxc exec snapcraft-multipass --
env CTEST_OUTPUT_ON_FAILURE=1
LD_LIBRARY_PATH=/root/stage/usr/lib/x86_64-linux-gnu/:/root/stage/lib/
cmake --build /root/parts/multipass/build --target covreport'
after_success:
- bash <(curl -s https://codecov.io/bash) -Z -s ${HOME/parts}
- stage: build
name: macOS
env: BUILD_TYPE=macOS
if: *secure_condition
git:
submodules: false
addons: ~
before_install:
- *setup-build
- *decrypt-bot-data
script:
- |
if [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]; then
REF="+refs/pull/${TRAVIS_PULL_REQUEST}/merge"
else
REF="${TRAVIS_COMMIT}"
fi
ARTIFACTS_DIR=$( ssh -q -p ${MAC_PORT} ${MAC_USERHOST} mktemp -d )
ssh -q -p ${MAC_PORT} ${MAC_USERHOST} multipass-build/build-in-snapshot.sh public "${REF}" "${ARTIFACTS_DIR}" "${MULTIPASS_BUILD_LABEL}"
after_success:
- *python-requirements
- scp -P ${MAC_PORT} ${MAC_USERHOST}:${ARTIFACTS_DIR}/*.pkg .
- python3 -m tools.report_build "${MULTIPASS_REPORT_OPTIONS[@]}"
--file *.pkg
--s3-bucket multipass-ci
--s3-prefix "${MULTIPASS_BUILD_LABEL}"
macOS '[{filename}]({url})'
- stage: process snaps
name: Process snaps
env: ~
language: python
python: 3.8
addons:
snaps:
- review-tools
before_install:
- *decrypt-bot-data
install:
- *python-requirements
script:
- tools/process_snaps.py