Skip to content

Commit 1d76b09

Browse files
authored
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 actions/checkout#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`
1 parent 75dce31 commit 1d76b09

9 files changed

+107
-9
lines changed

.github/workflows/examples-efr32.yaml

+13-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
BUILD_TYPE: gn_efr32
3333
GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }}
3434
GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
35-
GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
35+
GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
3636

3737
runs-on: ubuntu-latest
3838
if: github.actor != 'restyled-io[bot]'
@@ -46,6 +46,17 @@ jobs:
4646
uses: actions/checkout@v2
4747
with:
4848
submodules: true
49+
50+
- name: Get parent for size reports
51+
shell: bash
52+
run: |
53+
MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')"
54+
if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0
55+
then
56+
MERGE_PARENT=$GH_EVENT_BASE
57+
fi
58+
echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV
59+
4960
- name: Bootstrap
5061
timeout-minutes: 25
5162
run: scripts/build/gn_bootstrap.sh
@@ -82,6 +93,7 @@ jobs:
8293
scripts/examples/gn_efr32_example.sh examples/window-app/efr32/ out/window_app_debug BRD4161A
8394
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py efr32 BRD4161A window-app \
8495
out/window_app_debug/BRD4161A/chip-efr32-window-example.out /tmp/bloat_reports/
96+
8597
- name: Uploading Size Reports
8698
uses: actions/upload-artifact@v2
8799
if: ${{ !env.ACT }}

.github/workflows/examples-esp32.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
BUILD_TYPE: esp32
3333
GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }}
3434
GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
35-
GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
35+
GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
3636

3737
runs-on: ubuntu-latest
3838
if: github.actor != 'restyled-io[bot]'
@@ -47,6 +47,16 @@ jobs:
4747
uses: actions/checkout@v2
4848
with:
4949
submodules: true
50+
51+
- name: Get parent for size reports
52+
run: |
53+
MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')"
54+
if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0
55+
then
56+
MERGE_PARENT=$GH_EVENT_BASE
57+
fi
58+
echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV
59+
5060
- name: Bootstrap
5161
timeout-minutes: 25
5262
run: scripts/build/gn_bootstrap.sh
@@ -103,6 +113,7 @@ jobs:
103113
- name: Build example IPv6 Only App
104114
timeout-minutes: 10
105115
run: scripts/examples/esp_example.sh ipv6only-app sdkconfig.defaults
116+
106117
- name: Uploading Size Reports
107118
uses: actions/upload-artifact@v2
108119
if: ${{ !env.ACT }}

.github/workflows/examples-infineon.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
env:
3232
GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }}
3333
GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
34-
GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
34+
GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
3535

3636
runs-on: ubuntu-latest
3737
if: github.actor != 'restyled-io[bot]'
@@ -44,6 +44,16 @@ jobs:
4444
uses: actions/checkout@v2
4545
with:
4646
submodules: true
47+
48+
- name: Get parent for size reports
49+
run: |
50+
MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')"
51+
if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0
52+
then
53+
MERGE_PARENT=$GH_EVENT_BASE
54+
fi
55+
echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV
56+
4757
- name: Bootstrap
4858
timeout-minutes: 25
4959
run: scripts/build/gn_bootstrap.sh
@@ -71,6 +81,7 @@ jobs:
7181
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
7282
p6 default all-clusters-app \
7383
out/infineon-p6-all-clusters/chip-p6-clusters-example.out
84+
7485
- name: Uploading Size Reports
7586
uses: actions/upload-artifact@v2
7687
if: ${{ !env.ACT }}

.github/workflows/examples-k32w.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
BUILD_TYPE: gn_k32w
3232
GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }}
3333
GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
34-
GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
34+
GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
3535

3636
runs-on: ubuntu-latest
3737
if: github.actor != 'restyled-io[bot]'
@@ -45,6 +45,16 @@ jobs:
4545
uses: actions/checkout@v2
4646
with:
4747
submodules: true
48+
49+
- name: Get parent for size reports
50+
run: |
51+
MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')"
52+
if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0
53+
then
54+
MERGE_PARENT=$GH_EVENT_BASE
55+
fi
56+
echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV
57+
4858
- name: Bootstrap
4959
timeout-minutes: 25
5060
run: scripts/build/gn_bootstrap.sh
@@ -83,6 +93,7 @@ jobs:
8393
k32w k32w061+se05x+release lighting-app \
8494
out/lighting_app_se_release/chip-k32w061-light-example \
8595
/tmp/bloat_reports/
96+
8697
- name: Uploading Size Reports
8798
uses: actions/upload-artifact@v2
8899
if: ${{ !env.ACT }}

.github/workflows/examples-linux-standalone.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
BUILD_TYPE: gn_linux
3232
GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }}
3333
GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
34-
GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
34+
GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
3535

