Skip to content

ci: fix checking CI_GITHUB_API_KEY, refactoring #5496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 14 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@ stages:
jobs:
include:
# Build stage. To save time, run all kinds of builds and tests in parallel.
#
# TODO: since we can now call different script for each job,
# split the do-it-all common.sh into separate scripts responsible
# for different types of jobs below:
- name: "Host tests"
stage: build
script: $TRAVIS_BUILD_DIR/tests/common.sh
env:
- BUILD_TYPE=host_tests
install:
- sudo apt-get install valgrind lcov
script: $TRAVIS_BUILD_DIR/tests/ci/host_test.sh
install: sudo apt-get install valgrind lcov

# TODO: since we can now call different script for each job,
# split the do-it-all common.sh into separate scripts responsible
# for different types of jobs below:
- name: "Build (1)"
script: $TRAVIS_BUILD_DIR/tests/common.sh
env:
Expand All @@ -51,34 +47,24 @@ jobs:
- BUILD_TYPE=platformio_odd

- name: "Docs"
script: $TRAVIS_BUILD_DIR/tests/common.sh
env:
- BUILD_TYPE=docs
script: $TRAVIS_BUILD_DIR/tests/ci/build_docs.sh
install:
- pip install --user -r doc/requirements.txt;
- sudo apt-get install python3-pip
- pip3 install --user -r doc/requirements.txt;

- name: "Style check"
script: $TRAVIS_BUILD_DIR/tests/common.sh
env:
- BUILD_TYPE=style_check
install:
- >
[ "$BUILD_TYPE" = "style_check" ] && {
[ -f $HOME/astyle/build/gcc/bin/astyle ] || {
wget -O astyle_3.1_linux.tar.gz https://sourceforge.net/projects/astyle/files/astyle/astyle%203.1/astyle_3.1_linux.tar.gz/download;
tar -xf astyle_3.1_linux.tar.gz -C $HOME;
make -C $HOME/astyle/build/gcc;
}
make -C $HOME/astyle/build/gcc prefix=$HOME install;
} || true
script: $TRAVIS_BUILD_DIR/tests/ci/style_check.sh
install: tests/ci/install_astyle.sh

- name: "Boards"
script: $TRAVIS_BUILD_DIR/tests/ci/build_boards.sh

# Deploy stage.
# Here we build the package JSON (always) and do the deployments
- name: "Package / deploy"
stage: deploy
script: $TRAVIS_BUILD_DIR/tests/common.sh
script: tests/ci/build_package.sh
env: BUILD_TYPE=package
if: env(CI_GITHUB_API_KEY) IS present
deploy:
# Create Github release, upload artifacts
- provider: releases
Expand Down
14 changes: 14 additions & 0 deletions tests/ci/build_boards.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
#
# CI job which checks that boards.txt and package_esp8266com_index.template.json are up to date

set -ev

cd $TRAVIS_BUILD_DIR

tools/boards.txt.py --boardsgen --ldgen --packagegen --docgen

git diff --exit-code -- boards.txt \
doc/boards.rst \
tools/sdk/ld/
git diff --exit-code -w -- package/package_esp8266com_index.template.json
9 changes: 9 additions & 0 deletions tests/ci/build_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
#
# CI job to run the documentation build

set -ev

cd $TRAVIS_BUILD_DIR/doc

SPHINXOPTS="-W" make html
16 changes: 16 additions & 0 deletions tests/ci/build_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#
# CI job which builds the boards manager package

set -ev

export PKG_URL=https://github.com/esp8266/Arduino/releases/download/$TRAVIS_TAG/esp8266-$TRAVIS_TAG.zip
export DOC_URL=https://arduino-esp8266.readthedocs.io/en/$TRAVIS_TAG/

if [ -z "$CI_GITHUB_API_KEY" ]; then
echo "Github API key not set. Skip building the package."
exit 0
fi

cd $TRAVIS_BUILD_DIR/package
./build_boards_manager_package.sh
10 changes: 10 additions & 0 deletions tests/ci/host_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
#
# CI job for running tests on the host

set -ev

cd $TRAVIS_BUILD_DIR/tests/host

