forked from Optiboot/optiboot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Optiboot#246 from majekw/travis-4
Travis-CI: targets update, compilation matrix with sizes, documentation
- Loading branch information
Showing
7 changed files
with
401 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Travis-CI and Optiboot | ||
|
||
## What is Travis? | ||
|
||
https://travis-ci.com is site which allows to make checking builds after | ||
every push of code to git repository. It could also check pull request. | ||
|
||
It nicely integrates with Github, so to enable it's enough to just | ||
install Travis' Github App from: https://github.com/marketplace/travis-ci | ||
|
||
Travis have also free plan for Open Source projects, so there is no | ||
cost involved. | ||
|
||
When installed, after every push a build is started on Travis-CI | ||
servers. After build finish, status of commit is updated, so everyone | ||
can see if build passed or failed. Clicking on details gives more | ||
information about which job(s) within all build failed and even direct | ||
output from virtual machine, so it's easy to check why something went | ||
wrong. | ||
|
||
Of course, Travis-CI also needs configuration to define what should | ||
be run to test code, so every project must have *.travis.yml* file | ||
and some others if external scripts are needed. | ||
|
||
## Files | ||
|
||
### .travis.yml | ||
|
||
Standard Travis-CI file with definitions of jobs. | ||
|
||
There are 2 stages of tests: | ||
- *check sizes*: there is only one build in this stage which compiles ALL | ||
targets specified in *.travis.yml* (variable *OPTIBOOT_TARGET* in matrix) | ||
agains ALL compilers marked with 'yes' from *arduino-gcc-versions.md* file | ||
plus latest Microchip's compiler for avr8. There are 2 tables produced | ||
at the end of build: one is output of current compilation and resulting | ||
sizes for every target or 'x' if build failed. Second one is based on | ||
online database of builds and gives comparison between current build | ||
and last commited into repository. Output is markdown compatible, so | ||
it could be just copied and pasted into Github comment to produce | ||
pretty table. | ||
- test: stage with separate build for every *OPTIBOOT_TARGET* against only | ||
one compiler specified in variable *TOOLS_VERSION*. In 'allow_failures' | ||
section there are targets known to fail and ignored in overall status | ||
of test. | ||
|
||
### scripts/travis-build.sh | ||
|
||
Script used to build single target during 'test' stage. | ||
|
||
## scripts/travis-check-sizes.sh | ||
|
||
Script used to build all targets using all compilers during 'check sizes' | ||
stage. | ||
|
||
## scripts/travis-download.inc.sh | ||
|
||
Include script used to download and unpack tools. Used by *travis-build.sh* | ||
and *travis-check-sizes.sh* scripts. | ||
|
||
## scripts/travis-env.inc.sh | ||
|
||
Helper script for local testing (on Linux) builds. It sets all necessary | ||
environment variables to make *travis-build.sh* or *travis-check-sizes.sh* | ||
on local machine. Need to be sourced from repository parent directory: | ||
```bash | ||
. scripts/travis-env.inc.sh | ||
``` | ||
|
||
## scripts/travis-fill-cache.sh | ||
|
||
Helper script used by *travis-check-sizes.sh* to download and extract all | ||
needed compilers. It uses *docs/arduino-gcc-versions.md* file to find | ||
which Arduino version should be downloaded. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env bash | ||
|
||
LOCAL_TOOLS_DIR=$HOME/avr-tools | ||
|
||
if [ -z "$TRAVIS_BUILD_DIR" ]; then | ||
echo "This script should be run by Travis-CI environment" | ||
echo "If you want to simulate Travis build, please set TRAVIS_BUILD_DIR" | ||
echo "environment variable to directory where your code lives" | ||
exit 1 | ||
fi | ||
|
||
|
||
# download all compilers | ||
$TRAVIS_BUILD_DIR/scripts/travis-fill-cache.sh | ||
|
||
# prepare output dir | ||
OUTPUT_DIR="$TRAVIS_BUILD_DIR/sizes-out" | ||
mkdir -p "$OUTPUT_DIR" | ||
OUTPUT_TABLE="$OUTPUT_DIR/sizes.txt" | ||
OUTPUT_JSON="$OUTPUT_DIR/sizes.json" | ||
|
||
# compiler list | ||
COMPILERS=$(cat $TRAVIS_BUILD_DIR/docs/arduino-gcc-versions.md |grep -i "| yes |"|cut -f 2 -d '|') | ||
COMPILERS="$COMPILERS microchip" | ||
|
||
# table header | ||
echo -n "| target \ compiler |" >"$OUTPUT_TABLE" | ||
for compiler in $COMPILERS; do | ||
echo -n " $compiler |" >>"$OUTPUT_TABLE" | ||
done | ||
echo >>"$OUTPUT_TABLE" | ||
# table header separator | ||
echo -n "|-|" >>"$OUTPUT_TABLE" | ||
for compiler in $COMPILERS; do | ||
echo -n "-|">>"$OUTPUT_TABLE" | ||
done | ||
echo >>"$OUTPUT_TABLE" | ||
|
||
# get repo and commit info for json output | ||
if [[ "$TRAVIS_PULL_REQUEST" = "false" ]]; then | ||
REPO="$TRAVIS_REPO_SLUG" | ||
BRANCH="$TRAVIS_BRANCH" | ||
else | ||
REPO="$TRAVIS_PULL_REQUEST_SLUG" | ||
BRANCH="$TRAVIS_PULL_REQUEST_BRANCH" | ||
fi | ||
|
||
# start json | ||
echo "{\"slug\":\"$REPO\",\"branch\":\"$BRANCH\",\"commit\":\"$TRAVIS_COMMIT\",\"emoji\":\"false\",\"builds\":[" >"$OUTPUT_JSON" | ||
|
||
# build everything | ||
cat $TRAVIS_BUILD_DIR/.travis.yml|grep " - OPTIBOOT_TARGET="|cut -f 2- -d '=' \ | ||
|tr -d '"'|sort|while read target; do | ||
echo -n "| $target |" >>"$OUTPUT_TABLE" | ||
echo "{\"t\":\"$target\",\"v\":[">>"$OUTPUT_JSON" | ||
for compiler in $COMPILERS; do | ||
echo "Checking size for $target @ $compiler" | ||
size=$($TRAVIS_BUILD_DIR/scripts/travis-build.sh $compiler $target 2>/dev/null|grep -A 2 avr-size|tail -n1|awk '{ print $1;}') | ||
if [[ -z "$size" ]]; then | ||
size="x" | ||
fi | ||
echo -n " $size |" >>"$OUTPUT_TABLE" | ||
echo "{\"c\":\"$compiler\",\"s\":\"$size\"}," >>"$OUTPUT_JSON" | ||
done | ||
echo >>"$OUTPUT_TABLE" | ||
sed -i '$ s/.$//' "$OUTPUT_JSON" | ||
echo "]}," >>"$OUTPUT_JSON" | ||
done | ||
sed -i '$ s/.$//' "$OUTPUT_JSON" | ||
echo "]}">>"$OUTPUT_JSON" | ||
|
||
echo "========= OUTPUT SIZES START =============" | ||
cat "$OUTPUT_TABLE" | ||
echo "========== OUTPUT SIZES END ==============" | ||
|
||
echo "Checking results against last commit" | ||
echo "========= OUTPUT SIZES COMPARE START =============" | ||
curl -H "Content-Type: application/json" --data @$OUTPUT_JSON https://api.travisjoin.w7i.pl/tj/compare/$REPO/$BRANCH/last | ||
echo "========== OUTPUT SIZES COMPARE END ==============" | ||
|
||
echo "Uploading results to TravisJoin" | ||
curl -H "Content-Type: application/json" --data @$OUTPUT_JSON https://api.travisjoin.w7i.pl/tj/add/$REPO/$BRANCH/$TRAVIS_COMMIT | ||
|
||
exit 0 |
Oops, something went wrong.