From b077ef3a4416e0a3e4585eb51744d1d6d246e745 Mon Sep 17 00:00:00 2001 From: per1234 Date: Mon, 12 Apr 2021 18:16:24 -0700 Subject: [PATCH 1/4] Upload test sketches report workflow artifact This sketches report artifact is used to get test size deltas reports. --- .github/workflows/upload-report-artifact.yml | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/upload-report-artifact.yml diff --git a/.github/workflows/upload-report-artifact.yml b/.github/workflows/upload-report-artifact.yml new file mode 100644 index 0000000..b23c129 --- /dev/null +++ b/.github/workflows/upload-report-artifact.yml @@ -0,0 +1,39 @@ +name: Upload test sketches report artifact + +on: + pull_request: + types: + - opened + - synchronize + # The "labeled" event can be used to easily retrigger the workflow to restore the workflow artifact after it + # expires every 90 days. + - labeled + +jobs: + upload: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # The action only does a deltas report when the sketches report's `commit_hash` value matches the PR head SHA + - name: Update commit hash in reports + run: | + # Set up dedicated folder for the updated sketches reports (it's not possible to modify them in place) + SKETCHES_REPORTS_PATH="${{ runner.temp }}/sketches-reports" + # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + echo "SKETCHES_REPORTS_PATH=$SKETCHES_REPORTS_PATH" >> "$GITHUB_ENV" + mkdir --parents "$SKETCHES_REPORTS_PATH" + + cd "${{ github.workspace }}/.github/workflows/testdata/sketches-reports/" + for reportFile in *.json; do + jq '.commit_hash = "${{ github.event.pull_request.head.sha }}"' "$reportFile" > "${SKETCHES_REPORTS_PATH}/$reportFile" + done + + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v2 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: sketches-reports From 39c0012c59258cb9a4601d75196189a00ca2e71d Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 19 Jan 2024 14:19:19 -0800 Subject: [PATCH 2/4] Bump action dependencies in "Upload test sketches report artifact" workflow `actions/upload-artifact` is only bumped to v3 here because a significant change in the artifact format was introduced in 4.0.0. It is necessary for the workflow to continue to produce test data that provides integration test coverage for compatibility of the action with the artifacts produced by <=v3 of the action. --- .github/workflows/upload-report-artifact.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload-report-artifact.yml b/.github/workflows/upload-report-artifact.yml index b23c129..23705e6 100644 --- a/.github/workflows/upload-report-artifact.yml +++ b/.github/workflows/upload-report-artifact.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 # The action only does a deltas report when the sketches report's `commit_hash` value matches the PR head SHA - name: Update commit hash in reports @@ -32,7 +32,7 @@ jobs: done - name: Save sketches report as workflow artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: if-no-files-found: error path: ${{ env.SKETCHES_REPORTS_PATH }} From e99610b0b3e90019d43966a1acbe903148158d3c Mon Sep 17 00:00:00 2001 From: per1234 Date: Fri, 19 Jan 2024 14:22:44 -0800 Subject: [PATCH 3/4] Upload multiple test data artifacts to provide coverage for artifact name pattern feature The action was originally designed for a use case where there will only be a single sketches reports workflow artifact. Due to a change in the "actions/upload-artifact" GitHub Actions action, it became necessary to add the capability for the "arduino/report-size-deltas" action to be able to consume reports from multiple artifacts. The "Upload test sketches report artifact" GitHub Actions workflow is hereby updated to produce multiple test data artifacts in order to allow the "Run integration tests" workflow to provide coverage for the new capability. As was previously the case, one of the artifacts uploaded by the workflow contains multiple sketches report files in order to provide test data necessary to continue providing coverage for the <=actions/upload-artifact@v3 single artifact system. Even though the produced test data (multiple artifacts, with multiple reports in a single artifact) would not occur under real world usage, it is the cleanest way (the alternative being to create and maintain separate copies of the system implemented in the `report-target-pr` branch for each use pattern) to provide effective integration test coverage. --- .../arduino-avr-leonardo.json | 245 ++++++++++++++++++ .../arduino-sam-arduino_due_x.json | 245 ++++++++++++++++++ .../arduino-samd-mkrzero.json | 245 ++++++++++++++++++ .github/workflows/upload-report-artifact.yml | 18 +- 4 files changed, 751 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/testdata/artifact-source/multi-report-artifact/arduino-avr-leonardo.json create mode 100644 .github/workflows/testdata/artifact-source/multi-report-artifact/arduino-sam-arduino_due_x.json create mode 100644 .github/workflows/testdata/artifact-source/per-report-artifact/arduino-samd-mkrzero.json diff --git a/.github/workflows/testdata/artifact-source/multi-report-artifact/arduino-avr-leonardo.json b/.github/workflows/testdata/artifact-source/multi-report-artifact/arduino-avr-leonardo.json new file mode 100644 index 0000000..38cb56d --- /dev/null +++ b/.github/workflows/testdata/artifact-source/multi-report-artifact/arduino-avr-leonardo.json @@ -0,0 +1,245 @@ +{ + "commit_hash": "0123456789abcdef0123456789abcdef01234567", + "commit_url": "https://github.com/per1234/generate-size-deltas-report/commit/651f05f4d4aca30ac359e972c01568f873112d43", + "boards": [ + { + "board": "arduino:avr:leonardo", + "sketches": [ + { + "name": "examples/MIDIUSB_clock", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 28672, + "current": { + "absolute": 4792, + "relative": 16.71 + }, + "previous": { + "absolute": 4792, + "relative": 16.71 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + }, + { + "name": "RAM for global variables", + "maximum": 2560, + "current": { + "absolute": 443, + "relative": 17.3 + }, + "previous": { + "absolute": 443, + "relative": 17.3 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + } + ], + "warnings": { + "current": { + "absolute": 2 + }, + "previous": { + "absolute": 2 + }, + "delta": { + "absolute": 0 + } + } + }, + { + "name": "examples/MIDIUSB_loop", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 28672, + "current": { + "absolute": 4870, + "relative": 16.99 + }, + "previous": { + "absolute": 4870, + "relative": 16.99 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + }, + { + "name": "RAM for global variables", + "maximum": 2560, + "current": { + "absolute": 441, + "relative": 17.23 + }, + "previous": { + "absolute": 441, + "relative": 17.23 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + } + ], + "warnings": { + "current": { + "absolute": 3 + }, + "previous": { + "absolute": 3 + }, + "delta": { + "absolute": 0 + } + } + }, + { + "name": "examples/MIDIUSB_read", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 28672, + "current": { + "absolute": 4908, + "relative": 17.12 + }, + "previous": { + "absolute": 4908, + "relative": 17.12 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + }, + { + "name": "RAM for global variables", + "maximum": 2560, + "current": { + "absolute": 457, + "relative": 17.85 + }, + "previous": { + "absolute": 457, + "relative": 17.85 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + } + ], + "warnings": { + "current": { + "absolute": 3 + }, + "previous": { + "absolute": 3 + }, + "delta": { + "absolute": 0 + } + } + }, + { + "name": "examples/MIDIUSB_write", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 28672, + "current": { + "absolute": 4524, + "relative": 15.78 + }, + "previous": { + "absolute": 4564, + "relative": 15.92 + }, + "delta": { + "absolute": -40, + "relative": -0.14 + } + }, + { + "name": "RAM for global variables", + "maximum": 2560, + "current": { + "absolute": 197, + "relative": 7.7 + }, + "previous": { + "absolute": 213, + "relative": 8.32 + }, + "delta": { + "absolute": -16, + "relative": -0.62 + } + } + ], + "warnings": { + "current": { + "absolute": 3 + }, + "previous": { + "absolute": 3 + }, + "delta": { + "absolute": 0 + } + } + } + ], + "sizes": [ + { + "name": "flash", + "maximum": 28672, + "delta": { + "absolute": { + "minimum": -40, + "maximum": 0 + }, + "relative": { + "minimum": -0.14, + "maximum": 0.0 + } + } + }, + { + "name": "RAM for global variables", + "maximum": 2560, + "delta": { + "absolute": { + "minimum": -16, + "maximum": 0 + }, + "relative": { + "minimum": -0.62, + "maximum": 0.0 + } + } + } + ], + "warnings": { + "delta": { + "absolute": { + "minimum": 0, + "maximum": 0 + } + } + } + } + ] +} diff --git a/.github/workflows/testdata/artifact-source/multi-report-artifact/arduino-sam-arduino_due_x.json b/.github/workflows/testdata/artifact-source/multi-report-artifact/arduino-sam-arduino_due_x.json new file mode 100644 index 0000000..6b32edf --- /dev/null +++ b/.github/workflows/testdata/artifact-source/multi-report-artifact/arduino-sam-arduino_due_x.json @@ -0,0 +1,245 @@ +{ + "commit_hash": "0123456789abcdef0123456789abcdef01234567", + "commit_url": "https://github.com/per1234/generate-size-deltas-report/commit/651f05f4d4aca30ac359e972c01568f873112d43", + "boards": [ + { + "board": "arduino:sam:arduino_due_x", + "sketches": [ + { + "name": "examples/MIDIUSB_clock", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 524288, + "current": { + "absolute": 11792, + "relative": 2.25 + }, + "previous": { + "absolute": 11792, + "relative": 2.25 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + }, + { + "name": "RAM for global variables", + "maximum": "N/A", + "current": { + "absolute": "N/A", + "relative": "N/A" + }, + "previous": { + "absolute": "N/A", + "relative": "N/A" + }, + "delta": { + "absolute": "N/A", + "relative": "N/A" + } + } + ], + "warnings": { + "current": { + "absolute": 5 + }, + "previous": { + "absolute": 5 + }, + "delta": { + "absolute": 0 + } + } + }, + { + "name": "examples/MIDIUSB_loop", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 524288, + "current": { + "absolute": 11640, + "relative": 2.22 + }, + "previous": { + "absolute": 11640, + "relative": 2.22 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + }, + { + "name": "RAM for global variables", + "maximum": "N/A", + "current": { + "absolute": "N/A", + "relative": "N/A" + }, + "previous": { + "absolute": "N/A", + "relative": "N/A" + }, + "delta": { + "absolute": "N/A", + "relative": "N/A" + } + } + ], + "warnings": { + "current": { + "absolute": 6 + }, + "previous": { + "absolute": 6 + }, + "delta": { + "absolute": 0 + } + } + }, + { + "name": "examples/MIDIUSB_read", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 524288, + "current": { + "absolute": 11808, + "relative": 2.25 + }, + "previous": { + "absolute": 11808, + "relative": 2.25 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + }, + { + "name": "RAM for global variables", + "maximum": "N/A", + "current": { + "absolute": "N/A", + "relative": "N/A" + }, + "previous": { + "absolute": "N/A", + "relative": "N/A" + }, + "delta": { + "absolute": "N/A", + "relative": "N/A" + } + } + ], + "warnings": { + "current": { + "absolute": 6 + }, + "previous": { + "absolute": 6 + }, + "delta": { + "absolute": 0 + } + } + }, + { + "name": "examples/MIDIUSB_write", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 524288, + "current": { + "absolute": 11680, + "relative": 2.23 + }, + "previous": { + "absolute": 11680, + "relative": 2.23 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + }, + { + "name": "RAM for global variables", + "maximum": "N/A", + "current": { + "absolute": "N/A", + "relative": "N/A" + }, + "previous": { + "absolute": "N/A", + "relative": "N/A" + }, + "delta": { + "absolute": "N/A", + "relative": "N/A" + } + } + ], + "warnings": { + "current": { + "absolute": 6 + }, + "previous": { + "absolute": 6 + }, + "delta": { + "absolute": 0 + } + } + } + ], + "sizes": [ + { + "name": "flash", + "maximum": 524288, + "delta": { + "absolute": { + "minimum": 0, + "maximum": 0 + }, + "relative": { + "minimum": 0.0, + "maximum": 0.0 + } + } + }, + { + "name": "RAM for global variables", + "maximum": "N/A", + "delta": { + "absolute": { + "minimum": "N/A", + "maximum": "N/A" + }, + "relative": { + "minimum": "N/A", + "maximum": "N/A" + } + } + } + ], + "warnings": { + "delta": { + "absolute": { + "minimum": 0, + "maximum": 0 + } + } + } + } + ] +} diff --git a/.github/workflows/testdata/artifact-source/per-report-artifact/arduino-samd-mkrzero.json b/.github/workflows/testdata/artifact-source/per-report-artifact/arduino-samd-mkrzero.json new file mode 100644 index 0000000..c75f869 --- /dev/null +++ b/.github/workflows/testdata/artifact-source/per-report-artifact/arduino-samd-mkrzero.json @@ -0,0 +1,245 @@ +{ + "commit_hash": "0123456789abcdef0123456789abcdef01234567", + "commit_url": "https://github.com/per1234/generate-size-deltas-report/commit/651f05f4d4aca30ac359e972c01568f873112d43", + "boards": [ + { + "board": "arduino:samd:mkrzero", + "sketches": [ + { + "name": "examples/MIDIUSB_clock", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 262144, + "current": { + "absolute": 11976, + "relative": 4.57 + }, + "previous": { + "absolute": 11892, + "relative": 4.54 + }, + "delta": { + "absolute": 84, + "relative": 0.03 + } + }, + { + "name": "RAM for global variables", + "maximum": 32768, + "current": { + "absolute": 2300, + "relative": 7.02 + }, + "previous": { + "absolute": 2300, + "relative": 7.02 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + } + ], + "warnings": { + "current": { + "absolute": 3 + }, + "previous": { + "absolute": 3 + }, + "delta": { + "absolute": 0 + } + } + }, + { + "name": "examples/MIDIUSB_loop", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 262144, + "current": { + "absolute": 11784, + "relative": 4.5 + }, + "previous": { + "absolute": 11784, + "relative": 4.5 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + }, + { + "name": "RAM for global variables", + "maximum": 32768, + "current": { + "absolute": 2296, + "relative": 7.01 + }, + "previous": { + "absolute": 2296, + "relative": 7.01 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + } + ], + "warnings": { + "current": { + "absolute": 4 + }, + "previous": { + "absolute": 4 + }, + "delta": { + "absolute": 0 + } + } + }, + { + "name": "examples/MIDIUSB_read", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 262144, + "current": { + "absolute": 11940, + "relative": 4.55 + }, + "previous": { + "absolute": 11968, + "relative": 4.57 + }, + "delta": { + "absolute": -28, + "relative": -0.01 + } + }, + { + "name": "RAM for global variables", + "maximum": 32768, + "current": { + "absolute": 2296, + "relative": 7.01 + }, + "previous": { + "absolute": 2296, + "relative": 7.01 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + } + ], + "warnings": { + "current": { + "absolute": 4 + }, + "previous": { + "absolute": 4 + }, + "delta": { + "absolute": 0 + } + } + }, + { + "name": "examples/MIDIUSB_write", + "compilation_success": true, + "sizes": [ + { + "name": "flash", + "maximum": 262144, + "current": { + "absolute": 11808, + "relative": 4.5 + }, + "previous": { + "absolute": 11808, + "relative": 4.5 + }, + "delta": { + "absolute": 0, + "relative": 0.0 + } + }, + { + "name": "RAM for global variables", + "maximum": 32768, + "current": { + "absolute": 2064, + "relative": 6.3 + }, + "previous": { + "absolute": 2032, + "relative": 6.2 + }, + "delta": { + "absolute": 32, + "relative": 0.1 + } + } + ], + "warnings": { + "current": { + "absolute": 4 + }, + "previous": { + "absolute": 4 + }, + "delta": { + "absolute": 0 + } + } + } + ], + "sizes": [ + { + "name": "flash", + "maximum": 262144, + "delta": { + "absolute": { + "minimum": -28, + "maximum": 84 + }, + "relative": { + "minimum": -0.01, + "maximum": 0.03 + } + } + }, + { + "name": "RAM for global variables", + "maximum": 32768, + "delta": { + "absolute": { + "minimum": 0, + "maximum": 32 + }, + "relative": { + "minimum": 0.0, + "maximum": 0.1 + } + } + } + ], + "warnings": { + "delta": { + "absolute": { + "minimum": 0, + "maximum": 0 + } + } + } + } + ] +} diff --git a/.github/workflows/upload-report-artifact.yml b/.github/workflows/upload-report-artifact.yml index 23705e6..bf29171 100644 --- a/.github/workflows/upload-report-artifact.yml +++ b/.github/workflows/upload-report-artifact.yml @@ -13,6 +13,20 @@ jobs: upload: runs-on: ubuntu-latest + env: + ARTIFACT_NAME_PREFIX: sketches-report- + + strategy: + fail-fast: false + matrix: + parameters: + # Coverage for pre-actions/upload-artifact@v4 approach where all reports are stored in a single artifact. + - artifact-name-suffix: multi + reports-folder: multi-report-artifact + # Coverage for actions/upload-artifact@v4 approach where each report is stored in a separate artifact. + - artifact-name-suffix: arduino-samd-mkrzero + reports-folder: per-report-artifact + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -26,7 +40,7 @@ jobs: echo "SKETCHES_REPORTS_PATH=$SKETCHES_REPORTS_PATH" >> "$GITHUB_ENV" mkdir --parents "$SKETCHES_REPORTS_PATH" - cd "${{ github.workspace }}/.github/workflows/testdata/sketches-reports/" + cd "${{ github.workspace }}/.github/workflows/testdata/artifact-source/${{ matrix.parameters.reports-folder }}" for reportFile in *.json; do jq '.commit_hash = "${{ github.event.pull_request.head.sha }}"' "$reportFile" > "${SKETCHES_REPORTS_PATH}/$reportFile" done @@ -36,4 +50,4 @@ jobs: with: if-no-files-found: error path: ${{ env.SKETCHES_REPORTS_PATH }} - name: sketches-reports + name: ${{ env.ARTIFACT_NAME_PREFIX }}${{ matrix.parameters.artifact-name-suffix }} From aa22d11cf7c17d9cfa7e888599a375a67e5996e1 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 21 Jan 2024 22:33:40 -0800 Subject: [PATCH 4/4] Generate v1 and v2 format test data artifacts A significant change was made to the nature of GitHub Actions workflow artifacts starting from the 2.x release of the `@actions/artifact` package, which was introduced in the 4.0.0 release of the "actions/upload-artifact" GitHub Actions action. It is necessary to provide integration test coverage for compatibility of the "arduino/report-size-deltas" action with the v2 format artifacts produced by actions/upload-artifact@v4. It is also important to continue to cover compatibility with the v1 format artifacts produced by actions/upload-artifact@v3, to support users who have not gotten around to updating that action dependency in their sketch compilation workflows (especially since the breaking change introduced by actions/upload-artifact@v4 will make it necessary to adjust the configuration of the workflow). The chosen approach is to configure the "Upload test sketches report artifact" workflow to use actions/upload-artifact@v3 when upload one of the test data artifacts and actions/upload-artifact@v4 when uploading the other. Even though the produced test data would not occur under real world usage, it is the cleanest way (the alternative being to create and maintain separate copies of the system implemented in the `report-target-pr` branch for each major version of the actions/upload-artifact action) to provide effective integration test coverage. --- .github/workflows/upload-report-artifact.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload-report-artifact.yml b/.github/workflows/upload-report-artifact.yml index bf29171..b303a57 100644 --- a/.github/workflows/upload-report-artifact.yml +++ b/.github/workflows/upload-report-artifact.yml @@ -22,9 +22,11 @@ jobs: parameters: # Coverage for pre-actions/upload-artifact@v4 approach where all reports are stored in a single artifact. - artifact-name-suffix: multi + artifact-version: 1 reports-folder: multi-report-artifact # Coverage for actions/upload-artifact@v4 approach where each report is stored in a separate artifact. - artifact-name-suffix: arduino-samd-mkrzero + artifact-version: 2 reports-folder: per-report-artifact steps: @@ -45,9 +47,20 @@ jobs: jq '.commit_hash = "${{ github.event.pull_request.head.sha }}"' "$reportFile" > "${SKETCHES_REPORTS_PATH}/$reportFile" done - - name: Save sketches report as workflow artifact + - name: Save sketches report as v1 format workflow artifact + if: matrix.parameters.artifact-version == '1' + # actions/upload-artifact 3.x is the last version to produce v1 format artifacts: + # https://github.com/actions/upload-artifact/blob/main/README.md#v4---whats-new uses: actions/upload-artifact@v3 with: if-no-files-found: error path: ${{ env.SKETCHES_REPORTS_PATH }} name: ${{ env.ARTIFACT_NAME_PREFIX }}${{ matrix.parameters.artifact-name-suffix }} + + - name: Save sketches report as v2 format workflow artifact + if: matrix.parameters.artifact-version == '2' + uses: actions/upload-artifact@v4 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.ARTIFACT_NAME_PREFIX }}${{ matrix.parameters.artifact-name-suffix }}