Skip to content

Commit 397ee30

Browse files
Cruz Monrreal IICruz Monrreal II
authored andcommitted
Removed nearly all usage of 'apt-get'.
Primary cause of false Travis CI failures was running 'apt-get update'. Refactored all instances where this was needed with manually fetching and installing dependencies in S3 instace. This also includes GCC installation.
1 parent 5f40538 commit 397ee30

File tree

2 files changed

+158
-60
lines changed

2 files changed

+158
-60
lines changed

.travis.yml

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,28 @@ os: linux
1919
dist: xenial
2020

2121

22+
env:
23+
global:
24+
- deps_url="https://mbed-os-ci.s3-eu-west-1.amazonaws.com/jenkins-ci/deps"
25+
- deps_dir="${HOME}/.cache/deps"
26+
27+
cache:
28+
2229
cache:
2330
pip: true
2431
directories:
25-
- $HOME/.cache/apt
26-
- $HOME/gcc-arm-none-eabi-6-2017-q2-update
32+
- $HOME/.cache/deps
2733

2834

2935
before_install:
3036
- source tools/test/travis-ci/functions.sh
3137
- set_status "pending" "Test started."
3238

33-
# Make sure pipefail
34-
#- set -o pipefail
35-
# Setup apt to cache
36-
#- mkdir -p $HOME/.cache/apt/partial
37-
#- sudo rm -rf /var/cache/apt/archives
38-
#- sudo ln -s $HOME/.cache/apt /var/cache/apt/archives
39-
# Setup ppa to make sure arm-none-eabi-gcc is correct version
40-
#- sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
41-
#- sudo add-apt-repository -y ppa:deadsnakes/ppa
42-
# workaround for https://travis-ci.community/t/then-sudo-apt-get-update-failed-public-key-is-not-available-no-pubkey-6b05f25d762e3157-in-ubuntu-xenial/1728
43-
#- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 762E3157
44-
# Loop until update succeeds (timeouts can occur)
45-
#- travis_retry $(! sudo apt-get update 2>&1 |grep Failed)
46-
4739
after_success:
4840
- set_status "success" "Success!"
4941

5042
after_failure:
51-
-set_status "failure" "Test failed."
43+
- set_status "failure" "Test failed."
5244

5345

5446
matrix:
@@ -83,19 +75,6 @@ matrix:
8375
### Docs Tests ###
8476
- &docs-vm
8577
stage: "Docs"
86-
name: "spellcheck"
87-
env: NAME=doxy-spellcheck
88-
install:
89-
- sudo apt-get install aspell
90-
script:
91-
# Run local testing on header file doxy
92-
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh drivers
93-
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh platform
94-
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh events
95-
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh rtos
96-
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh features/netsocket
97-
98-
- <<: *docs-vm
9978
name: "astyle"
10079
env: NAME=astyle
10180
install:
@@ -117,16 +96,23 @@ matrix:
11796
| ( grep -v -f .astyleignore || true ) \
11897
| while read file; do astyle -n --options=.astylerc "${file}"; done
11998
- git diff --exit-code --diff-filter=d --color
99+
100+
- <<: *docs-vm
101+
name: "spellcheck"
102+
env: NAME=doxy-spellcheck
103+
install:
104+
- source_pkg aspell
105+
script:
106+
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh drivers
107+
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh platform
108+
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh events
109+
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh rtos
110+
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh features/netsocket
120111

