Skip to content

Commit 89caada

Browse files
committed
CI: Split extra checks out into separate jobs
This avoids the extra checks being done redundantly multiple times. This allows specifying the go language for the shfmt job, which seems to have suddenly become necessary. This makes it easier to determine the result of the build by looking at a summary on the jobs list page.
1 parent cbc6586 commit 89caada

File tree

1 file changed

+101
-71
lines changed

1 file changed

+101
-71
lines changed

.travis.yml

Lines changed: 101 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,129 @@
11
# This file is used to test the script with Travis CI
22

3-
# Although sudo is no longer required by arduino-ci-script since the 1.0.0 release, for some reason setting "sudo: false" causes the Travis CI build time to significantly increase so this setting is left as "sudo: required"
4-
sudo: required
5-
6-
7-
# It's necessary to do this just for codespell
8-
language: python
9-
python: 3.6
10-
11-
123
env:
134
global:
145
# The Arduino IDE will be installed at APPLICATION_FOLDER/arduino
156
- APPLICATION_FOLDER="${HOME}/arduino-ide"
167
- SKETCHBOOK_FOLDER="${HOME}/arduino-sketchbook"
8+
matrix:
9+
allow_failures:
10+
# define the key used to determine whether job failures are allowed
11+
# The expected behavior of this job is failure because 1.6.3 doesn't support boards manager installation.
12+
- env: INSTALL_IDE_START_VERSION="1.6.3" VERBOSITY_LEVEL=2 VERBOSE_COMPILATION="false"
13+
include:
14+
1715

18-
matrix:
1916
# Test install_ide with no argument (using full version list). Causes the job to exceed Travis CI's maximum duration and thus can not be run.
20-
# - INSTALL_IDE_START_VERSION=""
17+
#- env: INSTALL_IDE_START_VERSION=""
18+
#language: generic
19+
2120

2221
# Test install_ide using full version list. Causes the job to exceed Travis CI's maximum duration and thus can not be run.
23-
#- INSTALL_IDE_START_VERSION="all" VERBOSITY_LEVEL=0 VERBOSE_COMPILATION="false"
22+
#- env: INSTALL_IDE_START_VERSION="all" VERBOSITY_LEVEL=0 VERBOSE_COMPILATION="false"
23+
#language: generic
24+
2425

2526
# Test install_ide using custom version list
2627
# Test the use of the special version names "oldest", "newest", and "hourly" in a version list.
2728
# Test duplicates in version list
28-
- INSTALL_IDE_START_VERSION='("oldest" "1.8.3" "1.8.4" "1.8.4" "newest" "hourly")' VERBOSITY_LEVEL=1 VERBOSE_COMPILATION="true"
29+
- env: INSTALL_IDE_START_VERSION='("oldest" "1.8.3" "1.8.4" "1.8.4" "newest" "hourly")' VERBOSITY_LEVEL=1 VERBOSE_COMPILATION="true"
30+
language: generic
31+
2932

3033
# Test install_ide using version range.
3134
# Test the use of the special version name "newest" in a version range.
3235
# Test installing the full sane range of IDE versions
33-
- INSTALL_IDE_START_VERSION="1.6.5-r5" INSTALL_IDE_END_VERSION="newest" VERBOSITY_LEVEL=0 VERBOSE_COMPILATION="false"
36+
- env: INSTALL_IDE_START_VERSION="1.6.5-r5" INSTALL_IDE_END_VERSION="newest" VERBOSITY_LEVEL=0 VERBOSE_COMPILATION="false"
37+
language: generic
38+
3439

3540
# Test the use of the special version name "hourly" in a version range.
36-
- INSTALL_IDE_START_VERSION="1.8.3" INSTALL_IDE_END_VERSION="hourly" VERBOSITY_LEVEL=0 VERBOSE_COMPILATION="false"
41+
- env: INSTALL_IDE_START_VERSION="1.8.3" INSTALL_IDE_END_VERSION="hourly" VERBOSITY_LEVEL=0 VERBOSE_COMPILATION="false"
42+
language: generic
43+
3744

