From a2964285ebcc4151908f4df457cf4ed22d842cdd Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Tue, 29 Oct 2024 15:00:58 +0100 Subject: [PATCH] [CI] Update compile-examples and report-size-deltas for released libraries. (#32) --- .github/workflows/compile-examples.yml | 63 +++++++++++++----------- .github/workflows/report-size-deltas.yml | 24 +++++++++ 2 files changed, 57 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/report-size-deltas.yml diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index c2686b9..70b8481 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -1,37 +1,58 @@ name: Compile Examples +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows on: - - push - - pull_request - -env: - # It's convenient to set variables for values used multiple times in the workflow. - SKETCHES_REPORTS_PATH: sketches-reports + push: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + pull_request: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms). + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: jobs: - compile: + build: + name: ${{ matrix.board.fqbn }} runs-on: ubuntu-latest + env: + SKETCHES_REPORTS_PATH: sketches-reports + strategy: + fail-fast: false + matrix: board: - fqbn: arduino:mbed_opta:opta artifact-name-suffix: arduino-mbed_opta-opta steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - - uses: arduino/compile-sketches@v1 + - name: Compile examples + uses: arduino/compile-sketches@v1 with: fqbn: ${{ matrix.board.fqbn }} platforms: ${{ matrix.board.platforms }} libraries: | + # Install the library from the local path. - source-path: ./ - name: Arduino_Opta_Blueprint - name: Arduino_SerialUpdater - name: Arduino_DebugUtils - name: ArduinoRS485 - name: ArduinoModbus + sketch-paths: | + - examples enable-deltas-report: true github-token: ${{ secrets.GITHUB_TOKEN }} sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} @@ -39,27 +60,9 @@ jobs: - --build-property - compiler.cpp.extra_flags=-DUSE_MODBUS_SENSOR_MD02=1 - # This step is needed to pass the size data to the report job. - - name: Upload sketches report to workflow artifact + - name: Save sketches report as workflow artifact uses: actions/upload-artifact@v4 with: - name: sketches-reports-${{ matrix.board.artifact-name-suffix }} + if-no-files-found: error path: ${{ env.SKETCHES_REPORTS_PATH }} - - # When using a matrix to compile for multiple boards, it's necessary to use a separate job for the deltas report - report: - needs: compile # Wait for the compile job to finish to get the data for the report - if: github.event_name == 'pull_request' # Only run the job when the workflow is triggered by a pull request - runs-on: ubuntu-latest - - steps: - # This step is needed to get the size data produced by the compile jobs - - name: Download sketches reports artifacts - uses: actions/download-artifact@v4 - with: - # All workflow artifacts will be downloaded to this location. - path: ${{ env.SKETCHES_REPORTS_PATH }} - - - uses: arduino/report-size-deltas@v1 - with: - sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }} + name: sketches-report-${{ matrix.board.artifact-name-suffix }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml new file mode 100644 index 0000000..39e2a0a --- /dev/null +++ b/.github/workflows/report-size-deltas.yml @@ -0,0 +1,24 @@ +name: Report Size Deltas + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/report-size-deltas.yml" + schedule: + # Run at the minimum interval allowed by GitHub Actions. + # Note: GitHub Actions periodically has outages which result in workflow failures. + # In this event, the workflows will start passing again once the service recovers. + - cron: "*/5 * * * *" + workflow_dispatch: + repository_dispatch: + +jobs: + report: + runs-on: ubuntu-latest + steps: + - name: Comment size deltas reports to PRs + uses: arduino/report-size-deltas@v1 + with: + # Regex matching the names of the workflow artifacts created by the "Compile Examples" workflow + sketches-reports-source: ^sketches-report-.+