Skip to content

Commit

Permalink
added base CI
Browse files Browse the repository at this point in the history
  • Loading branch information
andreagilardoni committed May 31, 2024
1 parent f914956 commit c4dee69
Show file tree
Hide file tree
Showing 15 changed files with 533 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# See: https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#about-the-dependabotyml-file
version: 2

updates:
# Configure check for outdated GitHub Actions actions in workflows.
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/dependabot/README.md
# See: https://docs.github.com/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
- package-ecosystem: github-actions
directory: /.github/workflows/
schedule:
interval: daily
labels:
- "topic: infrastructure"
27 changes: 27 additions & 0 deletions .github/workflows/check-arduino.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Check Arduino

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
pull_request:
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Arduino Lint
uses: arduino/arduino-lint-action@v1
with:
compliance: specification
library-manager: update
# Always use this setting for official repositories. Remove for 3rd party projects.
official: true
112 changes: 112 additions & 0 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Compile Examples

on:
pull_request:
paths:
- ".github/workflows/compile-examples.yml"
- "examples/**"
- "src/**"
push:
paths:
- ".github/workflows/compile-examples.yml"
- "examples/**"
- "src/**"

jobs:
build:
runs-on: ubuntu-latest

env:
# libraries to install for all boards
UNIVERSAL_LIBRARIES: |
- source-path: ./
- name: Arduino_DebugUtils
# sketch paths to compile (recursive) for all boards
UNIVERSAL_SKETCH_PATHS: |
- examples/lzssDecoder
- examples/crc32
SKETCHES_REPORTS_PATH: sketches-reports

strategy:
fail-fast: false

matrix:
board:
- fqbn: arduino:samd:mkr1000
type: mkr1000
artifact-name-suffix: arduino-samd-mkr1000
- fqbn: arduino:samd:mkrwifi1010
type: nina
artifact-name-suffix: arduino-samd-mkrwifi1010
- fqbn: arduino:samd:nano_33_iot
type: nina
artifact-name-suffix: arduino-samd-nano_33_iot
- fqbn: arduino:samd:mkrwan1300
type: wan
artifact-name-suffix: arduino-samd-mkrwan1300
- fqbn: arduino:samd:mkrgsm1400
type: gsm
artifact-name-suffix: arduino-samd-mkrgsm1400
- fqbn: arduino:samd:mkrnb1500
type: nb
artifact-name-suffix: arduino-samd-mkrnb1500
- fqbn: arduino:mbed_portenta:envie_m7
type: mbed_portenta
artifact-name-suffix: arduino-mbed_portenta-envie_m7
- fqbn: esp32:esp32:esp32
type: esp32
artifact-name-suffix: esp32-esp32-esp32
- fqbn: arduino:mbed_nano:nanorp2040connect
type: nina
artifact-name-suffix: arduino-mbed_nano-nanorp2040connect
- fqbn: arduino:mbed_nicla:nicla_vision
type: mbed_nicla
artifact-name-suffix: arduino-mbed_nicla-nicla_vision
- fqbn: arduino:mbed_opta:opta
type: mbed_opta
artifact-name-suffix: arduino-mbed_opta-opta
- fqbn: arduino:mbed_giga:giga
type: mbed_giga
artifact-name-suffix: arduino-mbed_giga-giga
- fqbn: arduino:renesas_portenta:portenta_c33
type: renesas_portenta
artifact-name-suffix: arduino-renesas_portenta-portenta_c33
- fqbn: arduino:renesas_uno:unor4wifi
type: renesas_uno
artifact-name-suffix: arduino-renesas_uno-unor4wifi
- fqbn: arduino:esp32:nano_nora
type: arduino_esp32
artifact-name-suffix: arduino-esp32-nano_nora
- fqbn: arduino:mbed_edge:edge_control
type: mbed_edge
artifact-name-suffix: arduino-mbed_edge-edge_control

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install ESP32 platform dependencies
if: matrix.board.type == 'esp32'
run: pip3 install pyserial

- name: Compile examples
uses: arduino/compile-sketches@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
platforms: ${{ matrix.platforms }}
fqbn: ${{ matrix.board.fqbn }}
libraries: |
${{ env.UNIVERSAL_LIBRARIES }}
${{ matrix.libraries }}
sketch-paths: |
${{ env.UNIVERSAL_SKETCH_PATHS }}
${{ matrix.sketch-paths }}
enable-deltas-report: "true"
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}

- name: Save memory usage change report as artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: sketches-report-${{ matrix.board.artifact-name-suffix }}
path: ${{ env.SKETCHES_REPORTS_PATH }}
24 changes: 24 additions & 0 deletions .github/workflows/report-size-deltas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Report Size Deltas

# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/report-size-deltas.yml"
schedule:
# Run at the minimum interval allowed by GitHub Actions.
# Note: GitHub Actions periodically has outages which result in workflow failures.
# In this event, the workflows will start passing again once the service recovers.
- cron: "*/5 * * * *"
workflow_dispatch:
repository_dispatch:

