From ad172243ef527c8a0631717031535ff8d26815bd Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 29 Jun 2021 12:55:07 -0700 Subject: [PATCH 1/2] Switch to contributor-friendly approach to size deltas CI report The CI system makes a report of the change to memory usage of the example sketches that results from the changes made in a pull request. It does this via a comment on the PR thread. In order to do that, it needs write permissions in the repository. As a security precaution, workflow runs triggered by a pull request from a fork are not given the necessary write permissions. The workflow was added in the early development phase when the repository was still private. In that situation, the approach of triggering the deltas report from the pull_request event was the best but now the repository is public and it's important to get reports on pull requests that come from forks. So the approach of using a dedicated workflow triggered by the schedule event (which does have write permissions) is better. --- .../workflows/compile-examples-private.yml | 31 +++---------------- .github/workflows/report-size-deltas.yml | 24 ++++++++++++++ 2 files changed, 28 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/report-size-deltas.yml diff --git a/.github/workflows/compile-examples-private.yml b/.github/workflows/compile-examples-private.yml index 7555c8e..1ecd31f 100644 --- a/.github/workflows/compile-examples-private.yml +++ b/.github/workflows/compile-examples-private.yml @@ -20,15 +20,14 @@ on: workflow_dispatch: repository_dispatch: -env: - SKETCHES_REPORTS_PATH: sketches-reports - SKETCHES_REPORTS_ARTIFACT_NAME: sketches-reports - jobs: build: name: ${{ matrix.board.fqbn }} runs-on: ubuntu-latest + env: + SKETCHES_REPORTS_PATH: sketches-reports + strategy: fail-fast: false @@ -63,26 +62,4 @@ jobs: with: if-no-files-found: error path: ${{ env.SKETCHES_REPORTS_PATH }} - name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }} - - report-size-deltas: - needs: build - # Run even if some compilations failed. Only run when there are write permissions. - if: always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository - runs-on: ubuntu-latest - - steps: - - name: Download sketches reports artifact - id: download-artifact - continue-on-error: true # If compilation failed for all boards then there are no artifacts - uses: actions/download-artifact@v2 - with: - name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }} - path: ${{ env.SKETCHES_REPORTS_PATH }} - - - name: Comment size deltas report to PR - uses: arduino/report-size-deltas@v1 - # If actions/download-artifact failed, there are no artifacts to report from. - if: steps.download-artifact.outcome == 'success' - with: - sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml new file mode 100644 index 0000000..30b6ca0 --- /dev/null +++ b/.github/workflows/report-size-deltas.yml @@ -0,0 +1,24 @@ +name: Report Size Deltas + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/report-size-deltas.ya?ml" + 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: + # The name of the workflow artifact created by the sketch compilation workflow + sketches-reports-source: sketches-reports From 1e3abab837bdc28b4016cd230f5ac4ddcf9c601b Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 29 Jun 2021 13:05:24 -0700 Subject: [PATCH 2/2] Use appropriate filename for sketch compilation workflow The previous version of the workflow was configured for private repositories, thus the "-private", but we are now using the version for public repositories, so the filename should be updated accordingly. --- .../{compile-examples-private.yml => compile-examples.yml} | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{compile-examples-private.yml => compile-examples.yml} (93%) diff --git a/.github/workflows/compile-examples-private.yml b/.github/workflows/compile-examples.yml similarity index 93% rename from .github/workflows/compile-examples-private.yml rename to .github/workflows/compile-examples.yml index 1ecd31f..566f398 100644 --- a/.github/workflows/compile-examples-private.yml +++ b/.github/workflows/compile-examples.yml @@ -4,13 +4,13 @@ name: Compile Examples on: push: paths: - - ".github/workflows/compile-examples-private.ya?ml" + - ".github/workflows/compile-examples.ya?ml" - "library.properties" - "examples/**" - "src/**" pull_request: paths: - - ".github/workflows/compile-examples-private.ya?ml" + - ".github/workflows/compile-examples.ya?ml" - "library.properties" - "examples/**" - "src/**" diff --git a/README.md b/README.md index a563ffb..831ac92 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Portenta Breakout Carrier Library for Arduino [![Check Arduino status](https://github.com/arduino-libraries/Arduino_PortentaBreakoutLibrary/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PortentaBreakoutLibrary/actions/workflows/check-arduino.yml) -[![Compile Examples status](https://github.com/arduino-libraries/Arduino_PortentaBreakoutLibrary/actions/workflows/compile-examples-private.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PortentaBreakoutLibrary/actions/workflows/compile-examples-private.yml) +[![Compile Examples status](https://github.com/arduino-libraries/Arduino_PortentaBreakoutLibrary/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PortentaBreakoutLibrary/actions/workflows/compile-examples.yml) [![Spell Check status](https://github.com/arduino-libraries/Arduino_PortentaBreakoutLibrary/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PortentaBreakoutLibrary/actions/workflows/spell-check.yml) Arduino Library for the Arduino Portenta Breakout Carrier