Skip to content

Commit 7397c38

Browse files
Added CI
1 parent 3dafe2f commit 7397c38

7 files changed

+379
-0
lines changed

.github/dependabot.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# See: https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#about-the-dependabotyml-file
2+
version: 2
3+
4+
updates:
5+
# Configure check for outdated GitHub Actions actions in workflows.
6+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/dependabot/README.md
7+
# See: https://docs.github.com/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
8+
- package-ecosystem: github-actions
9+
directory: /.github/workflows/
10+
schedule:
11+
interval: daily
12+
labels:
13+
- "topic: infrastructure"

.github/workflows/check-arduino.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Check Arduino
2+
3+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
pull_request:
7+
schedule:
8+
# Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint.
9+
- cron: "0 8 * * TUE"
10+
workflow_dispatch:
11+
repository_dispatch:
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Arduino Lint
22+
uses: arduino/arduino-lint-action@v1
23+
with:
24+
compliance: specification
25+
library-manager: update
26+
# Always use this setting for official repositories. Remove for 3rd party projects.
27+
official: true
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Compile Examples
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/compile-examples.yml"
7+
- "examples/**"
8+
- "src/**"
9+
push:
10+
paths:
11+
- ".github/workflows/compile-examples.yml"
12+
- "examples/**"
13+
- "src/**"
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
env:
20+
# libraries to install for all boards
21+
UNIVERSAL_LIBRARIES: |
22+
- source-path: ./
23+
# sketch paths to compile (recursive) for all boards
24+
UNIVERSAL_SKETCH_PATHS: |
25+
- examples/KVStoreValidation
26+
SKETCHES_REPORTS_PATH: sketches-reports
27+
28+
strategy:
29+
fail-fast: false
30+
31+
matrix:
32+
board:
33+
- fqbn: arduino:samd:mkrwifi1010
34+
type: nina
35+
artifact-name-suffix: arduino-samd-mkrwifi1010
36+
- fqbn: arduino:samd:nano_33_iot
37+
type: nina
38+
artifact-name-suffix: arduino-samd-nano_33_iot
39+
- fqbn: arduino:mbed_portenta:envie_m7
40+
type: mbed_portenta
41+
artifact-name-suffix: arduino-mbed_portenta-envie_m7
42+
- fqbn: esp32:esp32:esp32
43+
type: esp32
44+
artifact-name-suffix: esp32-esp32-esp32
45+
- fqbn: arduino:mbed_nano:nanorp2040connect
46+
type: nina
47+
artifact-name-suffix: arduino-mbed_nano-nanorp2040connect
48+
- fqbn: arduino:mbed_nicla:nicla_vision
49+
type: mbed_nicla
50+
artifact-name-suffix: arduino-mbed_nicla-nicla_vision
51+
- fqbn: arduino:mbed_opta:opta
52+
type: mbed_opta
53+
artifact-name-suffix: arduino-mbed_opta-opta
54+
- fqbn: arduino:mbed_giga:giga
55+
type: mbed_giga
56+
artifact-name-suffix: arduino-mbed_giga-giga
57+
- fqbn: arduino:renesas_portenta:portenta_c33
58+
type: renesas_portenta
59+
artifact-name-suffix: arduino-renesas_portenta-portenta_c33
60+
- fqbn: arduino:renesas_uno:unor4wifi
61+
type: renesas_uno
62+
artifact-name-suffix: arduino-renesas_uno-unor4wifi
63+
- fqbn: arduino:esp32:nano_nora
64+
type: arduino_esp32
65+
artifact-name-suffix: arduino-esp32-nano_nora
66+
67+
include:
68+
# MKR WiFi 1010, Nano 33 IoT, Nano RP2040 Connect
69+
- board:
70+
type: nina
71+
libraries: |
72+
- name: WiFiNINA
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v4
76+
77+
- name: Install ESP32 platform dependencies
78+
if: matrix.board.type == 'esp32'
79+
run: pip3 install pyserial
80+
81+
- name: Compile examples
82+
uses: arduino/compile-sketches@v1
83+
with:
84+
github-token: ${{ secrets.GITHUB_TOKEN }}
85+
platforms: ${{ matrix.platforms }}
86+
fqbn: ${{ matrix.board.fqbn }}
87+
libraries: |
88+
${{ env.UNIVERSAL_LIBRARIES }}
89+
${{ matrix.libraries }}
90+
sketch-paths: |
91+
${{ env.UNIVERSAL_SKETCH_PATHS }}
92+
${{ matrix.sketch-paths }}
93+
enable-deltas-report: "true"
94+
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
95+
96+
- name: Save memory usage change report as artifact
97+
if: github.event_name == 'pull_request'
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: sketches-report-${{ matrix.board.artifact-name-suffix }}
101+
path: ${{ env.SKETCHES_REPORTS_PATH }}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Report Size Deltas
2+
3+
# See: https://docs.github.com/en/free-pro-team@latest/free-pro-team@latest/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/report-size-deltas.yml"
8+
schedule:
9+
# Run at the minimum interval allowed by GitHub Actions.
10+
# Note: GitHub Actions periodically has outages which result in workflow failures.
11+
# In this event, the workflows will start passing again once the service recovers.
12+
- cron: "*/5 * * * *"
13+
workflow_dispatch:
14+
repository_dispatch:
15+
16+
jobs:
17+
report:
18+
# Scheduled workflow runs would cause excess GitHub Actions service charges in a private repo
19+
if: github.repository_visibility == 'public'
20+
runs-on: ubuntu-latest
21+
permissions:
22+
pull-requests: write
23+
steps:
24+
- name: Comment size deltas reports to PRs
25+
uses: arduino/report-size-deltas@v1
26+
with:
27+
# Regex matching the names of the workflow artifacts created by the "Compile Examples" workflow
28+
sketches-reports-source: ^sketches-report-.+