jobs:
report:
runs-on: ubuntu-latest
steps:
- name: Comment size deltas reports to PRs
uses: arduino/report-size-deltas@v1
with:
# Regex matching the names of the workflow artifacts created by the "Compile Examples" workflow
sketches-reports-source: ^sketches-report-.+
16 changes: 16 additions & 0 deletions .github/workflows/spell-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Spell Check

on:
- push
- pull_request

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Spell check
uses: codespell-project/actions-codespell@master
138 changes: 138 additions & 0 deletions .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md
name: Sync Labels

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/sync-labels.ya?ml"
- ".github/label-configuration-files/*.ya?ml"
pull_request:
paths:
- ".github/workflows/sync-labels.ya?ml"
- ".github/label-configuration-files/*.ya?ml"
schedule:
# Run daily at 8 AM UTC to sync with changes to shared label configurations.
- cron: "0 8 * * *"
workflow_dispatch:
repository_dispatch:

env:
CONFIGURATIONS_FOLDER: .github/label-configuration-files
CONFIGURATIONS_ARTIFACT: label-configuration-files

jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download JSON schema for labels configuration file
id: download-schema
uses: carlosperate/download-file-action@v1
with:
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json
location: ${{ runner.temp }}/label-configuration-schema

- name: Install JSON schema validator
run: |
sudo npm install \
--global \
ajv-cli \
ajv-formats
- name: Validate local labels configuration
run: |
# See: https://github.com/ajv-validator/ajv-cli#readme
ajv validate \
--all-errors \
-c ajv-formats \
-s "${{ steps.download-schema.outputs.file-path }}" \
-d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}"
download:
needs: check
runs-on: ubuntu-latest

strategy:
matrix:
filename:
# Filenames of the shared configurations to apply to the repository in addition to the local configuration.
# https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels
- universal.yml

steps:
- name: Download
uses: carlosperate/download-file-action@v1
with:
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }}

- name: Pass configuration files to next job via workflow artifact
uses: actions/upload-artifact@v4
with:
path: |
*.yaml
*.yml
if-no-files-found: error
name: ${{ env.CONFIGURATIONS_ARTIFACT }}

sync:
needs: download
runs-on: ubuntu-latest

steps:
- name: Set environment variables
run: |
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV"
- name: Determine whether to dry run
id: dry-run
if: >
github.event_name == 'pull_request' ||
(
(
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch'
) &&
github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
)
run: |
# Use of this flag in the github-label-sync command will cause it to only check the validity of the
# configuration.
echo "::set-output name=flag::--dry-run"
- name: Checkout repository
uses: actions/checkout@v4

- name: Download configuration files artifact
uses: actions/download-artifact@v4
with:
name: ${{ env.CONFIGURATIONS_ARTIFACT }}
path: ${{ env.CONFIGURATIONS_FOLDER }}

- name: Remove unneeded artifact
uses: geekyeggo/delete-artifact@v5
with:
name: ${{ env.CONFIGURATIONS_ARTIFACT }}

- name: Merge label configuration files
run: |
# Merge all configuration files
shopt -s extglob
cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}"
- name: Install github-label-sync
run: sudo npm install --global github-label-sync

- name: Sync labels
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# See: https://github.com/Financial-Times/github-label-sync
github-label-sync \
--labels "${{ env.MERGED_CONFIGURATION_PATH }}" \
${{ steps.dry-run.outputs.flag }} \
${{ github.repository }}
56 changes: 56 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Unit Tests

on:
pull_request:
paths:
- ".github/workflows/unit-tests.yml"
- 'extras/test/**'
- 'src/**'

push:
paths:
- ".github/workflows/unit-tests.yml"
- 'extras/test/**'
- 'src/**'

jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest

env:
COVERAGE_DATA_PATH: extras/coverage-data/coverage.info

steps:
- name: Checkout
uses: actions/checkout@v4

- uses: arduino/cpp-test-action@main
with:
runtime-paths: |
- extras/test/build/bin/testArduinoCloudUtils
coverage-exclude-paths: |
- '*/extras/test/*'
- '/usr/*'
coverage-data-path: ${{ env.COVERAGE_DATA_PATH }}

# A token is used to avoid intermittent spurious job failures caused by rate limiting.
- name: Set up Codecov upload token
run: |
if [[ "${{ github.repository }}" == "arduino-libraries/ArduinoIoTCloud" ]]; then
# In order to avoid uploads of data from forks, only use the token for runs in the parent repo.
# Token is intentionally exposed.
# See: https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954
CODECOV_TOKEN="47827969-3fda-4ba1-9506-e8d0834ed88c"
else
# codecov/codecov-action does unauthenticated upload if empty string is passed via the `token` input.
CODECOV_TOKEN=""
fi
echo "CODECOV_TOKEN=$CODECOV_TOKEN" >> "$GITHUB_ENV"
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v3
with:
file: "${{ env.COVERAGE_DATA_PATH }}"
fail_ci_if_error: true
token: ${{ env.CODECOV_TOKEN }}
Loading

0 comments on commit c4dee69

Please sign in to comment.