Skip to content

Commit 9c1e03a

Browse files
committed
ci: use travis jobs to structure the CI flow
This mostly re-phrases the existing flow using the new language. Ref. https://blog.travis-ci.com/2017-05-11-introducing-build-stages
1 parent 47d6f83 commit 9c1e03a

File tree

2 files changed

+99
-65
lines changed

2 files changed

+99
-65
lines changed

.travis.yml

+92-62
Original file line numberDiff line numberDiff line change
@@ -6,73 +6,103 @@ cache:
66
directories:
77
- $HOME/astyle
88

9-
matrix:
9+
stages:
10+
- build
11+
- deploy
12+
13+
jobs:
1014
include:
11-
- env:
12-
- BUILD_TYPE=package
13-
- env:
14-
- BUILD_TYPE=build_even
15-
- env:
16-
- BUILD_TYPE=build_odd
17-
- env:
18-
- BUILD_TYPE=debug_even
19-
- env:
20-
- BUILD_TYPE=debug_odd
21-
- env:
22-
- BUILD_TYPE=platformio_even
23-
- env:
24-
- BUILD_TYPE=platformio_odd
25-
- env:
26-
- BUILD_TYPE=docs
27-
- env:
28-
- BUILD_TYPE=host_tests
29-
- env:
30-
- BUILD_TYPE=style_check
15+
# 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:
20+
- name: "Host tests"
21+
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
27+
28+
- name: "Build (1)"
29+
script: $TRAVIS_BUILD_DIR/tests/common.sh
30+
env:
31+
- BUILD_TYPE=build_even
32+
- name: "Build (2)"
33+
script: $TRAVIS_BUILD_DIR/tests/common.sh
34+
env:
35+
- BUILD_TYPE=build_odd
36+
- name: "Debug (1)"
37+
script: $TRAVIS_BUILD_DIR/tests/common.sh
38+
env:
39+
- BUILD_TYPE=debug_even
40+
- name: "Debug (2)"
41+
script: $TRAVIS_BUILD_DIR/tests/common.sh
42+
env:
43+
- BUILD_TYPE=debug_odd
44+
- name: "Platformio (1)"
45+
script: $TRAVIS_BUILD_DIR/tests/common.sh
46+
env:
47+
- BUILD_TYPE=platformio_even
48+
- name: "Platformio (2)"
49+
script: $TRAVIS_BUILD_DIR/tests/common.sh
50+
env:
51+
- BUILD_TYPE=platformio_odd
3152

32-
install:
33-
- >
34-
[ "$BUILD_TYPE" = "docs" ] && {
35-
pip install --user -r doc/requirements.txt;
36-
} || true
37-
- >
38-
[ "$BUILD_TYPE" = "style_check" ] && {
39-
[ -f $HOME/astyle/build/gcc/bin/astyle ] || {
40-
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;
41-
tar -xf astyle_3.1_linux.tar.gz -C $HOME;
42-
make -C $HOME/astyle/build/gcc;
43-
}
44-
make -C $HOME/astyle/build/gcc prefix=$HOME install;
45-
} || true
46-
- sudo apt-get install valgrind lcov
53+
- 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;
4759

