Skip to content

Commit 0dd5f03

Browse files
committed
ci: split build jobs into separate shell scripts
1 parent 2687712 commit 0dd5f03

8 files changed

+95
-97
lines changed

Diff for: .travis.yml

+13-32
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,14 @@ stages:
1313
jobs:
1414
include:
1515
# Build stage. To save time, run all kinds of builds and tests in parallel.
16-
#
17-
# TODO: since we can now call different script for each job,
18-
# split the do-it-all common.sh into separate scripts responsible
19-
# for different types of jobs below:
2016
- name: "Host tests"
2117
stage: build
22-
script: $TRAVIS_BUILD_DIR/tests/common.sh
23-
env:
24-
- BUILD_TYPE=host_tests
25-
install:
26-
- sudo apt-get install valgrind lcov
18+
script: $TRAVIS_BUILD_DIR/tests/ci/host_test.sh
19+
install: sudo apt-get install valgrind lcov
2720

21+
# TODO: since we can now call different script for each job,
22+
# split the do-it-all common.sh into separate scripts responsible
23+
# for different types of jobs below:
2824
- name: "Build (1)"
2925
script: $TRAVIS_BUILD_DIR/tests/common.sh
3026
env:
@@ -51,36 +47,21 @@ jobs:
5147
- BUILD_TYPE=platformio_odd
5248

5349
- name: "Docs"
54-
script: $TRAVIS_BUILD_DIR/tests/common.sh
55-
env:
56-
- BUILD_TYPE=docs
57-
install:
58-
- pip install --user -r doc/requirements.txt;
50+
script: $TRAVIS_BUILD_DIR/tests/ci/build_docs.sh
51+
install: pip install --user -r doc/requirements.txt;
5952

6053
- name: "Style check"
61-
script: $TRAVIS_BUILD_DIR/tests/common.sh
62-
env:
63-
- BUILD_TYPE=style_check
64-
install:
65-
- >
66-
if [ ! -f $HOME/astyle/build/gcc/bin/astyle ]; then
67-
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;
68-
tar -xf astyle_3.1_linux.tar.gz -C $HOME;
69-
make -C $HOME/astyle/build/gcc;
70-
fi
71-
make -C $HOME/astyle/build/gcc prefix=$HOME install;
54+
script: $TRAVIS_BUILD_DIR/tests/ci/style_check.sh
55+
install: tests/ci/install_astyle.sh
56+
57+
- name: "Boards"
58+
script: $TRAVIS_BUILD_DIR/tests/ci/build_boards.sh
7259

7360
# Deploy stage.
7461
# Here we build the package JSON (always) and do the deployments
7562
- name: "Package / deploy"
7663
stage: deploy
77-
script:
78-
- >
79-
if [ -n "$CI_GITHUB_API_KEY" ]; then
80-
$TRAVIS_BUILD_DIR/tests/common.sh
81-
else
82-
echo "Not building the package."
83-
fi
64+
script: tests/ci/build_package.sh
8465
env: BUILD_TYPE=package
8566
deploy:
8667
# Create Github release, upload artifacts

Diff for: tests/ci/build_boards.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
#
3+
# CI job which checks that boards.txt and package_esp8266com_index.template.json are up to date
4+
5+
set -ev
6+
7+
cd $TRAVIS_BUILD_DIR
8+
9+
tools/boards.txt.py --boardsgen --ldgen --packagegen --docgen
10+
11+
git diff --exit-code -- boards.txt \
12+
doc/boards.rst \
13+
tools/sdk/ld/
14+
git diff --exit-code -w -- package/package_esp8266com_index.template.json

Diff for: tests/ci/build_docs.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
#
3+
# CI job to run the documentation build
4+
5+
set -ev
6+
7+
cd $TRAVIS_BUILD_DIR/doc
8+
9+
SPHINXOPTS="-W" make html

Diff for: tests/ci/build_package.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
#
3+
# CI job which builds the boards manager package
4+
5+
set -ev
6+
7+
export PKG_URL=https://github.com/esp8266/Arduino/releases/download/$TRAVIS_TAG/esp8266-$TRAVIS_TAG.zip
8+
export DOC_URL=https://arduino-esp8266.readthedocs.io/en/$TRAVIS_TAG/
9+
10+
if [ -z "$CI_GITHUB_API_KEY" ]; then
11+
echo "Github API key not set. Skip building the package."
12+
exit 0
13+
fi
14+
15+
cd $TRAVIS_BUILD_DIR/package
16+
./build_boards_manager_package.sh

Diff for: tests/ci/host_test.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
#
3+
# CI job for running tests on the host
4+
5+
set -ev
6+
7+
cd $TRAVIS_BUILD_DIR/tests/host
8+
9+
make CI
10+
make clean-objects

