Skip to content

Commit 30ab6a1

Browse files
committed
Add simple demonstration workflow for pull_request-triggered workflow
A demonstration workflow is provided in the readme to show how to use the action in the use case where the report workflow is triggered by `pull_request` event. Previously, this workflow demonstrated the more advanced configuration that is required in order to compile for multiple boards. Although this demonstration will be useful to the action users, it might be overwhelming as an introduction to the action usage. A demonstration that only compiles for a single board can be far more simple. Even if the user requires coverage of multiple boards in their application, this will give them a basic understanding of the action usage. The advanced demonstration workflow is hereby moved to the FAQ document, replaced in the readme by a simple demonstration workflow. A link from the readme to the advanced usage demonstration is provided.
1 parent 90ad27d commit 30ab6a1

File tree

2 files changed

+67
-34
lines changed

2 files changed

+67
-34
lines changed

README.md

+7-34
Original file line numberDiff line numberDiff line change
@@ -114,51 +114,24 @@ jobs:
114114

115115
```yaml
116116
on: [push, pull_request]
117-
env:
118-
# It's convenient to set variables for values used multiple times in the workflow
119-
SKETCHES_REPORTS_PATH: sketches-reports
120117
jobs:
121118
compile:
122119
runs-on: ubuntu-latest
123-
strategy:
124-
matrix:
125-
board:
126-
- fqbn: arduino:avr:uno
127-
artifact-name-suffix: arduino-avr-uno
128-
- fqbn: arduino:samd:mkrzero
129-
artifact-name-suffix: arduino-samd-mkrzero
130120
steps:
131121
- uses: actions/checkout@v4
132-
133122
- uses: arduino/compile-sketches@v1
134123
with:
135-
fqbn: ${{ matrix.board.fqbn }}
136124
enable-deltas-report: true
137-
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
125+
- uses: arduino/report-size-deltas@v1
126+
# Only run the action when the workflow is triggered by a pull request.
127+
if: github.event_name == 'pull_request'
128+
```
138129

139-
# This step is needed to pass the size data to the report job
140-
- name: Upload sketches report to workflow artifact
141-
uses: actions/upload-artifact@v4
142-
with:
143-
name: sketches-reports-${{ matrix.board.artifact-name-suffix }}
144-
path: ${{ env.SKETCHES_REPORTS_PATH }}
130+
---
145131

146-
# When using a matrix to compile for multiple boards, it's necessary to use a separate job for the deltas report
147-
report:
148-
needs: compile # Wait for the compile job to finish to get the data for the report
149-
if: github.event_name == 'pull_request' # Only run the job when the workflow is triggered by a pull request
150-
runs-on: ubuntu-latest
151-
steps:
152-
# This step is needed to get the size data produced by the compile jobs
153-
- name: Download sketches reports artifacts
154-
uses: actions/download-artifact@v4
155-
with:
156-
path: ${{ env.SKETCHES_REPORTS_PATH }}
132+
**ⓘ** A more advanced example is available in [the **FAQ**](docs/FAQ.md#workflow-triggered-by-pull_request-event).
157133

158-
- uses: arduino/report-size-deltas@v1
159-
with:
160-
sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}
161-
```
134+
---
162135

163136
## Additional resources
164137

docs/FAQ.md

+60
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,63 @@ flowchart TB
139139
reportAction --> comment
140140
end
141141
```
142+
143+
### Workflow triggered by `pull_request` event
144+
145+
```yaml
146+
on:
147+
- push
148+
- pull_request
149+
150+
env:
151+
# It's convenient to set variables for values used multiple times in the workflow.
152+
SKETCHES_REPORTS_PATH: sketches-reports
153+
154+
jobs:
155+
compile:
156+
runs-on: ubuntu-latest
157+
158+
strategy:
159+
matrix:
160+
board:
161+
# Each element in the sequence produces a matrix job:
162+
- fqbn: arduino:avr:uno
163+
# This suffix will be used to define a unique name for the sketches report artifact.
164+
artifact-name-suffix: arduino-avr-uno
165+
- fqbn: arduino:samd:mkrzero
166+
artifact-name-suffix: arduino-samd-mkrzero
167+
168+
steps:
169+
- uses: actions/checkout@v4
170+
171+
- uses: arduino/compile-sketches@v1
172+
with:
173+
fqbn: ${{ matrix.board.fqbn }}
174+
enable-deltas-report: true
175+
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
176+
177+
# This step is needed to pass the size data to the report job.
178+
- name: Upload sketches report to workflow artifact
179+
uses: actions/upload-artifact@v4
180+
with:
181+
name: sketches-reports-${{ matrix.board.artifact-name-suffix }}
182+
path: ${{ env.SKETCHES_REPORTS_PATH }}
183+
184+
# When using a matrix to compile for multiple boards, it's necessary to use a separate job for the deltas report
185+
report:
186+
needs: compile # Wait for the compile job to finish to get the data for the report
187+
if: github.event_name == 'pull_request' # Only run the job when the workflow is triggered by a pull request
188+
runs-on: ubuntu-latest
189+
190+
steps:
191+
# This step is needed to get the size data produced by the compile jobs
192+
- name: Download sketches reports artifacts
193+
uses: actions/download-artifact@v4
194+
with:
195+
# All workflow artifacts will be downloaded to this location.
196+
path: ${{ env.SKETCHES_REPORTS_PATH }}
197+
198+
- uses: arduino/report-size-deltas@v1
199+
with:
200+
sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}
201+
```

0 commit comments

Comments
 (0)