Skip to content
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
98 changes: 98 additions & 0 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Linux

on: [push, pull_request]

env:
# build Configuration, i.e. Debug, Release, etc.
PRODUCT_BUILD_TYPE: Release

# build Configuration, i.e. Debug, Release, etc.
Configuration: Release

# Required for Github Action. Unit test TestProcess.testKillAndTerminate fails to start /bin/nano with the following error: "Error opening terminal: unknown."
TERM: xterm

jobs:
build:
# For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: ubuntu-latest

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

- name: Configure GIT
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: |
git config --local core.autocrlf true
git config --local advice.detachedHead false
git submodule update --init --recursive

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified

- name: Create new environment variables
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: |
python -c "import os; print('GIT_REPOSITORY=' + os.path.split(os.getenv('GITHUB_REPOSITORY'))[1]);" >> $GITHUB_ENV
python -c "import os; print('GIT_BRANCH=' + os.path.split(os.getenv('GITHUB_REF'))[1]);" >> $GITHUB_ENV
echo GITHUB_WORKFLOW=$GITHUB_WORKFLOW>> $GITHUB_ENV

- name: List environment variables for debugging
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: |
env

- name: Configure user profile and directories
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: |
mkdir ~/Documents #required for TestUser.testFoldersExisting() because /home/travis/Documents does not exists!
mkdir ~/Desktop #required for TestUser.testFoldersExisting() because /home/travis/Desktop does not exists!

- name: Install yamlpath
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: ./ci/github/install_yamlpath.sh

- name: Install pyserial
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: ./ci/github/install_pyserial.sh

- name: Install Arduino CLI
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: ./ci/github/install_arduinocli.sh

- name: Install Arduino cores
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: ./ci/github/install_arduino_cores.sh

- name: Install Arduino library dependencies
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: ./ci/github/arduino_install_libraries.sh

- name: Install this arduino library
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: ./ci/github/install_this.sh

- name: Build Arduino sketch - rtttl_blocking
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: python ci/generic/arduino_build_sketch.py rtttl_blocking

- name: Build Arduino sketch - rtttl_demo
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: bash
run: python ci/generic/arduino_build_sketch.py rtttl_demo
90 changes: 90 additions & 0 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Windows

on: [push, pull_request]

env:
PlatformToolset: v142

# build platform, i.e. x86, x64, Any CPU. This setting is optional.
Platform: Win32

# build Configuration, i.e. Debug, Release, etc.
Configuration: Release

jobs:
build:
# For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: windows-latest

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

- name: Configure GIT
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: |
git config --local core.autocrlf true
git config --local advice.detachedHead false
git submodule update --init --recursive

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified

- name: Create new environment variables
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: |
python -c "import os; print('GIT_REPOSITORY=' + os.path.split(os.getenv('GITHUB_REPOSITORY'))[1]);" >> %GITHUB_ENV%
python -c "import os; print('GIT_BRANCH=' + os.path.split(os.getenv('GITHUB_REF'))[1]);" >> %GITHUB_ENV%
echo GITHUB_WORKFLOW=%GITHUB_WORKFLOW%>> %GITHUB_ENV%

- name: List environment variables for debugging
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: |
set

- name: Install yamlpath
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: call ci\github\install_yamlpath.bat

- name: Install pyserial
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: call ci\github\install_pyserial.bat

- name: Install Arduino CLI
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: call ci\github\install_arduinocli.bat

- name: Install Arduino cores
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: call ci\github\install_arduino_cores.bat

- name: Install Arduino library dependencies
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: call ci\github\arduino_install_libraries.bat

- name: Install this arduino library
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: call ci\github\install_this.bat

- name: Build Arduino sketch - rtttl_blocking
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: python ci\generic\arduino_build_sketch.py rtttl_blocking

- name: Build Arduino sketch - rtttl_demo
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: python ci\generic\arduino_build_sketch.py rtttl_demo
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Changes for 1.4.0:

* Fixed issue #13 - ESP32 Core has changed from 2.x to 3.0.
* Fixed issue #20 - Deprecate AppVeyor-based compilation pipeline.
* Fixed issue #21 - Implement Github Actions compilation pipeline.

Changes for 1.3.0:

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Build:

| Service | Build | Tests |
|----|-------|-------|
| Windows Server 2019 | [![Build on Windows](https://github.com/end2endzone/NonBlockingRtttl/actions/workflows/build_windows.yml/badge.svg)](https://github.com/end2endzone/NonBlockingRtttl/actions/workflows/build_windows.yml) | N/A |
| Ubuntu 22.04 | [![Build on Linux](https://github.com/end2endzone/NonBlockingRtttl/actions/workflows/build_linux.yml/badge.svg)](https://github.com/end2endzone/NonBlockingRtttl/actions/workflows/build_linux.yml) | N/A |



Expand Down
4 changes: 4 additions & 0 deletions ci/arduinocli-core-esp32.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
board_manager:
additional_urls:
- https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
- https://dl.espressif.com/dl/package_esp32_index.json
3 changes: 3 additions & 0 deletions ci/arduinocli-core-esp8266.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
board_manager:
additional_urls:
- http://arduino.esp8266.com/stable/package_esp8266com_index.json
90 changes: 90 additions & 0 deletions ci/generic/arduino_build_sketch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import os
import sys
import subprocess

import functools
print = functools.partial(print, flush=True)

# Boards to compile for
BOARDS = {
"atmega328": "arduino:avr:nano:cpu=atmega328",
"nodemcuv2": "esp8266:esp8266:nodemcuv2",
"esp32": "esp32:esp32:esp32",
"esp32wroverkit": "esp32:esp32:esp32wroverkit"
}

def find_product_source_dir():
env_dir = os.environ.get("PRODUCT_SOURCE_DIR")
if env_dir:
return env_dir
script_dir = os.path.dirname(os.path.abspath(__file__))
return os.path.abspath(os.path.join(script_dir, "..", ".."))

def check_arduino_cli():
cli_path = os.environ.get("ARDUINO_CLI_INSTALL_DIR", "")
if cli_path:
os.environ["PATH"] += os.pathsep + cli_path
try:
subprocess.run(["arduino-cli", "version"],
stdout=sys.stdout,
check=True
)
except FileNotFoundError:
print("arduino-cli not found in PATH.")
sys.exit(1)

def is_board_compatible(board, boards_file):
try:
with open(boards_file, "r") as f:
lines = [line.strip() for line in f.readlines()]
return "all" in lines or board in lines
except FileNotFoundError:
print(f"No boards.txt found at {boards_file}")
return False

def compile_sketch(sketch_name):
product_dir_path = find_product_source_dir()
sketch_dir_path = os.path.join(product_dir_path, "examples", sketch_name)
ino_file_path = os.path.join(sketch_dir_path, f"{sketch_name}.ino")
boards_file_path = os.path.join(sketch_dir_path, "boards.txt")
ino_file_name = os.path.basename(ino_file_path)

if not os.path.isfile(ino_file_path):
print(f"Sketch file not found: {ino_file_path}")
sys.exit(1)

if not os.path.isfile(boards_file_path):
print(f"No boards.txt found at {boards_file_path}")
sys.exit(1)

print(f"Found boards.txt at {boards_file_path}\n")

for board, fqbn in BOARDS.items():
print("=" * 100)
print(f"Compiling {ino_file_name} for ({board})")
print("=" * 100)

if is_board_compatible(board, boards_file_path):
try:
subprocess.run(
["arduino-cli", "compile", "--fqbn", fqbn, ino_file_path],
stdout=sys.stdout,
cwd=sketch_dir_path,
check=True
)
except subprocess.CalledProcessError as e:
print(f"Compilation failed for {board} with error code {e.returncode}")
sys.exit(e.returncode)
else:
print(f"Skipping sketch compilation for {board} which is incompatible according to it's boards.txt file.")
print("\n")

if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python compile_sketch.py <sketch_name>")
sys.exit(1)

check_arduino_cli()

sketch_name = sys.argv[1]
compile_sketch(sketch_name)
11 changes: 11 additions & 0 deletions ci/github/arduino_build_sketch.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@echo off

:: Validate GitHub CI's environment
if "%GITHUB_WORKSPACE%"=="" (
echo Please define 'GITHUB_WORKSPACE' environment variable.
exit /B 1
)

:: Call matching script for windows
call "%GITHUB_WORKSPACE%\ci\windows\%~n0.bat" "%~1"
if %errorlevel% neq 0 exit /b %errorlevel%
12 changes: 12 additions & 0 deletions ci/github/arduino_build_sketch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Any commands which fail will cause the shell script to exit immediately
set -e

# Validate GitHub CI environment
if [ "$GITHUB_WORKSPACE" = "" ]; then
echo "Please define 'GITHUB_WORKSPACE' environment variable.";
exit 1;
fi

# Call matching script for linux
this_filename=`basename "$0"`
$GITHUB_WORKSPACE/ci/linux/$this_filename "$1"
11 changes: 11 additions & 0 deletions ci/github/arduino_install_libraries.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@echo off

:: Validate GitHub CI's environment
if "%GITHUB_WORKSPACE%"=="" (
echo Please define 'GITHUB_WORKSPACE' environment variable.
exit /B 1
)

:: Call matching script for windows
call "%GITHUB_WORKSPACE%\ci\windows\%~n0.bat" "%~1"
if %errorlevel% neq 0 exit /b %errorlevel%
12 changes: 12 additions & 0 deletions ci/github/arduino_install_libraries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Any commands which fail will cause the shell script to exit immediately
set -e

# Validate GitHub CI environment
if [ "$GITHUB_WORKSPACE" = "" ]; then
echo "Please define 'GITHUB_WORKSPACE' environment variable.";
exit 1;
fi

# Call matching script for linux
this_filename=`basename "$0"`
$GITHUB_WORKSPACE/ci/linux/$this_filename "$1"
11 changes: 11 additions & 0 deletions ci/github/install_arduino_cores.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@echo off

:: Validate GitHub CI's environment
if "%GITHUB_WORKSPACE%"=="" (
echo Please define 'GITHUB_WORKSPACE' environment variable.
exit /B 1
)

:: Call matching script for windows
call "%GITHUB_WORKSPACE%\ci\windows\%~n0.bat"
if %errorlevel% neq 0 exit /b %errorlevel%
12 changes: 12 additions & 0 deletions ci/github/install_arduino_cores.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Any commands which fail will cause the shell script to exit immediately
set -e

# Validate GitHub CI environment
if [ "$GITHUB_WORKSPACE" = "" ]; then
echo "Please define 'GITHUB_WORKSPACE' environment variable.";
exit 1;
fi

# Call matching script for linux
this_filename=`basename "$0"`
$GITHUB_WORKSPACE/ci/linux/$this_filename
15 changes: 15 additions & 0 deletions ci/github/install_arduinocli.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo off

:: Validate GitHub CI's environment
if "%GITHUB_WORKSPACE%"=="" (
echo Please define 'GITHUB_WORKSPACE' environment variable.
exit /B 1
)

:: Call matching script for windows
call "%GITHUB_WORKSPACE%\ci\windows\%~n0.bat"
if %errorlevel% neq 0 exit /b %errorlevel%

:: Remember installation directory
echo Remember ARDUINO_CLI_INSTALL_DIR as %ARDUINO_CLI_INSTALL_DIR% in %GITHUB_ENV%
echo ARDUINO_CLI_INSTALL_DIR=%ARDUINO_CLI_INSTALL_DIR%>> %GITHUB_ENV%
Loading