48-
script:
49-
- $TRAVIS_BUILD_DIR/tests/common.sh
60+
- name: "Style check"
61+
script: $TRAVIS_BUILD_DIR/tests/common.sh
62+
env:
63+
- BUILD_TYPE=style_check
64+
install:
65+
- >
66+
[ "$BUILD_TYPE" = "style_check" ] && {
67+
[ -f $HOME/astyle/build/gcc/bin/astyle ] || {
68+
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;
69+
tar -xf astyle_3.1_linux.tar.gz -C $HOME;
70+
make -C $HOME/astyle/build/gcc;
71+
}
72+
make -C $HOME/astyle/build/gcc prefix=$HOME install;
73+
} || true
5074
51-
deploy:
52-
- provider: releases
53-
draft: true
54-
skip_cleanup: true
55-
api_key:
56-
secure: A4FBmqyhlzy33oPeZVolg2Q/A3ZcJ3WnRQqQJ3NAPy+qGM5xcboOYtwcLL9vKaHZGfUB7lUP9QVZFGou1Wrmo9DnPvAoe3+XvCaDRGzVMxeIpu7UStbBD4Knbh98tlbMvZCXYRlT4VcusI9bMLK6UWw4sMdPislBh2FEfglTiag=
57-
file_glob: true
58-
tag_name: $TRAVIS_TAG
59-
target_commitish: $TRAVIS_COMMIT
60-
file:
61-
- package/versions/$TRAVIS_TAG/esp8266-$TRAVIS_TAG.zip
62-
- package/versions/$TRAVIS_TAG/package_esp8266com_index.json
63-
on:
64-
repo: esp8266/Arduino
65-
tags: true
66-
condition: "$BUILD_TYPE = package"
67-
68-
- provider: script
69-
skip_cleanup: true
70-
script: bash package/deploy_package_index.sh
71-
on:
72-
repo: esp8266/Arduino
73-
tags: true
74-
condition: "$BUILD_TYPE = package"
75+
# Deploy stage.
76+
# Here we build the package JSON (always) and do the deployments
77+
- name: "Package / deploy"
78+
stage: deploy
79+
script: $TRAVIS_BUILD_DIR/tests/common.sh
80+
env: BUILD_TYPE=package
81+
if: env(CI_GITHUB_API_KEY) IS present
82+
deploy:
83+
# Create Github release, upload artifacts
84+
- provider: releases
85+
draft: true
86+
skip_cleanup: true
87+
api_key:
88+
secure: kYsxX/N21fwLSTLpbb0c96PnQHn1CIMqZstm02hfUhCX83FygWSh4vs3gzW28DMpjQMZ6vC4g+jtfosYU2tUhht/bynurDH4edpEyGeMyK+fzCI9pAr4JT0RbKQI84EC18ScpgP/UP0jTc1LJ+xl8UMwSiDE0mzHx7xJ4mMNQbA=
89+
file_glob: true
90+
tag_name: $TRAVIS_TAG
91+
target_commitish: $TRAVIS_COMMIT
92+
file:
93+
- package/versions/$TRAVIS_TAG/esp8266-$TRAVIS_TAG.zip
94+
- package/versions/$TRAVIS_TAG/package_esp8266com_index.json
95+
on:
96+
repo: esp8266/Arduino
97+
tags: true
7598

99+
# Update the package index URL to point to the new version
100+
- provider: script
101+
skip_cleanup: true
102+
script: bash package/deploy_package_index.sh
103+
on:
104+
repo: esp8266/Arduino
105+
tags: true
76106

77107
notifications:
78108
email:

package/build_boards_manager_package.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ else
1818
plain_ver=$ver
1919
fi
2020

21-
# 'set -e' breaks CI but not local tests
22-
#set -e
21+
set -e
2322

2423
package_name=esp8266-$ver
2524
echo "Version: $ver"
@@ -134,8 +133,13 @@ fi
134133
cat $srcdir/package/package_esp8266com_index.template.json | \
135134
jq "$jq_arg" > package_esp8266com_index.json
136135

136+
# Use Github API token, if available
137+
curl_gh_token_arg=()
138+
if [ ! -z "$CI_GITHUB_API_KEY" ]; then
139+
curl_gh_token_arg=(-H "Authorization: token $CI_GITHUB_API_KEY")
140+
fi
137141
# Get previous release name
138-
curl --silent https://api.github.com/repos/esp8266/Arduino/releases > releases.json
142+
curl --silent "${curl_gh_token_arg[@]}" https://api.github.com/repos/esp8266/Arduino/releases > releases.json
139143
# Previous final release (prerelase == false)
140144
prev_release=$(jq -r '. | map(select(.draft == false and .prerelease == false)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name' releases.json)
141145
# Previous release (possibly a pre-release)

0 commit comments

Comments
 (0)