.github/workflows/spell-check.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Spell Check
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Spell check
16+
uses: codespell-project/actions-codespell@master

.github/workflows/sync-labels.yml

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md
2+
name: Sync Labels
3+
4+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
paths:
8+
- ".github/workflows/sync-labels.ya?ml"
9+
- ".github/label-configuration-files/*.ya?ml"
10+
pull_request:
11+
paths:
12+
- ".github/workflows/sync-labels.ya?ml"
13+
- ".github/label-configuration-files/*.ya?ml"
14+
schedule:
15+
# Run daily at 8 AM UTC to sync with changes to shared label configurations.
16+
- cron: "0 8 * * *"
17+
workflow_dispatch:
18+
repository_dispatch:
19+
20+
env:
21+
CONFIGURATIONS_FOLDER: .github/label-configuration-files
22+
CONFIGURATIONS_ARTIFACT: label-configuration-files
23+
24+
jobs:
25+
check:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
- name: Download JSON schema for labels configuration file
33+
id: download-schema
34+
uses: carlosperate/download-file-action@v1
35+
with:
36+
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json
37+
location: ${{ runner.temp }}/label-configuration-schema
38+
39+
- name: Install JSON schema validator
40+
run: |
41+
sudo npm install \
42+
--global \
43+
ajv-cli \
44+
ajv-formats
45+
46+
- name: Validate local labels configuration
47+
run: |
48+
# See: https://github.com/ajv-validator/ajv-cli#readme
49+
ajv validate \
50+
--all-errors \
51+
-c ajv-formats \
52+
-s "${{ steps.download-schema.outputs.file-path }}" \
53+
-d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"
54+
55+
download:
56+
needs: check
57+
runs-on: ubuntu-latest
58+
59+
strategy:
60+
matrix:
61+
filename:
62+
# Filenames of the shared configurations to apply to the repository in addition to the local configuration.
63+
# https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels
64+
- universal.yml
65+
66+
steps:
67+
- name: Download
68+
uses: carlosperate/download-file-action@v1
69+
with:
70+
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }}
71+
72+
- name: Pass configuration files to next job via workflow artifact
73+
uses: actions/upload-artifact@v4
74+
with:
75+
path: |
76+
*.yaml
77+
*.yml
78+
if-no-files-found: error
79+
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
80+
81+
sync:
82+
needs: download
83+
runs-on: ubuntu-latest
84+
85+
steps:
86+
- name: Set environment variables
87+
run: |
88+
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
89+
echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV"
90+
91+
- name: Determine whether to dry run
92+
id: dry-run
93+
if: >
94+
github.event_name == 'pull_request' ||
95+
(
96+
(
97+
github.event_name == 'push' ||
98+
github.event_name == 'workflow_dispatch'
99+
) &&
100+
github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
101+
)
102+
run: |
103+
# Use of this flag in the github-label-sync command will cause it to only check the validity of the
104+
# configuration.
105+
echo "::set-output name=flag::--dry-run"
106+
107+
- name: Checkout repository
108+
uses: actions/checkout@v4
109+
110+
- name: Download configuration files artifact
111+
uses: actions/download-artifact@v4
112+
with:
113+
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
114+
path: ${{ env.CONFIGURATIONS_FOLDER }}
115+
116+
- name: Remove unneeded artifact
117+
uses: geekyeggo/delete-artifact@v5
118+
with:
119+
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
120+
121+
- name: Merge label configuration files
122+
run: |
123+
# Merge all configuration files
124+
shopt -s extglob
125+
cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"
126+
127+
- name: Install github-label-sync
128+
run: sudo npm install --global github-label-sync
129+
130+
- name: Sync labels
131+
env:
132+
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
run: |
134+
# See: https://github.com/Financial-Times/github-label-sync
135+
github-label-sync \
136+
--labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
137+
${{ steps.dry-run.outputs.flag }} \
138+
${{ github.repository }}

