From 9278f817d28c78bf9b5aa2e0aaa41fd2a66a1aa6 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 21 Feb 2024 06:08:25 -0800 Subject: [PATCH 1/2] Revert "Fix regression: report size delta size on PR. (#429)" This partially reverts commit 836771a7a4a2d49758bf7e977f68fa2b124a5941. The repository infrastructure uses the "arduino/report-size-deltas" action to generate a report of the changes in memory usage of the example sketches that would result from merging a pull request. There are two use patterns for the "arduino/report-size-deltas" action: * Run from a workflow triggered by a `schedule` event. * Run from the same workflow as the "arduino/compile-sketches" action when triggered by a `pull_request` event. The latter use pattern is only suitable for private repositories. The reason is that, when a pull request is submitted from a fork, the permissions of the access token used by the "arduino/report-size-deltas" action are downgraded to read-only in workflows triggered by a `pull_request` event, which means it is unable to make the report comment. The reverted commit migrated the size deltas report infrastructure from the first use pattern to the second, which caused the "Compile Examples" workflow runs to fail on pull requests submitted from forks: Error: HTTPError: HTTP Error 403: Forbidden For this reason, the infrastructure must be reverted back to using the first use pattern. --- .github/workflows/compile-examples.yml | 26 ++---------------------- .github/workflows/report-size-deltas.yml | 14 +++++++++++++ 2 files changed, 16 insertions(+), 24 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 e482cfecb..46837b40d 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -12,12 +12,8 @@ on: - "examples/**" - "src/**" -env: - # It's convenient to set variables for values used multiple times in the workflow. - SKETCHES_REPORTS_PATH: sketches-reports - jobs: - compile: + build: runs-on: ubuntu-latest env: @@ -35,6 +31,7 @@ jobs: - examples/ArduinoIoTCloud-Callbacks - examples/ArduinoIoTCloud-Schedule - examples/utility/ArduinoIoTCloud_Travis_CI + SKETCHES_REPORTS_PATH: sketches-reports strategy: fail-fast: false @@ -295,28 +292,9 @@ jobs: google-key-file: ${{ secrets.GOOGLE_KEY_FILE }} spreadsheet-id: 1I6NZkpZpf8KugBkE92adB1Z3_b7ZepOpCdYTOigJpN4 - # This step is needed to pass the size data to the report job. - name: Save memory usage change report as artifact if: github.event_name == 'pull_request' uses: actions/upload-artifact@v4 with: name: sketches-report-${{ matrix.board.artifact-name-suffix }} 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 }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml new file mode 100644 index 000000000..9b0f2cdb5 --- /dev/null +++ b/.github/workflows/report-size-deltas.yml @@ -0,0 +1,14 @@ +on: + schedule: + - cron: '*/5 * * * *' + +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 "Compile Examples" workflow + sketches-reports-source: sketches-reports From ce9fc413feb9bb393cfc0341a12e6f4068331a10 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 21 Feb 2024 07:05:01 -0800 Subject: [PATCH 2/2] Correct workflow artifact name pattern in size deltas report workflow The "sketches-reports-source" input of the "arduino/report-size-deltas" GitHub Actions action defines the regular expression that matches the names of the sketches report workflow artifacts produced by the "Compile Examples" workflow. The key string in the names of these artifacts was set to "sketches-report" when the "Compile Examples" workflow was adjusted for compatibility with the breaking changes introduced by updating to version 4.x of the workflow's "actions/upload-artifact" GitHub Actions action dependency. The pattern set in the size deltas report workflow was "sketches-reports". The "s" at the end of that pattern caused it to no longer match against the key string in the artifact names after that adjustment of the "Compile Examples" workflow, resulting in size deltas reports no longer being generated by the workflow. Although a minimal fix would be to simply remove the "s" from the end of the pattern, the decision was made to use a more strict regular expression. This will make it easier for maintainers and contributors to understand that this value is a regular expression and the exact nature of how that regular expression functions (which is less clear when relying on the "arduino/report-size-deltas" action's partial pattern matching behavior). --- .github/workflows/report-size-deltas.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml index 9b0f2cdb5..ae4c69abd 100644 --- a/.github/workflows/report-size-deltas.yml +++ b/.github/workflows/report-size-deltas.yml @@ -10,5 +10,5 @@ jobs: - name: Comment size deltas reports to PRs uses: arduino/report-size-deltas@v1 with: - # The name of the workflow artifact created by the "Compile Examples" workflow - sketches-reports-source: sketches-reports + # Regex matching the names of the workflow artifacts created by the "Compile Examples" workflow + sketches-reports-source: ^sketches-report-.+