3845
# Allowed to fail
3946
# Test install_ide using single version
4047
# Test the failure behavior of install_package when a Boards Manager installation is attempted using an IDE version that doesn't support it.
41-
- INSTALL_IDE_START_VERSION="1.6.3" VERBOSITY_LEVEL=2 VERBOSE_COMPILATION="false"
42-
43-
44-
matrix:
45-
allow_failures:
46-
# The expected behavior is failure because 1.6.3 doesn't support boards manager installation.
4748
- env: INSTALL_IDE_START_VERSION="1.6.3" VERBOSITY_LEVEL=2 VERBOSE_COMPILATION="false"
48-
49-
50-
before_install:
51-
# Check for issues in the script
52-
- shellcheck arduino-ci-script.sh
53-
54-
# Check script's formatting
55-
- go get -u mvdan.cc/sh/cmd/shfmt
56-
- shfmt -i 2 -d .
57-
58-
# Run unit tests
59-
- git clone https://github.com/bats-core/bats-core.git
60-
- cd bats-core
61-
# Get new tags from the remote
62-
- git fetch --tags
63-
# Checkout the latest tag
64-
- git checkout $(git describe --tags `git rev-list --tags --max-count=1`)
65-
- sudo ./install.sh /usr/local
66-
- cd ..
67-
- rm --recursive --force bats-core
68-
- bats --version
69-
- cd ..
70-
- git clone https://github.com/per1234/arduino-ci-script-tests
71-
- cd arduino-ci-script-tests
72-
- bats check_keywords_txt.bats
73-
- bats check_library_manager_compliance.bats
74-
- bats check_library_properties.bats
75-
- bats check_library_structure.bats
76-
- bats check_sketch_structure.bats
77-
- bats miscellaneous.bats
78-
- cd ../arduino-ci-script
79-
80-
# Formatting checks:
81-
# Check for files starting with a blank line
82-
- find . -path ./.git -prune -o -type f -print0 | xargs -0 -L1 bash -c 'head -1 "$0" | grep --binary-files=without-match --regexp="^$"; if [[ "$?" == "0" ]]; then echo "Blank line found at start of $0."; false; fi'
83-
# Check for tabs
84-
- find . -path './.git' -prune -or -path './tests/check_keywords_txt' -prune -or -path './tests/check_library_manager_compliance' -prune -or -path './tests/check_library_properties' -prune -or -path './tests/check_library_structure' -prune -or -not -path './tests/check_library_properties.bats' -or -type f -exec grep --with-filename --line-number --binary-files=without-match --regexp=$'\t' '{}' \; -exec echo 'Tab found.' \; -exec false '{}' +
85-
# Check for trailing whitespace
86-
- find . -path './.git' -prune -or -path './tests/check_library_properties' -prune -or -type f -exec grep --with-filename --line-number --binary-files=without-match --regexp='[[:blank:]]$' '{}' \; -exec echo 'Trailing whitespace found.' \; -exec false '{}' +
87-
# Check for non-Unix line endings
88-
- find . -path './.git' -prune -or -path './tests/check_keywords_txt' -prune -or -path './tests/check_library_manager_compliance' -prune -or -path './tests/check_library_properties' -prune -or -path './tests/check_library_structure' -prune -or -type f -exec grep --files-with-matches --regexp=$'\r$' '{}' \; -exec echo 'Non-Unix EOL detected.' \; -exec false '{}' +
89-
# Check for blank lines at end of files
90-
- find . -path ./.git -prune -o -type f -print0 | xargs -0 -L1 bash -c 'tail -1 "$0" | grep --binary-files=without-match --regexp="^$"; if [[ "$?" == "0" ]]; then echo "Blank line found at end of $0."; false; fi'
91-
# Check for files that don't end in a newline (https://stackoverflow.com/a/25686825)
92-
- find . -path ./.git -prune -or -path './tests/check_keywords_txt' -prune -or -path './tests/check_library_manager_compliance' -prune -or -path './tests/check_library_properties' -prune -or -path './tests/check_library_structure' -prune -or -type f -print0 | xargs -0 -L1 bash -c 'if test "$(grep --files-with-matches --binary-files=without-match --max-count=1 --regexp='.*' "$0")" && test "$(tail --bytes=1 "$0")"; then echo "No new line at end of $0."; false; fi'
93-
94-
# Check for typos
95-
- pip install codespell
96-
- codespell --skip="${TRAVIS_BUILD_DIR}/.git" --ignore-words="${TRAVIS_BUILD_DIR}/etc/codespell-ignore-words-list.txt" "${TRAVIS_BUILD_DIR}"
97-
49+
language: generic
50+
51+
52+
# Check for common issues with scripts
53+
- name: 'ShellCheck'
54+
language: minimal
55+
# Must define an empty install phase so that the default one won't be used
56+
install: true
57+
script:
58+
- shellcheck arduino-ci-script.sh
59+
60+
61+
# Check for inconsistent script formatting
62+
- name: 'Script Formatting Check'
63+
language: go
64+
install:
65+
- go get -u mvdan.cc/sh/cmd/shfmt
66+
script:
67+
- shfmt -i 2 -d .
68+
69+
70+
- name: 'Unit Tests'
71+
language: minimal
72+
install:
73+
- git clone https://github.com/bats-core/bats-core.git
74+
- cd bats-core
75+
# Get new tags from the remote
76+
- git fetch --tags
77+
# Checkout the latest tag
78+
- git checkout $(git describe --tags `git rev-list --tags --max-count=1`)
79+
- sudo ./install.sh /usr/local
80+
- cd ..
81+
- rm --recursive --force bats-core
82+
- cd ..
83+
- git clone https://github.com/per1234/arduino-ci-script-tests
84+
- cd arduino-ci-script-tests
85+
script:
86+
- bats check_keywords_txt.bats
87+
- bats check_library_manager_compliance.bats
88+
- bats check_library_properties.bats
89+
- bats check_library_structure.bats
90+
- bats check_sketch_structure.bats
91+
- bats miscellaneous.bats
92+
93+
94+
# Check the files in the repository for consistent formatting
95+
- name: "File Formatting Checks"
96+
language: minimal
97+
# Must define an empty install phase so that the default one won't be used
98+
install: true
99+
script:
100+
# Check for files starting with a blank line
101+
- find . -path ./.git -prune -o -type f -print0 | xargs -0 -L1 bash -c 'head -1 "$0" | grep --binary-files=without-match --regexp="^$"; if [[ "$?" == "0" ]]; then echo "Blank line found at start of $0."; false; fi'
102+
# Check for tabs
103+
- find . -path './.git' -prune -or -path './tests/check_keywords_txt' -prune -or -path './tests/check_library_manager_compliance' -prune -or -path './tests/check_library_properties' -prune -or -path './tests/check_library_structure' -prune -or -not -path './tests/check_library_properties.bats' -or -type f -exec grep --with-filename --line-number --binary-files=without-match --regexp=$'\t' '{}' \; -exec echo 'Tab found.' \; -exec false '{}' +
104+
# Check for trailing whitespace
105+
- find . -path './.git' -prune -or -path './tests/check_library_properties' -prune -or -type f -exec grep --with-filename --line-number --binary-files=without-match --regexp='[[:blank:]]$' '{}' \; -exec echo 'Trailing whitespace found.' \; -exec false '{}' +
106+
# Check for non-Unix line endings
107+
- find . -path './.git' -prune -or -path './tests/check_keywords_txt' -prune -or -path './tests/check_library_manager_compliance' -prune -or -path './tests/check_library_properties' -prune -or -path './tests/check_library_structure' -prune -or -type f -exec grep --files-with-matches --regexp=$'\r$' '{}' \; -exec echo 'Non-Unix EOL detected.' \; -exec false '{}' +
108+
# Check for blank lines at end of files
109+
- find . -path ./.git -prune -o -type f -print0 | xargs -0 -L1 bash -c 'tail -1 "$0" | grep --binary-files=without-match --regexp="^$"; if [[ "$?" == "0" ]]; then echo "Blank line found at end of $0."; false; fi'
110+
# Check for files that don't end in a newline (https://stackoverflow.com/a/25686825)
111+
- find . -path ./.git -prune -or -path './tests/check_keywords_txt' -prune -or -path './tests/check_library_manager_compliance' -prune -or -path './tests/check_library_properties' -prune -or -path './tests/check_library_structure' -prune -or -type f -print0 | xargs -0 -L1 bash -c 'if test "$(grep --files-with-matches --binary-files=without-match --max-count=1 --regexp='.*' "$0")" && test "$(tail --bytes=1 "$0")"; then echo "No new line at end of $0."; false; fi'
112+
113+
114+
# Check for commonly misspelled words
115+
- name: "Spell Check"
116+
language: python
117+
python: 3.6
118+
install:
119+
# https://github.com/codespell-project/codespell
120+
- pip install codespell
121+
script:
122+
- codespell --skip="${TRAVIS_BUILD_DIR}/.git" --ignore-words="${TRAVIS_BUILD_DIR}/etc/codespell-ignore-words-list.txt" "${TRAVIS_BUILD_DIR}"
123+
124+
125+
# Default phases shared by all jobs that don't define their own
126+
install:
98127
- source "${TRAVIS_BUILD_DIR}/arduino-ci-script.sh"
99128

100129
- set_script_verbosity "$VERBOSITY_LEVEL"
@@ -241,6 +270,7 @@ notifications:
241270
on_failure: always
242271
webhooks:
243272
urls:
273+
# Use TravisBuddy to automatically comment on any pull request that results in a failed CI build
244274
- https://www.travisbuddy.com/
245275
on_success: never
246276
on_failure: always

0 commit comments

Comments
 (0)