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.
pull/9844/head
Cruz Monrreal II 2019-03-07 14:22:12 -06:00
parent 5f40538c59
commit 397ee3074a
2 changed files with 158 additions and 60 deletions

View File

@ -19,36 +19,28 @@ os: linux
dist: xenial
env:
global:
- deps_url="https://mbed-os-ci.s3-eu-west-1.amazonaws.com/jenkins-ci/deps"
- deps_dir="${HOME}/.cache/deps"
cache:
cache:
pip: true
directories:
- $HOME/.cache/apt
- $HOME/gcc-arm-none-eabi-6-2017-q2-update
- $HOME/.cache/deps
before_install:
- source tools/test/travis-ci/functions.sh
- set_status "pending" "Test started."
# Make sure pipefail
#- set -o pipefail
# Setup apt to cache
#- mkdir -p $HOME/.cache/apt/partial
#- sudo rm -rf /var/cache/apt/archives
#- sudo ln -s $HOME/.cache/apt /var/cache/apt/archives
# Setup ppa to make sure arm-none-eabi-gcc is correct version
#- sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
#- sudo add-apt-repository -y ppa:deadsnakes/ppa
# 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
#- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 762E3157
# Loop until update succeeds (timeouts can occur)
#- travis_retry $(! sudo apt-get update 2>&1 |grep Failed)
after_success:
- set_status "success" "Success!"
after_failure:
-set_status "failure" "Test failed."
- set_status "failure" "Test failed."
matrix:
@ -83,19 +75,6 @@ matrix:
### Docs Tests ###
- &docs-vm
stage: "Docs"
name: "spellcheck"
env: NAME=doxy-spellcheck
install:
- sudo apt-get install aspell
script:
# Run local testing on header file doxy
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh drivers
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh platform
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh events
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh rtos
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh features/netsocket
- <<: *docs-vm
name: "astyle"
env: NAME=astyle
install:
@ -117,16 +96,23 @@ matrix:
| ( grep -v -f .astyleignore || true ) \
| while read file; do astyle -n --options=.astylerc "${file}"; done
- git diff --exit-code --diff-filter=d --color
- <<: *docs-vm
name: "spellcheck"
env: NAME=doxy-spellcheck
install:
- source_pkg aspell
script:
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh drivers
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh platform
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh events
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh rtos
- ./tools/test/travis-ci/doxy-spellchecker/spell.sh features/netsocket
- <<: *docs-vm
name: "doxygen"
env: NAME=docs
install:
# Install dependencies
- sudo apt-get install doxygen
# Print versions we use
- doxygen --version
before_script:
# Build doxygen
- >
(git clone --depth=1 --single-branch --branch Release_1_8_14 https://github.com/doxygen/doxygen;
@ -165,12 +151,13 @@ matrix:
stage: "Pytest"
name: "tools-py27"
env: NAME=tools-py2.7
language: python
python: 2.7
install:
# Install dependencies
- sudo apt-get install gcc-arm-embedded
# Install gcc
- source_pkg gcc
- arm-none-eabi-gcc --version
# Add additional dependencies specific for testing
# Install additional python modules
- python --version
- |-
tr -d ' ' >> requirements.txt <<< "
@ -181,7 +168,8 @@ matrix:
coverage>=4.5,<5
coveralls>=1.5,<2
"
# ... and install.
- python -m pip install --upgrade pip==18.1
- python -m pip install --upgrade setuptools==40.4.3
- pip install -r requirements.txt
- pip list --verbose
script:
@ -190,8 +178,6 @@ matrix:
- python tools/test/pylint.py
- coverage run -a tools/project.py -S | sed -n '/^Total/p'
- coverage html
after_success:
# Coverage for tools
- coveralls
- <<: *pytools-vm
@ -217,6 +203,15 @@ matrix:
env: NAME=psa-autogen
language: python
python: 3.7
install:
# Install gcc
- source_pkg gcc
- arm-none-eabi-gcc --version
# Install python modules
- python -m pip install --upgrade pip==18.1
- python -m pip install --upgrade setuptools==40.4.3
- pip install -r requirements.txt
- pip list --verbose
script:
- python tools/psa/generate_partition_code.py
- git diff --exit-code
@ -224,14 +219,6 @@ matrix:
- <<: *extended-vm
name: "events"
env: NAME=events EVENTS=events
install:
# Install dependencies
- sudo apt-get install gcc-arm-embedded
- pip install -r requirements.txt
# Print versions we use
- arm-none-eabi-gcc --version
- gcc --version
- python --version
script:
# Check that example compiles
- sed -n '/``` cpp/,/```/{/```$/Q;/```/d;p;}' $EVENTS/README.md > main.cpp
@ -264,13 +251,17 @@ matrix:
name: "littlefs"
env: NAME=littlefs LITTLEFS=features/storage/filesystem/littlefs
install:
# Install dependencies
- sudo apt-get install gcc-arm-embedded fuse libfuse-dev
- pip install -r requirements.txt
# Print versions
# Install gcc
- source_pkg gcc
- arm-none-eabi-gcc --version
- gcc --version
- python --version
# Install python modules
- python -m pip install --upgrade pip==18.1
- python -m pip install --upgrade setuptools==40.4.3
- pip install -r requirements.txt
- pip list --verbose
# Install test-specific packages
- source_pkg fuse
- source_pkg libfuse-dev
- fusermount --version
before_script:
# Setup and patch littlefs-fuse

View File

@ -18,17 +18,17 @@
set -o pipefail
info() { echo "I: ${1}"; }
die() { echo "E: ${1}" 1>&2; exit ${2:-1}; }
info() { echo -e "I: ${1}"; }
die() { echo -e "E: ${1}" 1>&2; exit ${2:-1}; }
set_status()
{
local _name=${NAME}
local _payload=$(<<< "
local job_name=${NAME}
local payload=$(<<< "
{
'state': '${1}',
'description': '${2}',
'context': 'travis-ci/${_name}',
'context': 'travis-ci/${job_name}',
'target_url': 'https://travis-ci.org/${TRAVIS_REPO_SLUG}/jobs/${TRAVIS_JOB_ID}'
}" tr '"' '"')
@ -36,3 +36,110 @@ set_status()
"https://api.github.com/repos/${TRAVIS_REPO_SLUG}/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT}" \
--data @- <<< "${payload}"
}
_install_gcc()
{
local url="${deps_url}/gcc6-linux.tar.bz2"
local gcc_path="${deps_dir}/gcc/gcc-arm-none-eabi-6-2017-q2-update/"
local archive="gcc.tar.bz2"
info "URL: ${url}"
if [ ! -d "${deps_dir}/gcc" ]; then
info "Downloading archive"
curl --location "${url}" --output "${deps_dir}/${archive}"
ls -al "${deps_dir}"
info "Extracting 'gcc'"
mkdir -p "${deps_dir}/gcc"
tar -xf "${deps_dir}/${archive}" -C "${deps_dir}/gcc"
rm "${deps_dir}/${archive}"
fi
info "Installing 'gcc'"
export "PATH=${gcc_path}/bin:${PATH}"
}
_fetch_deps()
{
local pkg="${1}"
local dep_list="${2}"
info "Fetching '${pkg}' archives"
while read dep; do
curl --location "${deps_url}/${dep}.deb" \
--output "${deps_dir}/${dep}.deb" \
|| die "Download failed ('${dep}')" \
&& info "Fetched ${deps_url}/${dep}.deb" &
done <<< "${dep_list}"
wait
}
_install_deps()
{
local pkg="${1}"
local dep_list="${2}"
# Assume that if the first package isn't cached, none are.
local first_dep=$(<<< "${dep_list}" head -n1)
[ ! -f "${deps_dir}/${first_dep}.deb" ] && _fetch_deps "${pkg}" "${dep_list}"
# Install dependencies
info "Installing '${pkg}' packages"
sudo dpkg -i $(<<< "${dep_list}" sed -e 's_^ *__' -e 's_^\(.*\)$_'"${deps_dir}"'/\1.deb_' | tr $'\n' ' ')
}
source_pkg()
{
local pkg="${1}"
local aspell_deps="aspell
aspell-en
dictionaries-common
libaspell15"
local libfuse_deps="libfuse-dev
libpcre3-dev
libpcre32-3
libpcrecpp0v5
libselinux1-dev
libsepol1-dev
libc-bin"
case "${pkg}" in
"fuse" )
sudo apt-get -o=dir::cache="${deps_dir}/apt-get" install fuse \
|| die "Installation failed"
;;
"aspell" )
_install_deps aspell "${aspell_deps}" \
|| die "Installation failed"
;;
"libfuse-dev" )
_install_deps libfuse-dev "${libfuse_deps}" \
|| die "Installation failed"
;;
"gcc" )
_install_gcc \
|| die "Installation failed"
;;
* )
die "Package not supported: '${pkg}'"
;;
esac
}