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

Commit 8845005

Browse files
author
Roberto Sora
authored
Merge pull request #18 from per1234/size-reports
Add ability for libraries actions to report changes in memory usage
2 parents a1d5b0a + fbba9bd commit 8845005

16 files changed

+1921
-13
lines changed

libraries/compile-examples/Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
# Container image that runs your code
2-
FROM ubuntu:latest
1+
FROM python:3.8.2
32

43
# Install prerequisites
5-
RUN apt-get update --quiet=2 && apt-get install --quiet=2 --assume-yes wget
6-
CMD /bin/bash
4+
RUN apt-get update && apt-get install -y git wget jq curl \
5+
&& rm -rf /var/lib/apt/lists/*
76

87
# Copies your code file from your action repository to the filesystem path `/` of the container
98
COPY entrypoint.sh /entrypoint.sh
9+
COPY reportsizetrends /reportsizetrends
10+
11+
# Install python dependencies
12+
RUN pip install -r /reportsizetrends/requirements.txt
1013

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

libraries/compile-examples/README.md

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,105 @@ For 3rd party boards, also specify the Boards Manager URL:
2020

2121
List of library dependencies to install (space separated). Default `""`.
2222

23+
### `github-token`
24+
25+
GitHub access token used to get information from the GitHub API. Only needed if you're using the size report features with private repositories. It will be convenient to use [`${{ secrets.GITHUB_TOKEN }}`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token). Default `""`.
26+
27+
### `size-report-sketch`
28+
29+
Name of the sketch used to compare memory usage change. Default `""`.
30+
31+
### `enable-size-deltas-report`
32+
33+
Set to `true` to cause the action to determine the change in memory usage for the [`size-reports-sketch`](#size-reports-sketch) between the pull request branch and the tip of the pull request's base branch. This may be used with the [`arduino/actions/libraries/report-size-deltas` action](https://github.com/arduino/actions/tree/master/libraries/report-size-deltas). Default `false`.
34+
35+
### `size-deltas-report-folder-name`
36+
37+
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"`.
38+
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+
### `keyfile`
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+
2394
## Example usage
2495

96+
Only compiling examples:
97+
```yaml
98+
- uses: arduino/actions/libraries/compile-examples@master
99+
with:
100+
fqbn: 'arduino:avr:uno'
101+
```
102+
103+
Storing the memory usage change report as a [workflow artifact](https://help.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts):
104+
```yaml
105+
- uses: arduino/actions/libraries/compile-examples@master
106+
with:
107+
size-report-sketch: Foobar
108+
enable-size-deltas-report: true
109+
- if: github.event_name == 'pull_request'
110+
uses: actions/upload-artifact@v1
111+
with:
112+
name: size-deltas-reports
113+
path: size-delta-reports
114+
```
115+
116+
Publishing memory usage trends data to a Google Sheets spreadsheet:
25117
```yaml
26-
uses: arduino/actions/libraries/compile-examples@master
27-
with:
28-
fqbn: 'arduino:avr:uno'
118+
- uses: arduino/actions/libraries/compile-examples@master
119+
with:
120+
size-report-sketch: Foobar
121+
enable-size-trends-report: true
122+
keyfile: ${{ secrets.GOOGLE_KEY_FILE }}
123+
size-trends-report-spreadsheet-id: 15WOp3vp-6AnTnWlNWaNWNl61Fe_j8UJhIKE0rVdV-7U
29124
```

libraries/compile-examples/action.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,41 @@ inputs:
1010
libraries:
1111
description: 'List of library dependencies to install (space separated)'
1212
default: ''
13+
github-token:
14+
description: 'GitHub access token used to get information from the GitHub API. Only needed if you are using the size report features with private repositories.'
15+
default: ''
16+
size-report-sketch:
17+
description: 'Name of the sketch used to compare memory usage change'
18+
default: ''
19+
enable-size-deltas-report:
20+
description: 'Set to true to cause the action to determine the change in memory usage for the size-reports-sketch'
21+
default: false
22+
size-deltas-report-folder-name:
23+
description: 'Folder to save the memory usage change report to'
24+
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'
1337
runs:
1438
using: 'docker'
1539
image: 'Dockerfile'
1640
args:
1741
- ${{ inputs.cli-version }}
1842
- ${{ inputs.fqbn }}
1943
- ${{ inputs.libraries }}
44+
- ${{ inputs.github-token }}
45+
- ${{ inputs.size-report-sketch }}
46+
- ${{ inputs.enable-size-deltas-report }}
47+
- ${{ 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)