From 06767cc548376aee6a58210b551e302b6b02ab67 Mon Sep 17 00:00:00 2001 From: Cruz Monrreal II Date: Thu, 10 Jan 2019 22:28:51 -0600 Subject: [PATCH 1/2] Corrected simplified astyle job behavior when base branch is not master Consolidated efforts from PR #9336. Previous job's env vars would not be populated correctly if the base branch of a PR was not master. Corected by pulling remaining respository information to perform comparison between read-only instance of PR and base branch. --- .travis.yml | 52 +++++++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index f65545b35ac..3ba7555a25e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -134,43 +134,25 @@ matrix: - env: - NAME=astyle install: - - curl -L0 https://mbed-os.s3-eu-west-1.amazonaws.com/builds/deps/astyle_3.1_linux.tar.gz --output astyle.tar.gz; - mkdir -p BUILD && tar xf astyle.tar.gz -C BUILD; - pushd BUILD/astyle/build/gcc; - make; - export PATH=$PWD/bin:$PATH; - popd; - - astyle --version + - >- + curl -L0 https://mbed-os.s3-eu-west-1.amazonaws.com/builds/deps/astyle_3.1_linux.tar.gz --output astyle.tar.gz; + mkdir -p BUILD && tar xf astyle.tar.gz -C BUILD; + cd BUILD/astyle/build/gcc; + make; + export PATH=$PWD/bin:$PATH; + cd - + - astyle --version + # Fetch remaining information needed for branch comparison + - git fetch --all --unshallow --tags + - git fetch origin "${TRAVIS_BRANCH}" script: - # only changed files this time - git diff --name-only --diff-filter=d $TRAVIS_BRANCH | grep '.*\.\(h\|c\|hpp\|cpp\)$' | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle-files-changed.out; - if [ $(cat astyle-files-changed.out | grep Formatted | wc -l) -ne 0 ]; then - git --no-pager diff; - echo ""; - echo "AStyle check failed, please fix style issues as shown above"; - (exit 1); - else - echo "Coding style check OK"; - fi - after_success: - # run astyle for all files on the branch - - git checkout -- . - - find -regex '.*\.\(h\|c\|hpp\|cpp\)$' -type f | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle-branch.out; - # update status if we succeeded, compare with master if possible - - | - CURR=$(cat astyle-branch.out | grep Formatted | wc -l) - PREV=$(curl -u "$MBED_BOT" https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \ - | jq -re "select(.sha != \"$TRAVIS_COMMIT\") - | .statuses[] | select(.context == \"travis-ci/$NAME\").description - | capture(\", (?[0-9]+) files\").files" \ - || echo 0) + - >- + git diff --name-only --diff-filter=d FETCH_HEAD..HEAD \ + | ( grep '.\(c\|cpp\|h\|hpp\)$' || true ) \ + | ( fgrep -v -f .astyleignore || true ) \ + | while read file; do astyle -n --options=.astylerc "${file}"; done + - git diff --exit-code --diff-filter=d --color - STATUSM="Passed, ${CURR} files" - if [ "$PREV" -ne 0 ] - then - STATUSM="$STATUSM ($(python -c "print '%+d' % ($CURR-$PREV)") files)" - fi - - bash -c "$STATUS" success "$STATUSM" - env: - NAME=events - EVENTS=events From 1b6b1caeffca6c7494108afd1835cf32167857f8 Mon Sep 17 00:00:00 2001 From: Martin Kojtal Date: Tue, 8 Jan 2019 12:52:08 +0000 Subject: [PATCH 2/2] travis: add keys for ubuntu - workaround --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3ba7555a25e..154334df716 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,6 +46,8 @@ before_install: # 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)