make CI
make clean-objects
16 changes: 16 additions & 0 deletions tests/ci/install_astyle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#
# $HOME/astyle directory is cached on Travis.
# If cached build is not present, download astyle and build it.
# Install built astyle binary into the home directory.
#

set -e

if [ ! -f $HOME/astyle/build/gcc/bin/astyle ]; then
wget -O astyle_3.1_linux.tar.gz https://sourceforge.net/projects/astyle/files/astyle/astyle%203.1/astyle_3.1_linux.tar.gz/download
tar -xf astyle_3.1_linux.tar.gz -C $HOME
make -C $HOME/astyle/build/gcc
fi

make -C $HOME/astyle/build/gcc prefix=$HOME install
16 changes: 16 additions & 0 deletions tests/ci/style_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#
# CI job for checking examples style

set -ev

find $TRAVIS_BUILD_DIR/libraries -name '*.ino' -exec \
astyle \
--suffix=none \
--options=$TRAVIS_BUILD_DIR/tests/examples_style.conf {} \;

# Revert changes which astyle might have done to the submodules,
# as we don't want to fail the build because of the 3rd party libraries
git submodule foreach --recursive git reset --hard

git diff --exit-code -- $TRAVIS_BUILD_DIR/libraries
66 changes: 1 addition & 65 deletions tests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,37 +126,6 @@ function install_ide()
export PATH="$ide_path:$core_path/tools/xtensa-lx106-elf/bin:$PATH"
}

function build_docs()
{
SPHINXOPTS="-W" make html
}

function run_host_tests()
{
pushd host
make CI
make clean-objects
popd
}

function build_package()
{
export PKG_URL=https://github.com/esp8266/Arduino/releases/download/$TRAVIS_TAG/esp8266-$TRAVIS_TAG.zip
export DOC_URL=https://arduino-esp8266.readthedocs.io/en/$TRAVIS_TAG/
./build_boards_manager_package.sh
}

function build_boards()
{
echo -e "travis_fold:start:build_boards"
tools/boards.txt.py --boardsgen --ldgen --packagegen --docgen
git diff --exit-code -- boards.txt \
doc/boards.rst \
tools/sdk/ld/
git diff --exit-code -w -- package/package_esp8266com_index.template.json
echo -e "travis_fold:end:build_boards"
}

function install_platformio()
{
pip install --user -U https://github.com/platformio/platformio/archive/develop.zip
Expand Down Expand Up @@ -239,22 +208,6 @@ function build_sketches_with_arduino()
echo -e "travis_fold:end:size_report"
}

function check_examples_style()
{
echo -e "travis_fold:start:check_examples_style"

find $TRAVIS_BUILD_DIR/libraries -name '*.ino' -exec \
astyle \
--suffix=none \
--options=$TRAVIS_BUILD_DIR/tests/examples_style.conf {} \;

# we have no control over submodules
git submodule foreach --recursive git reset --hard

git diff --exit-code -- $TRAVIS_BUILD_DIR/libraries

echo -e "travis_fold:end:check_examples_style"
}

set -e

Expand Down Expand Up @@ -293,25 +246,8 @@ elif [ "$BUILD_TYPE" = "platformio_odd" ]; then
# PlatformIO
install_platformio
build_sketches_with_platformio $TRAVIS_BUILD_DIR/libraries "--board nodemcuv2 --verbose" 2 1
elif [ "$BUILD_TYPE" = "docs" ]; then
# Build documentation using Sphinx
cd $TRAVIS_BUILD_DIR/doc
build_docs
elif [ "$BUILD_TYPE" = "package" ]; then
# Check that boards.txt, ld scripts, package JSON template, and boards.rst are up to date
build_boards
# Build release package
cd $TRAVIS_BUILD_DIR/package
build_package
elif [ "$BUILD_TYPE" = "host_tests" ]; then
# Run host side tests
cd $TRAVIS_BUILD_DIR/tests
run_host_tests
elif [ "$BUILD_TYPE" = "style_check" ]; then
# Check code style
check_examples_style
else
echo "BUILD_TYPE not set"
echo "BUILD_TYPE not set or invalid"
exit 1
fi