From bf80e99d5412f4212217a89fc3b444bb8295a9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Best?= Date: Tue, 10 Aug 2021 16:12:51 +0200 Subject: [PATCH] chore: Move CI to GitHub Actions - Build and run unit tests with CMake - Track code coverage with Coveralls - Build examples on officially supported boards - Removed TravisCI configuration Closes #233. --- .github/workflows/cmake.yml | 33 ++++++-- .github/workflows/platformio.yml | 59 ++++++++++++++ .travis.yml | 104 ------------------------- examples/AltPinSerial/AltPinSerial.ino | 2 +- 4 files changed, 87 insertions(+), 111 deletions(-) create mode 100644 .github/workflows/platformio.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 0646bf2..9b006b6 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -2,13 +2,14 @@ name: CMake on: push: - branches: [ master ] pull_request: branches: [ master ] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release + BUILD_TYPE: Debug + GENERATE_COVERAGE: true + LCOV_ROOT: ${{github.workspace}}/lcov jobs: build: @@ -22,11 +23,19 @@ jobs: - uses: actions/checkout@v2 with: submodules: recursive - + + - name: Install lcov + run: | + mkdir -p "$LCOV_ROOT" + wget https://github.com/linux-test-project/lcov/releases/download/v1.15/lcov-1.15.tar.gz --output-document="$LCOV_ROOT/lcov.tar.gz" + tar -xf "$LCOV_ROOT/lcov.tar.gz" --strip-components=1 -C "$LCOV_ROOT" + echo "$LCOV_ROOT/bin" >> $GITHUB_PATH + shell: bash + - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILDER_ENABLE_PROFILING=true - name: Build # Build your program with the given configuration @@ -34,5 +43,17 @@ jobs: - name: Run Unit Tests working-directory: ${{github.workspace}}/build - run: ./test/unit-tests/unit-tests - + run: ctest --verbose + + - name: Generate code coverage report + working-directory: ${{github.workspace}}/build + run: | + lcov --directory . --capture --output-file coverage.info + lcov --remove coverage.info '/usr/*' "${{github.workspace}}/test/*" "${{github.workspace}}/external/*" --output-file coverage.info + lcov --list coverage.info + + - uses: coverallsapp/github-action@9ba913c152ae4be1327bfb9085dc806cedb44057 + name: Upload code coverage report to Coveralls + with: + path-to-lcov: ${{github.workspace}}/build/coverage.info + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/platformio.yml b/.github/workflows/platformio.yml new file mode 100644 index 0000000..6433144 --- /dev/null +++ b/.github/workflows/platformio.yml @@ -0,0 +1,59 @@ +name: PlatformIO + +on: + push: + branches: [master] + pull_request: + branches: [ master ] + +jobs: + platformio: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + example: + - AltPinSerial + - Basic_IO + - Bench + - Callbacks + - DualMerger + - ErrorCallback + - Input + - RPN_NRPN + - SimpleSynth + board: + - uno + - due + - zero + - leonardo + - micro + - nanoatmega328 + - megaatmega2560 + - teensy2 + - teensy30 + - teensy31 + - teensylc + steps: + - uses: actions/checkout@v2 + - name: Cache pip + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: ${{ runner.os }}-pip- + - name: Cache PlatformIO + uses: actions/cache@v2 + with: + path: ~/.platformio + key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} + - name: Set up Python + uses: actions/setup-python@v2 + - name: Install PlatformIO + run: | + python -m pip install --upgrade pip + pip install --upgrade platformio + - name: Run PlatformIO + run: pio ci --lib="." --board="${{matrix.board}}" + env: + PLATFORMIO_CI_SRC: examples/${{ matrix.example }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index de7c28d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,104 +0,0 @@ -# Kudos to these guys: -# https://github.com/Return-To-The-Roots/s25client/blob/master/.travis.yml -# http://docs.platformio.org/en/stable/ci/travis.html - -sudo: false -language: python - -os: - - linux - -python: - - "2.7" - -# Cache PlatformIO packages using Travis CI container-based infrastructure -cache: - directories: - - "~/.platformio" - -env: - global: - - BUILD_TYPE=Debug - matrix: - - BUILD_UNIT_TESTS=1 - - PLATFORMIO_CI_SRC=examples/Basic_IO - - PLATFORMIO_CI_SRC=examples/Bench - - PLATFORMIO_CI_SRC=examples/Callbacks - - PLATFORMIO_CI_SRC=examples/DualMerger - - PLATFORMIO_CI_SRC=examples/ErrorCallback - - PLATFORMIO_CI_SRC=examples/Input - - PLATFORMIO_CI_SRC=examples/RPN_NRPN - - PLATFORMIO_CI_SRC=examples/SimpleSynth - - PLATFORMIO_CI_SRC=examples/AltPinSerial - -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 - - cmake - -install: - - | - if [ "${BUILD_UNIT_TESTS}" ]; then - # GCov 4.6 cannot handle the file structure - export CXX="g++-4.8" - export GCOV="gcov-4.8" - - # Install newer lcov (1.9 seems to fail: http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/) - export LCOV_ROOT="$HOME/lcov" - mkdir -p "$LCOV_ROOT" - wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.14.orig.tar.gz --output-document="$LCOV_ROOT/lcov.tar.gz" - tar xf "$LCOV_ROOT/lcov.tar.gz" --strip-components=1 -C $LCOV_ROOT - export PATH="$LCOV_ROOT/bin:$PATH" - which lcov - - # Install coveralls tool - gem install coveralls-lcov - export GENERATE_COVERAGE=1 - else - # Install PlatformIO - pip install -U platformio - fi - -script: - # Build unit tests & generate code coverage - - | - if [ "${BUILD_UNIT_TESTS}" ]; then - mkdir build && cd build - cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILDER_ENABLE_PROFILING=${GENERATE_COVERAGE} --generator="Unix Makefiles" .. - make all - ctest --verbose - fi - - # Build current example - - | - if [ ! "${BUILD_UNIT_TESTS}" ]; then - platformio ci --lib="." \ - --board="uno" \ - --board="due" \ - --board="zero" \ - --board="leonardo" \ - --board="micro" \ - --board="nanoatmega328" \ - --board="megaatmega2560" \ - --board="teensy2" \ - --board="teensy30" \ - --board="teensy31" \ - --board="teensylc" - fi - -after_success: - - | - if [ "${GENERATE_COVERAGE}" ]; then - # Generate code coverage information & send to Coveralls - rm -rf ./external/google-test/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.gcda - lcov --gcov-tool $GCOV --directory . --capture --output-file coverage.info - lcov --gcov-tool $GCOV --remove coverage.info 'test/*' '/usr/*' 'external/*' --output-file coverage.info - lcov --list coverage.info - coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage.info - fi - -notifications: - email: false diff --git a/examples/AltPinSerial/AltPinSerial.ino b/examples/AltPinSerial/AltPinSerial.ino index 65a0c49..ce57cb0 100644 --- a/examples/AltPinSerial/AltPinSerial.ino +++ b/examples/AltPinSerial/AltPinSerial.ino @@ -5,7 +5,7 @@ // Here, when receiving any message on channel 4, the Arduino // will blink a led and play back a note for 1 second. -#if defined(ARDUINO_SAM_DUE) || defined(SAMD_SERIES) +#if defined(ARDUINO_SAM_DUE) || defined(SAMD_SERIES) || defined(_VARIANT_ARDUINO_ZERO_) /* example not relevant for this hardware (SoftwareSerial not supported) */ MIDI_CREATE_DEFAULT_INSTANCE(); #else