121112
- <<: *docs-vm
122113
name: "doxygen"
123114
env: NAME=docs
124115
install:
125-
# Install dependencies
126-
- sudo apt-get install doxygen
127-
# Print versions we use
128-
- doxygen --version
129-
before_script:
130116
# Build doxygen
131117
- >
132118
(git clone --depth=1 --single-branch --branch Release_1_8_14 https://github.com/doxygen/doxygen;
@@ -165,12 +151,13 @@ matrix:
165151
stage: "Pytest"
166152
name: "tools-py27"
167153
env: NAME=tools-py2.7
154+
language: python
168155
python: 2.7
169156
install:
170-
# Install dependencies
171-
- sudo apt-get install gcc-arm-embedded
157+
# Install gcc
158+
- source_pkg gcc
172159
- arm-none-eabi-gcc --version
173-
# Add additional dependencies specific for testing
160+
# Install additional python modules
174161
- python --version
175162
- |-
176163
tr -d ' ' >> requirements.txt <<< "
@@ -181,7 +168,8 @@ matrix:
181168
coverage>=4.5,<5
182169
coveralls>=1.5,<2
183170
"
184-
# ... and install.
171+
- python -m pip install --upgrade pip==18.1
172+
- python -m pip install --upgrade setuptools==40.4.3
185173
- pip install -r requirements.txt
186174
- pip list --verbose
187175
script:
@@ -190,8 +178,6 @@ matrix:
190178
- python tools/test/pylint.py
191179
- coverage run -a tools/project.py -S | sed -n '/^Total/p'
192180
- coverage html
193-
after_success:
194-
# Coverage for tools
195181
- coveralls
196182

197183
- <<: *pytools-vm
@@ -217,21 +203,22 @@ matrix:
217203
env: NAME=psa-autogen
218204
language: python
219205
python: 3.7
206+
install:
207+
# Install gcc
208+
- source_pkg gcc
209+
- arm-none-eabi-gcc --version
210+
# Install python modules
211+
- python -m pip install --upgrade pip==18.1
212+
- python -m pip install --upgrade setuptools==40.4.3
213+
- pip install -r requirements.txt
214+
- pip list --verbose
220215
script:
221216
- python tools/psa/generate_partition_code.py
222217
- git diff --exit-code
223218

224219
- <<: *extended-vm
225220
name: "events"
226221
env: NAME=events EVENTS=events
227-
install:
228-
# Install dependencies
229-
- sudo apt-get install gcc-arm-embedded
230-
- pip install -r requirements.txt
231-
# Print versions we use
232-
- arm-none-eabi-gcc --version
233-
- gcc --version
234-
- python --version
235222
script:
236223
# Check that example compiles
237224
- sed -n '/``` cpp/,/```/{/```$/Q;/```/d;p;}' $EVENTS/README.md > main.cpp
@@ -264,13 +251,17 @@ matrix:
264251
name: "littlefs"
265252
env: NAME=littlefs LITTLEFS=features/storage/filesystem/littlefs
266253
install:
267-
# Install dependencies
268-
- sudo apt-get install gcc-arm-embedded fuse libfuse-dev
269-
- pip install -r requirements.txt
270-
# Print versions
254+
# Install gcc
255+
- source_pkg gcc
271256
- arm-none-eabi-gcc --version
272-
- gcc --version
273-
- python --version
257+
# Install python modules
258+
- python -m pip install --upgrade pip==18.1
259+
- python -m pip install --upgrade setuptools==40.4.3
260+
- pip install -r requirements.txt
261+
- pip list --verbose
262+
# Install test-specific packages
263+
- source_pkg fuse
264+
- source_pkg libfuse-dev
274265
- fusermount --version
275266
before_script:
276267
# Setup and patch littlefs-fuse

tools/test/travis-ci/functions.sh

Lines changed: 112 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,128 @@
1818

1919
set -o pipefail
2020

21-
info() { echo "I: ${1}"; }
22-
die() { echo "E: ${1}" 1>&2; exit ${2:-1}; }
21+
info() { echo -e "I: ${1}"; }
22+
die() { echo -e "E: ${1}" 1>&2; exit ${2:-1}; }
2323

2424
set_status()
2525
{
26-
local _name=${NAME}
27-
local _payload=$(<<< "
26+
local job_name=${NAME}
27+
local payload=$(<<< "
2828
{
2929
'state': '${1}',
3030
'description': '${2}',
31-
'context': 'travis-ci/${_name}',
31+
'context': 'travis-ci/${job_name}',
3232
'target_url': 'https://travis-ci.org/${TRAVIS_REPO_SLUG}/jobs/${TRAVIS_JOB_ID}'
3333
}" tr '"' '"')
3434

3535
curl --silent --output /dev/null --user "${MBED_BOT}" --request POST \
3636
"https://api.github.com/repos/${TRAVIS_REPO_SLUG}/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT}" \
3737
--data @- <<< "${payload}"
3838
}
39+
40+
41+
_install_gcc()
42+
{
43+
local url="${deps_url}/gcc6-linux.tar.bz2"
44+
local gcc_path="${deps_dir}/gcc/gcc-arm-none-eabi-6-2017-q2-update/"
45+
local archive="gcc.tar.bz2"
46+
47+
info "URL: ${url}"
48+
49+
if [ ! -d "${deps_dir}/gcc" ]; then
50+
51+
info "Downloading archive"
52+
curl --location "${url}" --output "${deps_dir}/${archive}"
53+
ls -al "${deps_dir}"
54+
55+
info "Extracting 'gcc'"
56+
mkdir -p "${deps_dir}/gcc"
57+
tar -xf "${deps_dir}/${archive}" -C "${deps_dir}/gcc"
58+
rm "${deps_dir}/${archive}"
59+
60+
fi
61+
62+
info "Installing 'gcc'"
63+
export "PATH=${gcc_path}/bin:${PATH}"
64+
}
65+
66+
67+
_fetch_deps()
68+
{
69+
local pkg="${1}"
70+
local dep_list="${2}"
71+
72+
info "Fetching '${pkg}' archives"
73+
74+
while read dep; do
75+
76+
curl --location "${deps_url}/${dep}.deb" \
77+
--output "${deps_dir}/${dep}.deb" \
78+
|| die "Download failed ('${dep}')" \
79+
&& info "Fetched ${deps_url}/${dep}.deb" &
80+
81+
done <<< "${dep_list}"
82+
83+
wait
84+
}
85+
86+
_install_deps()
87+
{
88+
local pkg="${1}"
89+
local dep_list="${2}"
90+
91+
# Assume that if the first package isn't cached, none are.
92+
local first_dep=$(<<< "${dep_list}" head -n1)
93+
[ ! -f "${deps_dir}/${first_dep}.deb" ] && _fetch_deps "${pkg}" "${dep_list}"
94+
95+
# Install dependencies
96+
info "Installing '${pkg}' packages"
97+
sudo dpkg -i $(<<< "${dep_list}" sed -e 's_^ *__' -e 's_^\(.*\)$_'"${deps_dir}"'/\1.deb_' | tr $'\n' ' ')
98+
}
99+
100+
101+
source_pkg()
102+
{
103+
local pkg="${1}"
104+
105+
local aspell_deps="aspell
106+
aspell-en
107+
dictionaries-common
108+
libaspell15"
109+
110+
local libfuse_deps="libfuse-dev
111+
libpcre3-dev
112+
libpcre32-3
113+
libpcrecpp0v5
114+
libselinux1-dev
115+
libsepol1-dev
116+
libc-bin"
117+
118+
119+
case "${pkg}" in
120+
121+
"fuse" )
122+
sudo apt-get -o=dir::cache="${deps_dir}/apt-get" install fuse \
123+
|| die "Installation failed"
124+
;;
125+
126+
"aspell" )
127+
_install_deps aspell "${aspell_deps}" \
128+
|| die "Installation failed"
129+
;;
130+
"libfuse-dev" )
131+
_install_deps libfuse-dev "${libfuse_deps}" \
132+
|| die "Installation failed"
133+
;;
134+
135+
"gcc" )
136+
_install_gcc \
137+
|| die "Installation failed"
138+
;;
139+
140+
* )
141+
die "Package not supported: '${pkg}'"
142+
;;
143+
144+
esac
145+
}

0 commit comments

Comments
 (0)