travis-check-sizes.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env bash
  2. LOCAL_TOOLS_DIR=$HOME/avr-tools
  3. if [ -z "$TRAVIS_BUILD_DIR" ]; then
  4. echo "This script should be run by Travis-CI environment"
  5. echo "If you want to simulate Travis build, please set TRAVIS_BUILD_DIR"
  6. echo "environment variable to directory where your code lives"
  7. exit 1
  8. fi
  9. # download all compilers
  10. $TRAVIS_BUILD_DIR/scripts/travis-fill-cache.sh
  11. # prepare output dir
  12. OUTPUT_DIR="$TRAVIS_BUILD_DIR/sizes-out"
  13. mkdir -p "$OUTPUT_DIR"
  14. OUTPUT_TABLE="$OUTPUT_DIR/sizes.txt"
  15. OUTPUT_JSON="$OUTPUT_DIR/sizes.json"
  16. # compiler list
  17. COMPILERS=$(cat $TRAVIS_BUILD_DIR/docs/arduino-gcc-versions.md |grep -i "| yes |"|cut -f 2 -d '|')
  18. COMPILERS="$COMPILERS microchip"
  19. # table header
  20. echo -n "| target \ compiler |" >"$OUTPUT_TABLE"
  21. for compiler in $COMPILERS; do
  22. echo -n " $compiler |" >>"$OUTPUT_TABLE"
  23. done
  24. echo >>"$OUTPUT_TABLE"
  25. # table header separator
  26. echo -n "|-|" >>"$OUTPUT_TABLE"
  27. for compiler in $COMPILERS; do
  28. echo -n "-|">>"$OUTPUT_TABLE"
  29. done
  30. echo >>"$OUTPUT_TABLE"
  31. # get repo and commit info for json output
  32. if [[ "$TRAVIS_PULL_REQUEST" = "false" ]]; then
  33. REPO="$TRAVIS_REPO_SLUG"
  34. BRANCH="$TRAVIS_BRANCH"
  35. else
  36. REPO="$TRAVIS_PULL_REQUEST_SLUG"
  37. BRANCH="$TRAVIS_PULL_REQUEST_BRANCH"
  38. fi
  39. # start json
  40. echo "{\"slug\":\"$REPO\",\"branch\":\"$BRANCH\",\"commit\":\"$TRAVIS_COMMIT\",\"emoji\":\"true\",\"builds\":[" >"$OUTPUT_JSON"
  41. # build everything
  42. cat $TRAVIS_BUILD_DIR/.travis.yml|grep " - OPTIBOOT_TARGET="|cut -f 2- -d '=' \
  43. |tr -d '"'|sort|while read target; do
  44. echo -n "| $target |" >>"$OUTPUT_TABLE"
  45. echo "{\"t\":\"$target\",\"v\":[">>"$OUTPUT_JSON"
  46. for compiler in $COMPILERS; do
  47. echo "Checking size for $target @ $compiler"
  48. size=$($TRAVIS_BUILD_DIR/scripts/travis-build.sh $compiler $target 2>/dev/null|grep -A 2 avr-size|tail -n1|awk '{ print $1;}')
  49. if [[ -z "$size" ]]; then
  50. size="x"
  51. fi
  52. echo -n " $size |" >>"$OUTPUT_TABLE"
  53. echo "{\"c\":\"$compiler\",\"s\":\"$size\"}," >>"$OUTPUT_JSON"
  54. done
  55. echo >>"$OUTPUT_TABLE"
  56. sed -i '$ s/.$//' "$OUTPUT_JSON"
  57. echo "]}," >>"$OUTPUT_JSON"
  58. done
  59. sed -i '$ s/.$//' "$OUTPUT_JSON"
  60. echo "]}">>"$OUTPUT_JSON"
  61. echo "========= OUTPUT SIZES START ============="
  62. cat "$OUTPUT_TABLE"
  63. echo "========== OUTPUT SIZES END =============="
  64. echo "Checking results against last commit"
  65. echo "========= OUTPUT SIZES COMPARE START ============="
  66. curl -H "Content-Type: application/json" --data @$OUTPUT_JSON https://api.travisjoin.w7i.pl/tj/compare/$REPO/$BRANCH/last
  67. echo "========== OUTPUT SIZES COMPARE END =============="
  68. echo "Uploading results to TravisJoin"
  69. curl -H "Content-Type: application/json" --data @$OUTPUT_JSON https://api.travisjoin.w7i.pl/tj/add/$REPO/$BRANCH/$TRAVIS_COMMIT
  70. exit 0