.github/workflows/unit-tests.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Unit Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/unit-tests.yml"
7+
- 'extras/test/**'
8+
- 'src/**'
9+
10+
push:
11+
paths:
12+
- ".github/workflows/unit-tests.yml"
13+
- 'extras/test/**'
14+
- 'src/**'
15+
16+
jobs:
17+
test:
18+
name: Run unit tests
19+
runs-on: ubuntu-latest
20+
21+
env:
22+
COVERAGE_DATA_PATH: extras/coverage-data/coverage.info
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- uses: arduino/cpp-test-action@main
29+
with:
30+
runtime-paths: |
31+
- extras/test/build/bin/testArduinoKVStore
32+
coverage-exclude-paths: |
33+
- '*/extras/test/*'
34+
- '/usr/*'
35+
coverage-data-path: ${{ env.COVERAGE_DATA_PATH }}
36+
37+
# A token is used to avoid intermittent spurious job failures caused by rate limiting.
38+
- name: Set up Codecov upload token
39+
run: |
40+
if [[ "${{ github.repository }}" == "arduino-libraries/Arduino_CloudUtils" ]]; then
41+
# In order to avoid uploads of data from forks, only use the token for runs in the parent repo.
42+
# Token is intentionally exposed.
43+
# See: https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
44+
CODECOV_TOKEN="47827969-3fda-4ba1-9506-e8d0834ed88c"
45+
else
46+
# codecov/codecov-action does unauthenticated upload if empty string is passed via the `token` input.
47+
CODECOV_TOKEN="${{ secrets.CODECOV_TOKEN }}"
48+
fi
49+
echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> "$GITHUB_ENV"
50+
51+
- name: Upload coverage report to Codecov
52+
uses: codecov/codecov-action@v3
53+
with:
54+
file: "${{ env.COVERAGE_DATA_PATH }}"
55+
fail_ci_if_error: true
56+
token: ${{ env.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)