3636
runs-on: ubuntu-latest
3737
if: github.actor != 'restyled-io[bot]'
@@ -46,6 +46,16 @@ jobs:
4646
uses: actions/checkout@v2
4747
with:
4848
submodules: true
49+
50+
- name: Get parent for size reports
51+
run: |
52+
MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')"
53+
if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0
54+
then
55+
MERGE_PARENT=$GH_EVENT_BASE
56+
fi
57+
echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV
58+
4959
- name: Bootstrap
5060
timeout-minutes: 10
5161
run: scripts/build/gn_bootstrap.sh
@@ -123,6 +133,7 @@ jobs:
123133
linux debug ota-requestor-app \
124134
out/ota_requestor_debug/chip-ota-requestor-app \
125135
/tmp/bloat_reports/
136+
126137
- name: Uploading Size Reports
127138
uses: actions/upload-artifact@v2
128139
if: ${{ !env.ACT }}

.github/workflows/examples-mbed.yaml

+10-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
APP_TARGET: CY8CPROTO_062_4343W
3535
GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }}
3636
GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
37-
GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
37+
GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
3838

3939
runs-on: ubuntu-latest
4040
if: github.actor != 'restyled-io[bot]'
@@ -50,6 +50,15 @@ jobs:
5050
with:
5151
submodules: true
5252

53+
- name: Get parent for size reports
54+
run: |
55+
MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')"
56+
if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0
57+
then
58+
MERGE_PARENT=$GH_EVENT_BASE
59+
fi
60+
echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV
61+
5362
- name: Bootstrap
5463
timeout-minutes: 10
5564
run: scripts/build/gn_bootstrap.sh

.github/workflows/examples-nrfconnect.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
BUILD_TYPE: nrfconnect
3232
GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }}
3333
GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
34-
GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
34+
GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
3535

3636
runs-on: ubuntu-latest
3737
if: github.actor != 'restyled-io[bot]'
@@ -46,6 +46,16 @@ jobs:
4646
uses: actions/checkout@v2
4747
with:
4848
submodules: true
49+
50+
- name: Get parent for size reports
51+
run: |
52+
MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')"
53+
if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0
54+
then
55+
MERGE_PARENT=$GH_EVENT_BASE
56+
fi
57+
echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV
58+
4959
- name: Bootstrap
5060
timeout-minutes: 25
5161
run: scripts/build/gn_bootstrap.sh
@@ -144,6 +154,7 @@ jobs:
144154
timeout-minutes: 10
145155
run: |
146156
scripts/run_in_build_env.sh "scripts/tests/nrfconnect_native_posix_tests.sh native_posix_64"
157+
147158
- name: Uploading Size Reports
148159
uses: actions/upload-artifact@v2
149160
if: ${{ !env.ACT }}

.github/workflows/examples-qpg.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
BUILD_TYPE: gn_qpg
3232
GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }}
3333
GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
34-
GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
34+
GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
3535

3636
runs-on: ubuntu-latest
3737
if: github.actor != 'restyled-io[bot]'
@@ -45,6 +45,16 @@ jobs:
4545
uses: actions/checkout@v2
4646
with:
4747
submodules: true
48+
49+
- name: Get parent for size reports
50+
run: |
51+
MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')"
52+
if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0
53+
then
54+
MERGE_PARENT=$GH_EVENT_BASE
55+
fi
56+
echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV
57+
4858
- name: Bootstrap
4959
timeout-minutes: 25
5060
run: scripts/build/gn_bootstrap.sh
@@ -85,6 +95,7 @@ jobs:
8595
timeout-minutes: 5
8696
run: |
8797
config/qpg/chip-gn/build.sh
98+
8899
- name: Uploading Size Reports
89100
uses: actions/upload-artifact@v2
90101
if: ${{ !env.ACT }}

.github/workflows/examples-telink.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
BUILD_TYPE: telink
3030
GH_EVENT_PR: ${{ github.event_name == 'pull_request' && github.event.number || 0 }}
3131
GH_EVENT_HASH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
32-
GH_EVENT_PARENT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
32+
GH_EVENT_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
3333

3434
runs-on: ubuntu-latest
3535
if: github.actor != 'restyled-io[bot]'
@@ -44,6 +44,16 @@ jobs:
4444
uses: actions/checkout@v2
4545
with:
4646
submodules: true
47+
48+
- name: Get parent for size reports
49+
run: |
50+
MERGE_PARENT="$(git --no-pager log -1 --pretty=tformat:%s | sed -n -e 's/Merge [0-9a-f]\+ into //p')"
51+
if test -z "${MERGE_PARENT}" || test "${GH_EVENT_PARENT}" = 0
52+
then
53+
MERGE_PARENT=$GH_EVENT_BASE
54+
fi
55+
echo "GH_EVENT_PARENT=$MERGE_PARENT" >>$GITHUB_ENV
56+
4757
- name: Build example Telink Lighting App
4858
run: |
4959
./scripts/run_in_build_env.sh \
@@ -52,6 +62,7 @@ jobs:
5262
telink tlsr9518adk80d lighting-app \
5363
out/telink-tlsr9518adk80d-light/zephyr/zephyr.elf \
5464
/tmp/bloat_reports/
65+
5566
- name: Uploading Size Reports
5667
uses: actions/upload-artifact@v2
5768
if: ${{ !env.ACT }}

0 commit comments

Comments
 (0)