Skip to content

Commit

Permalink
Merge pull request #1 from bcmi-labs/ci
Browse files Browse the repository at this point in the history
SecureElement: add github workflows
  • Loading branch information
pennam authored Feb 8, 2024
2 parents af347e5 + c1f9c4d commit f7b7fc7
Show file tree
Hide file tree
Showing 7 changed files with 372 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[codespell]
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
ignore-words-list = ,
check-filenames =
check-hidden =
skip = ./.git
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/en/code-security/supply-chain-security/configuration-options-for-dependency-updates#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/en/code-security/supply-chain-security/keeping-your-actions-up-to-date-with-dependabot
- package-ecosystem: github-actions
directory: / # Check the repository's workflows under /.github/workflows/
schedule:
interval: daily
labels:
- "topic: infrastructure"
26 changes: 26 additions & 0 deletions .github/workflows/arduino-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Arduino Lint
on:
push:
pull_request:
# Scheduled trigger checks for breakage caused by new rules added to Arduino Lint
schedule:
# run every Saturday at 3 AM UTC
- cron: "0 3 * * 6"
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:

jobs:
lint:
runs-on: ubuntu-latest

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

- name: Arduino Lint
uses: arduino/arduino-lint-action@v1
with:
official: true
library-manager: update
141 changes: 141 additions & 0 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Compile Examples

on:
pull_request:
paths:
- ".github/workflows/compile-examples.yml"
- "library.properties"
- "examples/**"
- "src/**"
push:
paths:
- ".github/workflows/compile-examples.yml"
- "library.properties"
- "examples/**"
- "src/**"
# Scheduled trigger checks for breakage caused by changes to external resources (libraries, platforms)
schedule:
# run every Saturday at 3 AM UTC
- cron: "0 3 * * 6"
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:

jobs:
build:
name: ${{ matrix.board.fqbn }}
runs-on: ubuntu-latest

env:
SKETCHES_REPORTS_PATH: sketches-reports

strategy:
fail-fast: false

matrix:
board:
- fqbn: "arduino:samd:mkr1000"
platform-name: arduino:samd
- fqbn: "arduino:samd:mkrwifi1010"
platform-name: arduino:samd
- fqbn: "arduino:samd:nano_33_iot"
platform-name: arduino:samd
- fqbn: "arduino:samd:mkrgsm1400"
platform-name: arduino:samd
- fqbn: "arduino:samd:mkrnb1500"
platform-name: arduino:samd
- fqbn: "arduino:mbed_portenta:envie_m7"
platform-name: arduino:mbed_portenta
- fqbn: arduino:mbed_nano:nanorp2040connect
platform-name: arduino:mbed_nano
- fqbn: arduino:mbed_nicla:nicla_vision
platform-name: arduino:mbed_nicla
- fqbn: arduino:mbed_opta:opta
platform-name: arduino:mbed_opta
- fqbn: arduino:mbed_giga:giga
platform-name: arduino:mbed_giga
- fqbn: arduino:renesas_portenta:portenta_c33
platform-name: arduino:renesas_portenta
- fqbn: arduino:renesas_uno:unor4wifi
platform-name: arduino:renesas_uno

include:
- board:
platform-name: arduino:samd
platforms: |
# Install Arduino SAMD Boards via Boards Manager
- name: arduino:samd
libraries: |
- name: ArduinoECCX08
- board:
platform-name: arduino:mbed_portenta
platforms: |
# Install Arduino mbed_portenta Boards via Boards Manager
- name: arduino:mbed_portenta
libraries: |
- name: ArduinoECCX08
- board:
platform-name: arduino:mbed_nano
platforms: |
# Install Arduino mbed_nano Boards via Boards Manager
- name: arduino:mbed_nano
libraries: |
- name: ArduinoECCX08
- board:
platform-name: arduino:mbed_nicla
platforms: |
# Install Arduino mbed_nano Boards via Boards Manager
- name: arduino:mbed_nicla
- board:
platform-name: arduino:mbed_opta
platforms: |
# Install Arduino mbed_opta Boards via Boards Manager
- name: arduino:mbed_opta
libraries: |
- name: ArduinoECCX08
- board:
platform-name: arduino:mbed_giga
platforms: |
# Install Arduino mbed_giga Boards via Boards Manager
- name: arduino:mbed_giga
libraries: |
- name: ArduinoECCX08
- board:
platform-name: arduino:renesas_portenta
platforms: |
# Install Arduino renesas_portenta Boards via Boards Manager
- name: arduino:renesas_portenta
- board:
platform-name: arduino:renesas_uno
platforms: |
# Install Arduino renesas_uno Boards via Boards Manager
- name: arduino:renesas_uno
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install ESP32 platform dependencies
if: matrix.board.platform-name == '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: |
# Install the library from the local path.
- source-path: ./
${{ matrix.libraries }}
enable-deltas-report: true
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}

- name: Save memory usage change report as artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.SKETCHES_REPORTS_PATH }}
if-no-files-found: error
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

on:
push:
paths:
- ".github/workflows/report-size-deltas.ya?ml"
schedule:
- cron: '*/5 * * * *'
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:

jobs:
report:
runs-on: ubuntu-latest

steps:
# See: https://github.com/arduino/actions/blob/master/libraries/report-size-deltas/README.md
- name: Comment size deltas reports to PRs
uses: arduino/report-size-deltas@v1
with:
# The name of the workflow artifact created by the "Compile Examples" workflow
sketches-reports-source: sketches-reports
24 changes: 24 additions & 0 deletions .github/workflows/spell-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Spell Check

on:
pull_request:
push:
schedule:
# Run every Saturday at 3 AM UTC to catch new misspelling detections resulting from dictionary updates.
- cron: "0 3 * * 6"
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch
repository_dispatch:

jobs:
spellcheck:
runs-on: ubuntu-latest

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

# See: https://github.com/codespell-project/actions-codespell/blob/master/README.md
- name: Spell check
uses: codespell-project/actions-codespell@v2
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@v2
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@v2
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@v3
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 "flag=--dry-run" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Remove unneeded artifact
uses: geekyeggo/delete-artifact@v2
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 }}

0 comments on commit f7b7fc7

Please sign in to comment.