Skip to content

[AE-158] Add Github Actions [draft] #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# See: https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#about-the-dependabotyml-file
version: 2

updates:
# Configure check for outdated GitHub Actions actions in workflows.
# See: https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot
- package-ecosystem: github-actions
directory: / # Check the repository's workflows under /.github/workflows/
labels:
- "topic: infrastructure"
schedule:
interval: daily
28 changes: 28 additions & 0 deletions .github/workflows/check-arduino.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check Arduino

# See: https://docs.github.com/en/free-pro-team@latest/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@v3

- name: Arduino Lint
uses: arduino/arduino-lint-action@v1
with:
compliance: specification
library-manager: submit
# Always use this setting for official repositories. Remove for 3rd party projects.
official: true
project-type: library
103 changes: 103 additions & 0 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Source: https://github.com/per1234/.github/blob/main/workflow-templates/compile-examples-private.md
name: Compile Examples

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/compile-examples-private.ya?ml"
- "library.properties"
- "examples/**"
- "src/**"
pull_request:
paths:
- ".github/workflows/compile-examples-private.ya?ml"
- "library.properties"
- "examples/**"
- "src/**"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms).
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

env:
SKETCHES_REPORTS_PATH: sketches-reports
SKETCHES_REPORTS_ARTIFACT_NAME: sketches-reports

jobs:
build:
name: ${{ matrix.board.fqbn }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read

strategy:
fail-fast: false

matrix:
board:
- fqbn: arduino:mbed_portenta:envie_m7
platforms: |
- name: arduino:mbed_portenta
- fqbn: arduino:renesas_portenta:portenta_c33
platforms: |
- name: arduino:renesas_portenta
- fqbn: arduino:mbed_opta:opta
platforms: |
- name: arduino:mbed_opta


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

- name: Compile examples
uses: arduino/compile-sketches@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fqbn: ${{ matrix.board.fqbn }}
platforms: ${{ matrix.board.platforms }}
libraries: |
# Install the library from the local path.
- source-path: ./
- name: Arduino_USBHostMbed5
- source-path: https://github.com/arduino-libraries/Arduino_POSIXStorage
# Additional library dependencies can be listed here.
# See: https://github.com/arduino/compile-sketches#libraries
sketch-paths: |
- examples
enable-deltas-report: true
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}

- name: Save sketches report as workflow artifact
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
path: ${{ env.SKETCHES_REPORTS_PATH }}
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}

report-size-deltas:
needs: build
# Run even if some compilations failed.
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- name: Download sketches reports artifact
id: download-artifact
continue-on-error: true # If compilation failed for all boards then there are no artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
path: ${{ env.SKETCHES_REPORTS_PATH }}

- name: Comment size deltas report to PR
uses: arduino/report-size-deltas@v1
# If actions/download-artifact failed, there are no artifacts to report from.
if: steps.download-artifact.outcome == 'success'
with:
sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}
25 changes: 25 additions & 0 deletions .github/workflows/spell-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Source: https://github.com/per1234/.github/blob/main/workflow-templates/spell-check.md
name: Spell Check

# 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 new misspelling detections resulting from dictionary updates.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
spellcheck:
runs-on: ubuntu-latest
permissions:
contents: read

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

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

# See: https://docs.github.com/actions/using-workflows/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
permissions:
contents: read

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

- 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
permissions: {}

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
permissions:
contents: read
issues: write

steps:
- name: Set environment variables
run: |
# See: https://docs.github.com/actions/using-workflows/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@v3

- 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 }}
7 changes: 7 additions & 0 deletions examples/tests/test_qspi_usb_sd/test_c33
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
<<<<<<< Updated upstream
arduino-cli compile -b arduino:renesas_portenta:portenta_c33 --library "../../Arduino_POSIXStorage" --library "/home/c.dragomir/ArduinoWorkspace/Arduino_UnifiedStorage"
=======
arduino-cli compile -b arduino:renesas_portenta:portenta_c33 --library "/home/c.dragomir/ArduinoWorkspace/Repos/POSIXStorage" --library "/home/c.dragomir/ArduinoWorkspace/Repos/Arduino_UnifiedStorage"
>>>>>>> Stashed changes
arduino-cli upload -b arduino:renesas_portenta:portenta_c33
8 changes: 8 additions & 0 deletions examples/tests/test_qspi_usb_sd/test_h7
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
<<<<<<< Updated upstream
arduino-cli compile -b arduino:mbed_portenta:envie_m7 --library "../../Arduino_POSIXStorage" --library "/home/c.dragomir/ArduinoWorkspace/Arduino_UnifiedStorage"
arduino-cli upload -b arduino:mbed_portenta:envie_m7
=======
arduino-cli compile -b arduino:mbed_portenta:envie_m7 --library "../../../POSIXStorage" --library "../../../Arduino_UnifiedStorage"

>>>>>>> Stashed changes
Loading