From ddcd43284593fe32b5bf7b6fa28562971d7a8b5d Mon Sep 17 00:00:00 2001 From: Kevin Schoedel <67607049+kpschoedel@users.noreply.github.com> Date: Tue, 16 Nov 2021 14:21:15 -0500 Subject: [PATCH] Size reports: Fix parent SHA race (#11841) * Size reports: Fix parent SHA race #### Problem For a GitHub PR, the actual parent may be different from the commit given by `github.event.pull_request.base.sha` (see https://github.com/actions/checkout/issues/27). In this case, size reports incorrectly include changes from commit(s) between the purported and actual parent. #### Change overview Extract the actual parent from the PR merge commit subject. #### Testing Manually checked externally https://github.com/kpschoedel/actiontest/runs/4226639507 Actual confirmation can only happen on live CI runs. * set $GH_EVENT_PARENT before gh_sizes.py runs * Use `test` instead of `[[` * POSIX `test` --- .github/workflows/examples-efr32.yaml | 14 +++++++++++++- .github/workflows/examples-esp32.yaml | 13 ++++++++++++- .github/workflows/examples-infineon.yaml | 13 ++++++++++++- .github/workflows/examples-k32w.yaml | 13 ++++++++++++- .github/workflows/examples-linux-standalone.yaml | 13 ++++++++++++- .github/workflows/examples-mbed.yaml | 11 ++++++++++- .github/workflows/examples-nrfconnect.yaml | 13 ++++++++++++- .github/workflows/examples-qpg.yaml | 13 ++++++++++++- .github/workflows/examples-telink.yaml | 13 ++++++++++++- 9 files changed, 107 insertions(+), 9 deletions(-) diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 76d5e322f579ff..b54a80ee3f3935 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -32,7 +32,7 @@ jobs: BUILD_TYPE: gn_efr32 GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }} GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} - GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -46,6 +46,17 @@ jobs: uses: actions/checkout@v2 with: submodules: true + + - name: Get parent for size reports + shell: bash + run: | + MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')" + if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0 + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh @@ -82,6 +93,7 @@ jobs: scripts/examples/gn_efr32_example.sh examples/window-app/efr32/ out/window_app_debug BRD4161A .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py efr32 BRD4161A window-app \ out/window_app_debug/BRD4161A/chip-efr32-window-example.out /tmp/bloat_reports/ + - name: Uploading Size Reports uses: actions/upload-artifact@v2 if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index fd40daa2480a73..858a7f6aedd22a 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -32,7 +32,7 @@ jobs: BUILD_TYPE: esp32 GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }} GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} - GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -47,6 +47,16 @@ jobs: uses: actions/checkout@v2 with: submodules: true + + - name: Get parent for size reports + run: | + MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')" + if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0 + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh @@ -103,6 +113,7 @@ jobs: - name: Build example IPv6 Only App timeout-minutes: 10 run: scripts/examples/esp_example.sh ipv6only-app sdkconfig.defaults + - name: Uploading Size Reports uses: actions/upload-artifact@v2 if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index 0f441038a8ddd1..05174f70243398 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -31,7 +31,7 @@ jobs: env: GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }} GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} - GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -44,6 +44,16 @@ jobs: uses: actions/checkout@v2 with: submodules: true + + - name: Get parent for size reports + run: | + MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')" + if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0 + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh @@ -71,6 +81,7 @@ jobs: .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ p6 default all-clusters-app \ out/infineon-p6-all-clusters/chip-p6-clusters-example.out + - name: Uploading Size Reports uses: actions/upload-artifact@v2 if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 1c0a563f0ad45c..76e0f5f7873545 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -31,7 +31,7 @@ jobs: BUILD_TYPE: gn_k32w GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }} GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} - GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -45,6 +45,16 @@ jobs: uses: actions/checkout@v2 with: submodules: true + + - name: Get parent for size reports + run: | + MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')" + if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0 + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh @@ -83,6 +93,7 @@ jobs: k32w k32w061+se05x+release lighting-app \ out/lighting_app_se_release/chip-k32w061-light-example \ /tmp/bloat_reports/ + - name: Uploading Size Reports uses: actions/upload-artifact@v2 if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-linux-standalone.yaml b/.github/workflows/examples-linux-standalone.yaml index 8d9e07118a74da..0c0735f97dea4d 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -31,7 +31,7 @@ jobs: BUILD_TYPE: gn_linux GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }} GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} - GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -46,6 +46,16 @@ jobs: uses: actions/checkout@v2 with: submodules: true + + - name: Get parent for size reports + run: | + MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')" + if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0 + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - name: Bootstrap timeout-minutes: 10 run: scripts/build/gn_bootstrap.sh @@ -123,6 +133,7 @@ jobs: linux debug ota-requestor-app \ out/ota_requestor_debug/chip-ota-requestor-app \ /tmp/bloat_reports/ + - name: Uploading Size Reports uses: actions/upload-artifact@v2 if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-mbed.yaml b/.github/workflows/examples-mbed.yaml index 006ea73c483163..23bc0573e8563c 100644 --- a/.github/workflows/examples-mbed.yaml +++ b/.github/workflows/examples-mbed.yaml @@ -34,7 +34,7 @@ jobs: APP_TARGET: CY8CPROTO_062_4343W GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }} GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} - GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -50,6 +50,15 @@ jobs: with: submodules: true + - name: Get parent for size reports + run: | + MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')" + if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0 + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - name: Bootstrap timeout-minutes: 10 run: scripts/build/gn_bootstrap.sh diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 7df872e55437d7..8f3f8bc026a4db 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -31,7 +31,7 @@ jobs: BUILD_TYPE: nrfconnect GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }} GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} - GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -46,6 +46,16 @@ jobs: uses: actions/checkout@v2 with: submodules: true + + - name: Get parent for size reports + run: | + MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')" + if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0 + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh @@ -144,6 +154,7 @@ jobs: timeout-minutes: 10 run: | scripts/run_in_build_env.sh "scripts/tests/nrfconnect_native_posix_tests.sh native_posix_64" + - name: Uploading Size Reports uses: actions/upload-artifact@v2 if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index 7eb35b94123ee2..ee90789371c815 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -31,7 +31,7 @@ jobs: BUILD_TYPE: gn_qpg GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }} GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} - GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -45,6 +45,16 @@ jobs: uses: actions/checkout@v2 with: submodules: true + + - name: Get parent for size reports + run: | + MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')" + if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0 + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh @@ -85,6 +95,7 @@ jobs: timeout-minutes: 5 run: | config/qpg/chip-gn/build.sh + - name: Uploading Size Reports uses: actions/upload-artifact@v2 if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index d30a655f97eb45..45557aa3f393d4 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -29,7 +29,7 @@ jobs: BUILD_TYPE: telink GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }} GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} - GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -44,6 +44,16 @@ jobs: uses: actions/checkout@v2 with: submodules: true + + - name: Get parent for size reports + run: | + MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')" + if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0 + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - name: Build example Telink Lighting App run: | ./scripts/run_in_build_env.sh \ @@ -52,6 +62,7 @@ jobs: telink tlsr9518adk80d lighting-app \ out/telink-tlsr9518adk80d-light/zephyr/zephyr.elf \ /tmp/bloat_reports/ + - name: Uploading Size Reports uses: actions/upload-artifact@v2 if: ${{ !env.ACT }}