Skip to content

Commit

Permalink
use reusable workflows in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jan 7, 2023
1 parent d3f060a commit eaa0541
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 522 deletions.
105 changes: 29 additions & 76 deletions .github/workflows/build_arduino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,41 @@ on:
- ".github/workflows/build_arduino.yml"
- "examples/**"

env:
# convenient variable used multiple times
SKETCHES_REPORTS: sketches-reports

jobs:
check_formatting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
# Ubuntu 20.04.4 LTS reunners ship with clang-tools v12
# - name: Install clang-tools
# uses: KyleMayes/install-llvm-action@v1
# with:
# version: 12
- name: Install linter python package
run: python3 -m pip install cpp-linter
- name: run linter as a python package
id: linter
run: |
cpp-linter \
--version=12 \
--style=file \
--tidy-checks='-*' \
--files-changed-only='False' \
--extensions=ino
- name: Linter checks failed?
if: steps.linter.outputs.checks-failed > 0
run: exit 1
uses: nRF24/.github/.github/workflows/cpp_lint.yaml@reusable-workflow
with:
ignore: '!examples|'
extensions: ino

build:
needs: check_formatting
runs-on: ubuntu-latest

uses: nRF24/.github/.github/workflows/build_arduino.yaml@reusable-workflow
with:
sketch-paths: |
- examples/helloworld_rx
- examples/helloworld_rx_advanced
- examples/helloworld_tx_advanced
- examples/helloworld_tx
- examples/Network_Priority_RX
- examples/Network_Priority_TX
# - examples/Network_Ping
# - examples/Network_Ping_Sleep
libraries: |
- source-url: https://github.com/nRF24/RF24.git
- source-path: ./
# - source-url: https://github.com/TMRh20/nrf_to_nrf.git
# version: v1.0
fqbn: ${{ matrix.fqbn }}
enable-deltas-report: ${{ matrix.enable-deltas-report }}
platforms: |
- name: arduino:avr
- name: arduino:megaavr
- name: arduino:samd
- name: arduino:mbed
# - name: arduino:sam
strategy:
fail-fast: false

matrix:
fqbn:
- "arduino:avr:yun"
Expand Down Expand Up @@ -103,50 +98,8 @@ jobs:
- fqbn: arduino:samd:mkrzero
enable-deltas-report: true

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Compile examples
uses: arduino/compile-sketches@main
with:
sketch-paths: |
- examples/helloworld_rx
- examples/helloworld_rx_advanced
- examples/helloworld_tx_advanced
- examples/helloworld_tx
- examples/Network_Priority_RX
- examples/Network_Priority_TX
# - examples/Network_Ping
# - examples/Network_Ping_Sleep
libraries: |
- name: RF24
- source-path: ./
# - source-url: https://github.com/TMRh20/nrf_to_nrf.git
# version: v1.0
fqbn: ${{ matrix.fqbn }}
enable-deltas-report: ${{ matrix.enable-deltas-report }}
sketches-report-path: ${{ env.SKETCHES_REPORTS }}

# This step is needed to pass the size data to the report job
- name: Upload sketches report to workflow artifact
if: ${{ matrix.enable-deltas-report }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.SKETCHES_REPORTS }}
path: ${{ env.SKETCHES_REPORTS }}

# When using a matrix to compile for multiple boards, it's necessary to use a separate job for the deltas report
report:
needs: [build]
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Download sketches reports artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.SKETCHES_REPORTS }}
path: ${{ env.SKETCHES_REPORTS }}

- uses: arduino/report-size-deltas@v1
with:
sketches-reports-source: ${{ env.SKETCHES_REPORTS }}
uses: nRF24/.github/.github/workflows/arduino_size_deltas.yaml@reusable-workflow
61 changes: 61 additions & 0 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Linux build

on:
pull_request:
types: [opened, reopened]
paths:
- "*.h"
- "*.cpp"
- "CMakeLists.txt"
- "cmake/**"
- "library.properties" # CMake gets lib info from here
- "examples_RPi/*"
- "!**Makefile" # old build system is not tested in this workflow
- "**pyRF24Network/setup.py"
- "**pyRF24Network/*.cpp"
- ".github/workflows/linux_build.yml"
push:
paths:
- "*.h"
- "*.cpp"
- "CMakeLists.txt"
- "cmake/**"
- "library.properties" # CMake gets lib info from here
- "examples_RPi/**"
- "!**Makefile" # old build system is not tested in this workflow
- "**pyRF24Network/setup.py"
- "**pyRF24Network/*.cpp"
- ".github/workflows/linux_build.yml"
release:
types: [created]