Diff for: tests/ci/install_astyle.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
#
3+
# $HOME/astyle directory is cached on Travis.
4+
# If cached build is not present, download astyle and build it.
5+
# Install built astyle binary into the home directory.
6+
#
7+
8+
set -e
9+
10+
if [ ! -f $HOME/astyle/build/gcc/bin/astyle ]; then
11+
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
12+
tar -xf astyle_3.1_linux.tar.gz -C $HOME
13+
make -C $HOME/astyle/build/gcc
14+
fi
15+
16+
make -C $HOME/astyle/build/gcc prefix=$HOME install

Diff for: tests/ci/style_check.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
#
3+
# CI job for checking examples style
4+
5+
set -ev
6+
7+
find $TRAVIS_BUILD_DIR/libraries -name '*.ino' -exec \
8+
astyle \
9+
--suffix=none \
10+
--options=$TRAVIS_BUILD_DIR/tests/examples_style.conf {} \;
11+
12+
# Revert changes which astyle might have done to the submodules,
13+
# as we don't want to fail the build because of the 3rd party libraries
14+
git submodule foreach --recursive git reset --hard
15+
16+
git diff --exit-code -- $TRAVIS_BUILD_DIR/libraries

Diff for: tests/common.sh

+1-65
Original file line numberDiff line numberDiff line change
@@ -126,37 +126,6 @@ function install_ide()
126126
export PATH="$ide_path:$core_path/tools/xtensa-lx106-elf/bin:$PATH"
127127
}
128128

129-
function build_docs()
130-
{
131-
SPHINXOPTS="-W" make html
132-
}
133-
134-
function run_host_tests()
135-
{
136-
pushd host
137-
make CI
138-
make clean-objects
139-
popd
140-
}
141-
142-
function build_package()
143-
{
144-
export PKG_URL=https://github.com/esp8266/Arduino/releases/download/$TRAVIS_TAG/esp8266-$TRAVIS_TAG.zip
145-
export DOC_URL=https://arduino-esp8266.readthedocs.io/en/$TRAVIS_TAG/
146-
./build_boards_manager_package.sh
147-
}
148-
149-
function build_boards()
150-
{
151-
echo -e "travis_fold:start:build_boards"
152-
tools/boards.txt.py --boardsgen --ldgen --packagegen --docgen
153-
git diff --exit-code -- boards.txt \
154-
doc/boards.rst \
155-
tools/sdk/ld/
156-
git diff --exit-code -w -- package/package_esp8266com_index.template.json
157-
echo -e "travis_fold:end:build_boards"
158-
}
159-
160129
function install_platformio()
161130
{
162131
pip install --user -U https://github.com/platformio/platformio/archive/develop.zip
@@ -239,22 +208,6 @@ function build_sketches_with_arduino()
239208
echo -e "travis_fold:end:size_report"
240209
}
241210

242-
function check_examples_style()
243-
{
244-
echo -e "travis_fold:start:check_examples_style"
245-
246-
find $TRAVIS_BUILD_DIR/libraries -name '*.ino' -exec \
247-
astyle \
248-
--suffix=none \
249-
--options=$TRAVIS_BUILD_DIR/tests/examples_style.conf {} \;
250-
251-
# we have no control over submodules
252-
git submodule foreach --recursive git reset --hard
253-
254-
git diff --exit-code -- $TRAVIS_BUILD_DIR/libraries
255-
256-
echo -e "travis_fold:end:check_examples_style"
257-
}
258211

259212
set -e
260213

@@ -293,25 +246,8 @@ elif [ "$BUILD_TYPE" = "platformio_odd" ]; then
293246
# PlatformIO
294247
install_platformio
295248
build_sketches_with_platformio $TRAVIS_BUILD_DIR/libraries "--board nodemcuv2 --verbose" 2 1
296-
elif [ "$BUILD_TYPE" = "docs" ]; then
297-
# Build documentation using Sphinx
298-
cd $TRAVIS_BUILD_DIR/doc
299-
build_docs
300-
elif [ "$BUILD_TYPE" = "package" ]; then
301-
# Check that boards.txt, ld scripts, package JSON template, and boards.rst are up to date
302-
build_boards
303-
# Build release package
304-
cd $TRAVIS_BUILD_DIR/package
305-
build_package
306-
elif [ "$BUILD_TYPE" = "host_tests" ]; then
307-
# Run host side tests
308-
cd $TRAVIS_BUILD_DIR/tests
309-
run_host_tests
310-
elif [ "$BUILD_TYPE" = "style_check" ]; then
311-
# Check code style
312-
check_examples_style
313249
else
314-
echo "BUILD_TYPE not set"
250+
echo "BUILD_TYPE not set or invalid"
315251
exit 1
316252
fi
317253

0 commit comments

Comments
 (0)