Skip to content

Commit 51833fc

Browse files
committed
Add ability for libraries actions to report changes in memory usage introduced by a PR
Changes in the flash and dynamic memory for global variables usage of an example sketch are determined during the pull request build by the compile-examples action. The action displays the memory usage data in the log and also saves it to a JSON formatted file. The actions/upload-artifact action may be used to create a workflow artifact containing the memory usage data files. The newly added arduino/actions/libraries/report-size-deltas action may be used to provide a table summarizing the memory usage changes as a comment in the pull request thread.
1 parent 32ce2fb commit 51833fc

9 files changed

+969
-0
lines changed

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM python:3-slim AS build-env
2+
ADD . /app
3+
WORKDIR /app
4+
5+
FROM gcr.io/distroless/python3
6+
COPY --from=build-env /app /app
7+
WORKDIR /app
8+
CMD ["/app/reportsizedeltas.py"]

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# libraries/report-size-deltas action
2+
3+
This action comments on the pull request with a report on the change in memory usage of an example sketch. This should be run from a [scheduled workflow](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#onschedule).
4+
5+
## Inputs
6+
7+
### `size-deltas-reports-artifact-name`
8+
9+
Name of the workflow artifact that contains the memory usage data, as specified to the actions/upload-artifact action via the name argument
10+
11+
### `github-token`
12+
13+
GitHub access token used to comment the memory usage comparison results to the PR thread. Default [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token).
14+
15+
## Example usage
16+
17+
```yaml
18+
on:
19+
schedule:
20+
- cron: '*/5 * * * *'
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: arduino/actions/libraries/report-size-deltas@master
26+
```

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: 'Arduino Libraries - Report Size Deltas'
2+
description: 'Comments on the pull request with a report on the change in memory usage of an example sketch'
3+
inputs:
4+
size-deltas-reports-artifact-name:
5+
description: 'Name of the workflow artifact that contains the memory usage data, as specified to the actions/upload-artifact action via the name argument'
6+
default: 'size-deltas-reports'
7+
github-token:
8+
description: 'GitHub access token used to comment the memory usage comparison results to the PR thread'
9+
default: ${{ github.token }}
10+
runs:
11+
using: 'docker'
12+
image: 'Dockerfile'

reportsizedeltas.py

Lines changed: 470 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"fqbn": "adafruit:samd:adafruit_feather_m0",
3+
"sketch": "examples/ConnectionHandlerDemo",
4+
"previous_flash": 10580,
5+
"flash": 10580,
6+
"flash_delta": 0,
7+
"previous_ram": "N/A",
8+
"ram": "N/A",
9+
"ram_delta": "N/A"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"fqbn": "arduino:samd:mkrgsm1400",
3+
"sketch": "examples/ConnectionHandlerDemo",
4+
"previous_flash": "N/A",
5+
"flash": 51636,
6+
"flash_delta": "N/A",
7+
"previous_ram": "N/A",
8+
"ram": 5104,
9+
"ram_delta": "N/A"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"fqbn": "arduino:samd:mkrnb1500",
3+
"sketch": "examples/ConnectionHandlerDemo",
4+
"previous_flash": 50964,
5+
"flash": 50940,
6+
"flash_delta": -24,
7+
"previous_ram": 5068,
8+
"ram": 5068,
9+
"ram_delta": 0
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"fqbn": "esp8266:esp8266:huzzah",
3+
"sketch": "examples/ConnectionHandlerDemo",
4+
"previous_flash": 274588,
5+
"flash": 274620,
6+
"flash_delta": 32,
7+
"previous_ram": 27480,
8+
"ram": 27496,
9+
"ram_delta": 16
10+
}

0 commit comments

Comments
 (0)