jobs:
check_formatting:
uses: nRF24/.github/.github/workflows/cpp_lint.yaml@reusable-workflow
with:
ignore: 'examples|examples_pico'

using_cmake:
needs: check_formatting
uses: nRF24/.github/.github/workflows/build_linux_cmake.yaml@reusable-workflow
with:
rf24network-ref: ${{ github.sha }}
compiler: ${{ matrix.toolchain.compiler }}
usr-dir: ${{ matrix.toolchain.usr_dir }}
examples-path: examples_RPi
deploy-release: ${{ github.event_name == 'release' && (matrix.toolchain.compiler == 'armhf' || matrix.toolchain.compiler == 'arm64') }}
py-wrapper-path: RPi/pyRF24Network
strategy:
fail-fast: false
matrix:
toolchain:
- compiler: "armhf"
usr_dir: "arm-linux-gnueabihf"
- compiler: "arm64"
usr_dir: "aarch64-linux-gnu"
# - compiler: "x86_64"
# usr_dir: "x86_64-linux-gnux32"
# - compiler: "i686"
# usr_dir: "i686-linux-gnu"
- compiler: "default" # github runner is hosted on a "amd64"
usr_dir: "local"
110 changes: 9 additions & 101 deletions .github/workflows/build_platformIO.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,83 +19,22 @@ on:

jobs:
validate_lib_json:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: get latest release version number
id: latest_ver
run: echo "release=$(awk -F "=" '/version/ {print $2}' library.properties)" >> $GITHUB_OUTPUT

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: package lib
run: pio package pack -o PlatformIO-RF24Network-${{ steps.latest_ver.outputs.release }}.tar.gz

- name: Save artifact
uses: actions/upload-artifact@v3
with:
name: "PIO_pkg_RF24Network"
path: PlatformIO*.tar.gz

- name: Upload Release assets
if: github.event_name == 'release'
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "PlatformIO*.tar.gz"

- name: upload package to PlatformIO Registry
if: github.event_name == 'release' && github.event_type != 'edited'
# PIO lib packages cannot be re-published under the same tag
env:
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }}
run: pio package publish --owner nrf24 --non-interactive
uses: nRF24/.github/.github/workflows/validate_deploy_platformio.yaml@reusable-workflow
secrets: inherit

check_formatting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
# Ubuntu 20.04.4 LTS reunners ship with clang-tools v12
# - name: Install clang-tools
# uses: KyleMayes/install-llvm-action@v1
# with:
# version: 12
- name: Install linter python package
run: python3 -m pip install cpp-linter
- name: run linter as a python package
id: linter
run: |
cpp-linter \
--version=12 \
--style=file \
--tidy-checks='-*' \
--files-changed-only='False' \
--extensions=ino
- name: Linter checks failed?
if: steps.linter.outputs.checks-failed > 0
run: exit 1
uses: nRF24/.github/.github/workflows/cpp_lint.yaml@reusable-workflow
with:
extensions: ino

build:
needs: [check_formatting, validate_lib_json]
runs-on: ubuntu-latest

uses: nRF24/.github/.github/workflows/build_platformio.yaml@reusable-workflow
with:
example-path: ${{ matrix.example }}
board-id: ${{ matrix.board }}
strategy:
fail-fast: false

matrix:
example:
- "examples/helloworld_rx/helloworld_rx.ino"
Expand All @@ -111,34 +50,3 @@ jobs:
- "teensy40"
- "teensy41"
- "teensylc"

steps:
- uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
# "dependencies" field in JSON should automatically install RF24.
# Because we run this CI test against the local repo, the JSON seems neglected
- name: Install library dependencies
run: pio lib -g install nrf24/RF24
- name: Run PlatformIO
run: pio ci --lib="." --board=${{ matrix.board }}
env:
PLATFORMIO_CI_SRC: ${{ matrix.example }}
Loading

0 comments on commit eaa0541

Please sign in to comment.