Skip to content

Commit 070a102

Browse files
committed
Add size reports
1 parent 42ea8c2 commit 070a102

13 files changed

Lines changed: 447 additions & 54 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Checkout submodules & Bootstrap Matter CPP SDK
2+
description: Checkout submodules & Bootstrap Matter CPP SDK
3+
inputs:
4+
platform:
5+
description: "Platform name"
6+
required: true
7+
extra-submodule-parameters:
8+
description: "extra submodule parameters"
9+
required: false
10+
default: ""
11+
bootstrap-log-name:
12+
description: "Bootstrap log name"
13+
required: false
14+
default: bootstrap-logs-${{ github.job }}
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Maximize runner disk
19+
uses: ./.github/actions/maximize-runner-disk
20+
- name: Dump disk info
21+
uses: ./.github/actions/dump-disk-info
22+
- name: Set git safe directory for local act runs
23+
uses: ./.github/actions/git-safe-directory
24+
- name: Checkout submodules
25+
uses: ./.github/actions/checkout-submodules
26+
with:
27+
platform: ${{ inputs.platform }}
28+
extra-parameters: ${{ inputs.extra-submodule-parameters }}
29+
- name: Bootstrap
30+
uses: ./.github/actions/bootstrap
31+
with:
32+
platform: ${{ inputs.platform }}
33+
bootstrap-log-name: ${{ inputs.bootstrap-log-name }}
34+
- name: Dump disk info after checkout submodule & Bootstrap
35+
shell: bash
36+
run: scripts/dump_diskspace_info.sh
37+
- name: Work around TSAN ASLR issues
38+
if: runner.os == 'Linux' && !env.ACT
39+
shell: bash
40+
run: |
41+
# See https://stackoverflow.com/a/77856955/2365113
42+
if [[ "$UID" == 0 ]]; then function sudo() { "$@"; }; fi
43+
sudo sysctl vm.mmap_rnd_bits=28
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Checkout submodules
2+
description: Checkout submodules
3+
inputs:
4+
extra-parameters:
5+
description: "extra parameters"
6+
required: false
7+
default: ""
8+
platform:
9+
description: "Platform name"
10+
required: true
11+
runs:
12+
using: "composite"
13+
steps:
14+
- uses: Wandalen/wretry.action@v1.4.10
15+
name: Checkout submodules
16+
with:
17+
command: scripts/checkout_submodules.py --allow-changing-global-git-config --shallow --platform ${{ inputs.platform }} ${{ inputs.extra-parameters }}
18+
attempt_limit: 3
19+
attempt_delay: 2000
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Dump disk space info
2+
description: Help debug running out of disk space on github CI
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Collect disk info
7+
# Unfortunately current syntax for github wrapper actions only work for
8+
# Javascript actions, and Docker container actions, which doesn't make it
9+
# possible to wrap a shell script like the one below. The action below
10+
# essentially wraps the shell commands we want to run into a Javascript
11+
# wrapped action. This allow us to get the disk info usage before a job
12+
# is run and after the job is run regardless if the job succeeds or
13+
# fails.
14+
uses: pyTooling/Actions/with-post-step@v0.4.5
15+
if: ${{ runner.os == 'Linux' }}
16+
with:
17+
main: |-
18+
exec ./matter_cpp/repo/scripts/dump_diskspace_info.sh
19+
post: |-
20+
exec ./matter_cpp/repo/scripts/dump_diskspace_info.sh
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Git safe directory
2+
description: For running act with checkout owned by non-root user
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Set git safe.directory to "*"
7+
if: ${{ env.ACT }}
8+
shell: bash
9+
run: git config --system --add safe.directory '*'
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Maximize runner disk
2+
description: Free up disk space on the github runner
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Free up disk space on the github runner
7+
if: runner.os == 'Linux' && !env.ACT
8+
shell: bash
9+
run: |
10+
# maximize-runner-disk
11+
# Directories to prune to free up space. Candidates:
12+
# 1.6G /usr/share/dotnet
13+
# 1.1G /usr/local/lib/android/sdk/platforms
14+
# 1000M /usr/local/lib/android/sdk/build-tools
15+
# 8.9G /usr/local/lib/android/sdk
16+
# This list can be amended later to change the trade-off between the amount of
17+
# disk space freed up, and how long it takes to do so (deleting many files is slow).
18+
prune=(/usr/share/dotnet /usr/local/lib/android/sdk/platforms /usr/local/lib/android/sdk/build-tools)
19+
20+
if [[ "$UID" -eq 0 && -d /__w ]]; then
21+
root=/runner-root-volume
22+
if [[ ! -d "$root" ]]; then
23+
echo "Unable to maximize disk space, job is running inside a container and $root is not mounted"
24+
exit 0
25+
fi
26+
function sudo() { "$@"; } # we're already root (and sudo is probably unavailable)
27+
elif [[ "$UID" -ne 0 && "$RUNNER_ENVIRONMENT" == github-hosted ]]; then
28+
root=
29+
else
30+
echo "Unable to maximize disk space, unknown runner environment"
31+
exit 0
32+
fi
33+
34+
echo "Freeing up runner disk space on ${root:-/}"
35+
function avail() { df -k --output=avail "${root:-/}" | grep '^[0-9]*$'; }
36+
function now() { date '+%s'; }
37+
before="$(avail)" start="$(now)"
38+
for dir in "${prune[@]}"; do
39+
if [[ -d "${root}${dir}" ]]; then
40+
echo "- $dir"
41+
# du -sh -- "${root}${dir}"
42+
sudo rm -rf -- "${root}${dir}"
43+
else
44+
echo "- $dir (not found)"
45+
fi
46+
done
47+
after="$(avail)" end="$(now)"
48+
echo "Done, freed up $(( (after - before) / 1024 ))M of disk space in $(( end - start )) seconds."
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Setup size reports
2+
description: Setup size reports
3+
inputs:
4+
gh-context:
5+
description: "GH Context"
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Set up environment for size reports
12+
shell: bash
13+
env:
14+
GH_CONTEXT: ${{ inputs.gh-context }}
15+
run: matter_cpp/repo/scripts/tools/memory/gh_sizes_environment.py "${GH_CONTEXT}"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: upload-size-reports
2+
description: upload-size-reports
3+
inputs:
4+
platform-name:
5+
description: "Platform name Name"
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Uploading Size Reports
12+
uses: actions/upload-artifact@v4
13+
if: ${{ !env.ACT }}
14+
with:
15+
name: Size,${{ inputs.platform-name }}-Examples,${{ env.GH_EVENT_PR }},${{ env.GH_EVENT_HASH }},${{ env.GH_EVENT_PARENT }},${{ github.event_name }}
16+
path: |
17+
/tmp/bloat_reports/
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: "50 6 * * *"
10+
workflow_dispatch:
11+
12+
env:
13+
RUST_TOOLCHAIN: stable
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
CARGO_TERM_COLOR: always
16+
17+
jobs:
18+
build_and_run_size_report:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Rust
23+
uses: dtolnay/rust-toolchain@v1
24+
with:
25+
toolchain: ${{ env.RUST_TOOLCHAIN }}
26+
components: rustfmt, clippy, rust-src
27+
28+
- name: Setup | Rust no-std target
29+
run: rustup target add riscv32imac-unknown-none-elf
30+
31+
- name: Install libdbus
32+
run: sudo apt-get install -y libdbus-1-dev
33+
34+
- name: Checkout
35+
uses: actions/checkout@v3
36+
37+
- name: Checkout submodules & Matter CPP Bootstrap
38+
uses: ./.github/actions/checkout-submodules-and-cpp-bootstrap
39+
with:
40+
platform: linux
41+
42+
- name: Set up environment for size reports
43+
uses: ./.github/actions/setup-size-reports
44+
if: ${{ !env.ACT }}
45+
with:
46+
gh-context: ${{ toJson(github) }}
47+
48+
- name: Examples
49+
run: cargo build --examples --release --no-default-features --features os,rustcrypto,log
50+
51+
- name: Prepare bloat report from the previous builds
52+
run: |
53+
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
54+
linux rs-matter onoff-light-bt \
55+
target/release/onoff_light_bt \
56+
/tmp/bloat_reports/
57+
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
58+
linux rs-matter dimmable_light \
59+
target/release/dimmable_light \
60+
/tmp/bloat_reports/
61+
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
62+
linux rs-matter speaker \
63+
target/release/speaker \
64+
/tmp/bloat_reports/
65+
66+
- name: Uploading Size Reports
67+
uses: ./.github/actions/upload-size-reports
68+
if: ${{ !env.ACT }}
69+
with:
70+
platform-name: linux

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "matter_cpp/repo"]
2+
path = matter_cpp/repo
3+
url = https://github.com/project-chip/connectedhomeip.git
4+
branch = v1.3-branch

0 commit comments

Comments
 (0)