From 2a8d07b28ef56eaf721b28a4477f4a9ccd6d3986 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 25 Oct 2020 08:45:09 -0700 Subject: [PATCH] Add an integration test CI workflow This provides some checks on how the entire action works with GitHub Actions, which can catch issues the unit/functional tests of the Python code will miss. --- .github/workflows/test-integration.yml | 113 ++++++++++++++++++ .../sketches/BareMinimum/BareMinimum.ino | 2 + .../testdata/sketches/Error/Error.ino | 1 + .../sketches/ServoLibrary/ServoLibrary.ino | 3 + 4 files changed, 119 insertions(+) create mode 100644 .github/workflows/test-integration.yml create mode 100644 .github/workflows/testdata/sketches/BareMinimum/BareMinimum.ino create mode 100644 .github/workflows/testdata/sketches/Error/Error.ino create mode 100644 .github/workflows/testdata/sketches/ServoLibrary/ServoLibrary.ino diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml new file mode 100644 index 00000000..9cc416cd --- /dev/null +++ b/.github/workflows/test-integration.yml @@ -0,0 +1,113 @@ +name: Run integration tests + +on: + pull_request: + paths: + - '.github/workflows/test-integration.yml' + - '.github/workflows/testdata' + - 'action.yml' + - 'compilesketches/**' + + push: + paths: + - '.github/workflows/test-integration.yml' + - '.github/workflows/testdata' + - 'action.yml' + - 'compilesketches/**' + +env: + SKETCHES_REPORTS_PATH: sketches-reports + TESTDATA_SKETCHES_PATH: .github/workflows/testdata/sketches + +jobs: + default-inputs: + runs-on: ubuntu-latest + + steps: + - name: Checkout Servo library + uses: actions/checkout@v2 + with: + repository: arduino-libraries/servo + ref: 1.1.7 + + - name: Checkout local repo + uses: actions/checkout@v2 + with: + # Must be checked out to a subfolder to not interfere with the checked out library under test + path: extras/compile-sketches + + - name: Run action with default input values + # Use action from local path + uses: ./extras/compile-sketches + + + all-inputs: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:avr:uno + platforms: | + - name: arduino:avr + version: 1.8.3 + libraries: | + - name: Servo + version: 1.1.7 + # Board that requires Boards Manager URL + - fqbn: esp8266:esp8266:huzzah + platforms: | + - name: esp8266:esp8266 + source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json + version: 2.7.4 + libraries: | + # The official Servo library is not compatible with ESP8266, but that platform has a bundled Servo lib + # so there are no library dependencies + - + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Run action + # Use action from local path + uses: ./ + with: + cli-version: 0.13.0 + platforms: ${{ matrix.board.platforms }} + fqbn: ${{ matrix.board.fqbn }} + libraries: ${{ matrix.board.libraries }} + sketch-paths: | + - ${{ env.TESTDATA_SKETCHES_PATH }}/BareMinimum + - ${{ env.TESTDATA_SKETCHES_PATH }}/ServoLibrary + enable-deltas-report: true + enable-warnings-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + verbose: true + + + expected-failed-compilation: + runs-on: ubuntu-latest + + steps: + - name: Checkout local repo + uses: actions/checkout@v2 + + - name: Compile sketch that is expected to error + id: compile-sketches + continue-on-error: true + uses: ./ + with: + fqbn: arduino:avr:uno + libraries: | + - + sketch-paths: | + - ${{ env.TESTDATA_SKETCHES_PATH }}/Error + + - name: Fail the job if the action run succeeded + if: steps.compile-sketches.outcome == 'success' + run: | + echo "::error::The action run was expected to fail, but passed!" + exit 1 diff --git a/.github/workflows/testdata/sketches/BareMinimum/BareMinimum.ino b/.github/workflows/testdata/sketches/BareMinimum/BareMinimum.ino new file mode 100644 index 00000000..660bdbcc --- /dev/null +++ b/.github/workflows/testdata/sketches/BareMinimum/BareMinimum.ino @@ -0,0 +1,2 @@ +void setup() {} +void loop() {} diff --git a/.github/workflows/testdata/sketches/Error/Error.ino b/.github/workflows/testdata/sketches/Error/Error.ino new file mode 100644 index 00000000..09c7cfaf --- /dev/null +++ b/.github/workflows/testdata/sketches/Error/Error.ino @@ -0,0 +1 @@ +#error diff --git a/.github/workflows/testdata/sketches/ServoLibrary/ServoLibrary.ino b/.github/workflows/testdata/sketches/ServoLibrary/ServoLibrary.ino new file mode 100644 index 00000000..09a62f42 --- /dev/null +++ b/.github/workflows/testdata/sketches/ServoLibrary/ServoLibrary.ino @@ -0,0 +1,3 @@ +#include +void setup() {} +void loop() {}