From c61e299a19024faf36503d2ff653937f053abb21 Mon Sep 17 00:00:00 2001 From: Kevin Schoedel Date: Tue, 16 Nov 2021 10:20:13 -0500 Subject: [PATCH] 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. --- .github/workflows/examples-efr32.yaml | 12 +++++++++++- .github/workflows/examples-esp32.yaml | 12 +++++++++++- .github/workflows/examples-infineon.yaml | 12 +++++++++++- .github/workflows/examples-k32w.yaml | 12 +++++++++++- .github/workflows/examples-linux-standalone.yaml | 12 +++++++++++- .github/workflows/examples-mbed.yaml | 11 ++++++++++- .github/workflows/examples-nrfconnect.yaml | 12 +++++++++++- .github/workflows/examples-qpg.yaml | 12 +++++++++++- .github/workflows/examples-telink.yaml | 12 +++++++++++- 9 files changed, 98 insertions(+), 9 deletions(-) diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 76d5e322f579ff..054a413260dc99 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]' @@ -82,6 +82,16 @@ 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: 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 [[ -z "${MERGE_PARENT}" || "${GH_EVENT_PR}" == 0 ]] + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - 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..8698f1d47259dc 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]' @@ -103,6 +103,16 @@ jobs: - name: Build example IPv6 Only App timeout-minutes: 10 run: scripts/examples/esp_example.sh ipv6only-app sdkconfig.defaults + + - 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 [[ -z "${MERGE_PARENT}" || "${GH_EVENT_PR}" == 0 ]] + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - 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..d403d9a203f22b 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]' @@ -71,6 +71,16 @@ 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: 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 [[ -z "${MERGE_PARENT}" || "${GH_EVENT_PR}" == 0 ]] + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - 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..2b63b6abcb664c 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]' @@ -83,6 +83,16 @@ jobs: k32w k32w061+se05x+release lighting-app \ out/lighting_app_se_release/chip-k32w061-light-example \ /tmp/bloat_reports/ + + - 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 [[ -z "${MERGE_PARENT}" || "${GH_EVENT_PR}" == 0 ]] + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - 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..99f7d24f59a0de 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]' @@ -123,6 +123,16 @@ jobs: linux debug ota-requestor-app \ out/ota_requestor_debug/chip-ota-requestor-app \ /tmp/bloat_reports/ + + - 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 [[ -z "${MERGE_PARENT}" || "${GH_EVENT_PR}" == 0 ]] + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - 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..e89a32c4f7631f 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]' @@ -112,6 +112,15 @@ jobs: timeout-minutes: 10 run: scripts/tests/mbed/mbed_unit_tests.sh -b=$APP_TARGET -p=$APP_PROFILE + - 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 [[ -z "${MERGE_PARENT}" || "${GH_EVENT_PR}" == 0 ]] + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - name: Uploading Size Reports uses: actions/upload-artifact@v2 if: ${{ !env.ACT }} diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 7df872e55437d7..466831dc2b86e7 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]' @@ -144,6 +144,16 @@ jobs: timeout-minutes: 10 run: | scripts/run_in_build_env.sh "scripts/tests/nrfconnect_native_posix_tests.sh native_posix_64" + + - 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 [[ -z "${MERGE_PARENT}" || "${GH_EVENT_PR}" == 0 ]] + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - 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..a3c54b77279920 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]' @@ -85,6 +85,16 @@ jobs: timeout-minutes: 5 run: | config/qpg/chip-gn/build.sh + + - 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 [[ -z "${MERGE_PARENT}" || "${GH_EVENT_PR}" == 0 ]] + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - 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..adf9ac8806e228 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]' @@ -52,6 +52,16 @@ jobs: telink tlsr9518adk80d lighting-app \ out/telink-tlsr9518adk80d-light/zephyr/zephyr.elf \ /tmp/bloat_reports/ + + - 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 [[ -z "${MERGE_PARENT}" || "${GH_EVENT_PR}" == 0 ]] + then + MERGE_PARENT=$GH_EVENT_BASE + fi + echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV + - name: Uploading Size Reports uses: actions/upload-artifact@v2 if: ${{ !env.ACT }}