From 5f40538c594fafa40ab6cb2802bfef079c8d7625 Mon Sep 17 00:00:00 2001 From: Cruz Monrreal II Date: Thu, 7 Mar 2019 13:20:43 -0600 Subject: [PATCH] Re-enabled PR status reporting. Added external bash file to source functions from --- .travis.yml | 27 +++++++++++++++------- tools/test/travis-ci/functions.sh | 38 +++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 tools/test/travis-ci/functions.sh diff --git a/.travis.yml b/.travis.yml index 16eaa89a48..7633a3e92e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,26 +18,37 @@ language: sh os: linux dist: xenial + cache: pip: true directories: - $HOME/.cache/apt - $HOME/gcc-arm-none-eabi-6-2017-q2-update + before_install: + - source tools/test/travis-ci/functions.sh + - set_status "pending" "Test started." + # Make sure pipefail - - set -o 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 + #- 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 + #- 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 + #- 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) + #- travis_retry $(! sudo apt-get update 2>&1 |grep Failed) + +after_success: + - set_status "success" "Success!" + +after_failure: + -set_status "failure" "Test failed." matrix: diff --git a/tools/test/travis-ci/functions.sh b/tools/test/travis-ci/functions.sh new file mode 100644 index 0000000000..2d6ad88213 --- /dev/null +++ b/tools/test/travis-ci/functions.sh @@ -0,0 +1,38 @@ +#!/bin/bash -euf +# +# Copyright (c) 2013-2018 Arm Limited. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the License); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an AS IS BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o pipefail + +info() { echo "I: ${1}"; } +die() { echo "E: ${1}" 1>&2; exit ${2:-1}; } + +set_status() +{ + local _name=${NAME} + local _payload=$(<<< " + { + 'state': '${1}', + 'description': '${2}', + 'context': 'travis-ci/${_name}', + 'target_url': 'https://travis-ci.org/${TRAVIS_REPO_SLUG}/jobs/${TRAVIS_JOB_ID}' + }" tr '"' '"') + + curl --silent --output /dev/null --user "${MBED_BOT}" --request POST \ + "https://api.github.com/repos/${TRAVIS_REPO_SLUG}/statuses/${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT}" \ + --data @- <<< "${payload}" +}