Skip to content
This repository was archived by the owner on Apr 1, 2022. It is now read-only.

Commit 9d3ee6b

Browse files
committed
Add memory usage trends report feature to compile-examples action
When the feature is enabled, memory usage data for a selected example sketch is published to a Google Sheets spreadsheet on every push to the repository's default branch.
1 parent d8b5615 commit 9d3ee6b

File tree

7 files changed

+845
-84
lines changed

7 files changed

+845
-84
lines changed

libraries/compile-examples/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CMD /bin/bash
77

88
# Copies your code file from your action repository to the filesystem path `/` of the container
99
COPY entrypoint.sh /entrypoint.sh
10+
COPY reportsizetrends /reportsizetrends
1011

1112
# Code file to execute when the docker container starts up (`entrypoint.sh`)
1213
ENTRYPOINT ["/entrypoint.sh"]

libraries/compile-examples/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,61 @@ Set to `true` to cause the action to determine the change in memory usage for th
3636

3737
Folder to save the JSON formatted memory usage change reports to. Should be used only to store reports. It will be created under [`GITHUB_WORKSPACE`](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables). The folder will be created if it doesn't already exist. Default `"size-deltas-reports"`.
3838

39+
### `enable-size-trends-report`
40+
41+
Set to `true` to cause the action to record the memory usage of [`size-reports-sketch`](#size-reports-sketch) to a Google Sheets spreadsheet on every push to the repository's default branch. Default `false`.
42+
43+
### `size-trends-report-key-file`
44+
45+
Contents of the Google key file used to update the size trends report Google Sheets spreadsheet. This should be defined using a [GitHub secret](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets). Default `""`.
46+
1. Open https://console.developers.google.com/project
47+
1. Click the "Create Project" button.
48+
1. In the "Project name" field, enter the name you want for your project.
49+
1. You don't need to select anything from the "Location" menu.
50+
1. Click the button with the three horizontal lines at the top left corner of the window.
51+
1. Hover the mouse pointer over "APIs & Services".
52+
1. Click "Library".
53+
1. Make sure the name of the project you created is selected from the dropdown menu at the top of the window.
54+
1. Click 'Google Sheets API".
55+
1. Click the "Enable" button.
56+
1. Click the "Create Credentials" button.
57+
1. From the "Which API are you using?" menu, select "Google Sheets API".
58+
1. From the "Where will you be calling the API from?" menu, select "Other non-UI".
59+
1. From the "What data will you be accessing?" options, select "Application data".
60+
1. From the "Are you planning to use this API with App Engine or Compute Engine?" options, select "No, I’m not using them".
61+
1. Click the "What credentials do I need?" button.
62+
1. In the "Service account name" field, enter the name you want to use for the service account.
63+
1. From the "Role" menu, select "Project > Editor".
64+
1. From the "Key type" options, select "JSON".
65+
1. Click the "Continue" button. The .json file containing your private key will be downloaded. Save this somewhere safe.
66+
1. Open the downloaded file.
67+
1. Copy the entire contents of the file to the clipboard.
68+
1. Open the GitHub page of the repository you are configuring the GitHub Actions workflow for.
69+
1. Click the "Settings" tab.
70+
1. From the menu on the left side of the window, click "Secrets".
71+
1. Click the "Add a new secret" link.
72+
1. In the "Name" field, enter the variable name you want to use for your secret. This will be used for the `size-trends-report-key-file` argument of the `compile-examples` action in your workflow configuration file. For example, if you named the secret `GOOGLE_KEY_FILE`, you would reference it in your workflow configuration as `${{ secrets.GOOGLE_KEY_FILE }}`.
73+
1. In the "Value" field, paste the contents of the key file.
74+
1. Click the "Add secret" button.
75+
1. Open the downloaded key file again.
76+
1. Copy the email address shown in the `client_email` field.
77+
1. Open Google Sheets: https://docs.google.com/spreadsheets
78+
1. Under "Start a new spreadsheet", click "Blank".
79+
1. Click the "Share" button at the top right corner of the window.
80+
1. If you haven't already, give your spreadsheet a name.
81+
1. Paste the `client_email` email address into the "Enter names or email addresses..." field.
82+
1. Uncheck the box next to "Notify people".
83+
1. Click the "OK" button.
84+
1. In the "Skip sending invitations?" dialog, click the "OK" button.
85+
86+
### `size-trends-report-spreadsheet-id`
87+
88+
The ID of the Google Sheets spreadsheet to write the memory usage trends data to. The URL of your spreadsheet will look something like `https://docs.google.com/spreadsheets/d/15WOp3vp-6AnTnWlNWaNWNl61Fe_j8UJhIKE0rVdV-7U/edit#gid=0`. In this example, the spreadsheet ID is `15WOp3vp-6AnTnWlNWaNWNl61Fe_j8UJhIKE0rVdV-7U`. Default `""`.
89+
90+
### `size-trends-report-sheet-name`
91+
92+
The sheet name in the Google Sheets spreadsheet used for the memory usage trends report. Default `"Sheet1"`.
93+
3994
## Example usage
4095

4196
Only compiling examples:
@@ -57,3 +112,15 @@ Storing the memory usage change report as a [workflow artifact](https://help.git
57112
name: size-deltas-reports
58113
path: size-delta-reports
59114
```
115+
116+
Publishing memory usage trends data to a Google Sheets spreadsheet:
117+
```yaml
118+
- uses: arduino/actions/libraries/compile-examples@master
119+
env:
120+
SIZE_TRENDS_REPORT_KEY_FILE: ${{ secrets.GOOGLE_KEY_FILE }}
121+
with:
122+
size-report-sketch: Foobar
123+
enable-size-trends-report: true
124+
keyfile: ${{ secrets.GOOGLE_KEY_FILE }}
125+
size-trends-report-spreadsheet-id: 15WOp3vp-6AnTnWlNWaNWNl61Fe_j8UJhIKE0rVdV-7U
126+
```

libraries/compile-examples/action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ inputs:
2222
size-deltas-report-folder-name:
2323
description: 'Folder to save the memory usage change report to'
2424
default: 'size-deltas-reports'
25+
enable-size-trends-report:
26+
description: 'Set to true to cause the action to record the memory usage of size-reports-sketch'
27+
default: false
28+
keyfile:
29+
description: 'Google key file used to update the size trends report Google Sheets spreadsheet.'
30+
default: ''
31+
size-trends-report-spreadsheet-id:
32+
description: 'The ID of the Google Sheets spreadsheet to write the memory usage trends data to'
33+
default: ''
34+
size-trends-report-sheet-name:
35+
description: 'The sheet name in the Google Sheets spreadsheet used for the memory usage trends report'
36+
default: 'Sheet1'
2537
runs:
2638
using: 'docker'
2739
image: 'Dockerfile'
@@ -33,3 +45,6 @@ runs:
3345
- ${{ inputs.size-report-sketch }}
3446
- ${{ inputs.enable-size-deltas-report }}
3547
- ${{ inputs.size-deltas-report-folder-name }}
48+
- ${{ inputs.enable-size-trends-report }}
49+
- ${{ inputs.size-trends-report-spreadsheet-id }}
50+
- ${{ inputs.size-trends-report-sheet-name }}

0 commit comments

Comments
 (0)