1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

ci: split build jobs into separate shell scripts

This commit is contained in:
Ivan Grokhotkov 2018-12-14 16:53:54 +08:00
parent 2687712772
commit 0dd5f034f2
8 changed files with 95 additions and 97 deletions

View File

@ -13,18 +13,14 @@ stages:
jobs:
include:
# Build stage. To save time, run all kinds of builds and tests in parallel.
#
- name: "Host tests"
stage: build
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: "Host tests"
stage: build
script: $TRAVIS_BUILD_DIR/tests/common.sh
env:
- BUILD_TYPE=host_tests
install:
- sudo apt-get install valgrind lcov
- name: "Build (1)"
script: $TRAVIS_BUILD_DIR/tests/common.sh
env:
@ -51,36 +47,21 @@ jobs:
- BUILD_TYPE=platformio_odd
- name: "Docs"
script: $TRAVIS_BUILD_DIR/tests/common.sh
env:
- BUILD_TYPE=docs
install:
- pip install --user -r doc/requirements.txt;
script: $TRAVIS_BUILD_DIR/tests/ci/build_docs.sh
install: pip install --user -r doc/requirements.txt;
- name: "Style check"
script: $TRAVIS_BUILD_DIR/tests/common.sh
env:
- BUILD_TYPE=style_check
install:
- >
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;
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:
- >
if [ -n "$CI_GITHUB_API_KEY" ]; then
$TRAVIS_BUILD_DIR/tests/common.sh
else
echo "Not building the package."
fi
script: tests/ci/build_package.sh
env: BUILD_TYPE=package
deploy:
# Create Github release, upload artifacts

14
tests/ci/build_boards.sh Executable file
View File

@ -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
tests/ci/build_docs.sh Executable file
View File

@ -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
tests/ci/build_package.sh Executable file
View File

@ -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
tests/ci/host_test.sh Executable file
View File

@ -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
tests/ci/install_astyle.sh Executable file
View File

@ -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
tests/ci/style_check.sh Executable file
View File

@ -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

View File

@ -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
@ -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
@ -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