Skip to content

Commit

Permalink
Size reports: Fix parent SHA race (project-chip#11841)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
kpschoedel committed Nov 17, 2021
1 parent d74839b commit d16edf3
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 9 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]'
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/examples-esp32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]'
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/examples-infineon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]'
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/examples-k32w.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]'
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/examples-linux-standalone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]'
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/examples-mbed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]'
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/examples-nrfconnect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]'
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/examples-qpg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]'
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/examples-telink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]'
Expand All @@ -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 \
Expand All @@ -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 }}
Expand Down

0 comments on commit d16edf3

Please sign in to comment.