Skip to content

Commit

Permalink
GitHub workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminJo committed Mar 30, 2020
1 parent a8d9187 commit dcdd975
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 148 deletions.
116 changes: 21 additions & 95 deletions .github/workflows/LibraryBuild.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
# Before being able to push to my .github\workflows directories,
# I had to create a new personal token with workflow enabled at https://github.com/settings/tokens
# LibraryBuild.yml
# Github workflow script to test compile all examples of an Arduino library repository.
#
# Copyright (C) 2020 Armin Joachimsmeyer
# https://github.com/ArminJo/Github-Actions

# This is the name of the workflow, visible on GitHub UI.
name: build
on: [push]
name: LibraryBuild
on: [push, pull_request] # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request

jobs:
build:
name: ${{ matrix.arduino-boards-fqbn }} - test compiling examples

runs-on: ubuntu-latest # I picked Ubuntu to use shell scripts.

env:
# Space separated list without double quotes around the list.
# If you need a library with a space in its name, like Adafruit NeoPixel or Adafruit INA219, you must use double quotes
# around the name and have at least 2 entries, where the first must be without double quotes! You may use Servo as dummy entry.
REQUIRED_LIBRARIES:

# Output colors
RED: '\033[0;31m'
GREEN: '\033[0;32m'
YELLOW: '\033[1;33m'
BLUE: '\033[0;34m'

strategy:
matrix:
# The matrix will produce one job for each configuration parameter of type `arduino-boards-fqbn`
Expand All @@ -32,7 +23,8 @@ jobs:
# arduino:sam:arduino_due_x, arduino:samd:arduino_zero_native"
# ATTinyCore:avr:attinyx5:chip=85,clock=1internal, digistump:avr:digispark-tiny, digistump:avr:digispark-pro
# STM32:stm32:GenF1:pnum=BLUEPILL_F103C8
#esp8266:esp8266:huzzah:eesz=4M3M,xtal=80, esp32:esp32:featheresp32:FlashFreq=80
# esp8266:esp8266:huzzah:eesz=4M3M,xtal=80, esp32:esp32:featheresp32:FlashFreq=80
# You may add a suffix behind the fqbn with "|" to specify one board for e.g. different compile options like arduino:avr:uno|trace
#############################################################################################################
arduino-boards-fqbn:
- arduino:avr:uno
Expand All @@ -43,101 +35,35 @@ jobs:
- ATTinyCore:avr:attinyx5:chip=85,clock=1internal

# Choose the right platform for the boards we want to test. (maybe in the future Arduino will automatically do this for you)
# This works like this: when the fqbn is "arduino:avr:uno" the variable `platform` is set to "arduino:avr".
# Just take the first 2 token of the fqbn - this cannot be automatically done by GitHub workflow :-(
# With examples-exclude you may exclude specific examples for a board. Use a comma separated list.
#############################################################################################################
include:
- arduino-boards-fqbn: arduino:avr:uno
platform: arduino:avr

- arduino-boards-fqbn: arduino:avr:leonardo
platform: arduino:avr

- arduino-boards-fqbn: arduino:avr:mega
platform: arduino:avr

- arduino-boards-fqbn: digistump:avr:digispark-tiny1 # ATtiny85 board @1 MHz
platform: digistump:avr
platform-url: http://digistump.com/package_digistump_index.json
# examples-build-properties / aka setting compiler.cpp.extra_flags does not work for digistump:avr platform
examples-exclude: EasyButtonExample # Space separated list of (unique substrings of) example names to exclude in build
examples-exclude: EasyButtonExample # Comma separated list of (unique substrings of) example names to exclude in build

- arduino-boards-fqbn: digistump:avr:digispark-pro
platform: digistump:avr
platform-url: http://digistump.com/package_digistump_index.json

- arduino-boards-fqbn: ATTinyCore:avr:attinyx5:chip=85,clock=1internal
platform: ATTinyCore:avr
platform-url: http://drazzy.com/package_drazzy.com_index.json
examples-build-properties:
EasyButtonExample:
-DTX_PIN=PB0

# Do not cancel all jobs / architectures if one job fails
fail-fast: false

# This is the list of steps this job will run.
steps:

# First of all, we clone the repo using the `checkout` action.
- name: Checkout
uses: actions/checkout@master

# We use the `arduino/setup-arduino-cli` action to install and
# configure the Arduino CLI on the system.
- name: Setup Arduino CLI
uses: arduino/setup-arduino-cli@v1.0.0

- name: Link this repository as Arduino library
run: |
mkdir -p $HOME/Arduino/libraries
ln -s $PWD $HOME/Arduino/libraries/.
- name: Install platform from build matrix
run: |
arduino-cli core update-index
if [ "${{ matrix.platform }}" == "" ]; then echo -e ""$RED"ERROR: platform missing for board ${{ matrix.arduino-boards-fqbn }}. Check your matrix.includes entries"; exit 1; fi
if [[ ${{ matrix.platform }} != *"arduino"* && ! -f ./arduino-cli.yaml ]]; then echo -e ""$RED"Non Arduino platform ${{ matrix.platform }} requested, but file arduino-cli.yaml is missing."; exit 1; fi
arduino-cli core install ${{ matrix.platform }} # for each job / board one platform is installed
arduino-cli board listall
if [ ${{ matrix.platform }} == "esp32:esp32" ]; then pip install pyserial; fi
- name: List installed boards with their FQBN
run: |
arduino-cli board listall
# ls -l $HOME/.arduino15/packages/ # I see only arduino and one of the Attiny cores but not all 3 together
# echo -e HOME=\"$HOME\" # /home/runner
# echo PWD=$PWD # /home/runner/work/Github-Actions-Test/Github-Actions-Test
# which arduino-cli # /opt/hostedtoolcache/arduino-cli/0.9.0/x64/arduino-cli
- name: Install libraries
run: if [[ "$REQUIRED_LIBRARIES" != "" ]]; then arduino-cli lib install ${{ env.REQUIRED_LIBRARIES }}; fi

# Finally, we compile the sketch, using the FQBN that was set in the build matrix.
- name: Compile all examples
env:
BUILD_PROPERTIES: ${{ toJson(matrix.examples-build-properties) }}
run: |
BUILD_PROPERTIES=${BUILD_PROPERTIES#\{} # remove "{"
# if matrix.examples-build-properties are specified, create an associative shell array
if [[ $BUILD_PROPERTIES != "null" ]]; then declare -A PROP_MAP="( $(echo $BUILD_PROPERTIES | sed -E 's/"(\w*)": *([^,}]*)[,}]/\[\1\]=\2/g' ) )"; fi
echo -e "Compiling examples for board ${{ matrix.arduino-boards-fqbn }} \n"
EXAMPLES=($(find . -name "*.ino"))
for example in "${EXAMPLES[@]}"; do # Loop over all example directories
EXAMPLE_NAME=$(basename $(dirname $example))
if [[ "${{ matrix.examples-exclude }}" == *"$EXAMPLE_NAME"* ]]; then
echo -e "Skipping $EXAMPLE_NAME \xe2\x9e\x9e" # Right arrow
else
# check if there is an entry in the associative array and create a compile parameter
echo -n "Compiling $EXAMPLE_NAME "
if [[ "${PROP_MAP[$EXAMPLE_NAME]}" != "" ]]; then echo -n "with ${PROP_MAP[$EXAMPLE_NAME]} "; fi
build_stdout=$(arduino-cli compile --verbose --warnings all --fqbn ${{ matrix.arduino-boards-fqbn }} --build-properties compiler.cpp.extra_flags="${PROP_MAP[$EXAMPLE_NAME]}" $(dirname $example) 2>&1);
if [ $? -ne 0 ]; then
echo -e ""$RED"\xe2\x9c\x96" # If ok output a green checkmark else a red X and the command output.
exit_code=1
echo -e "$build_stdout \n"
else
echo -e ""$GREEN"\xe2\x9c\x93"
fi
fi
done
exit $exit_code
shell: bash {0} # Needed to avoid an exit at first error

uses: ArminJo/arduino-test-compile@master
with:
arduino-board-fqbn: ${{ matrix.arduino-boards-fqbn }}
platform-url: ${{ matrix.platform-url }}
examples-exclude: ${{ matrix.examples-exclude }}
examples-build-properties: ${{ toJson(matrix.examples-build-properties) }}

29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Installation instructions](https://www.ardu-badge.com/badge/EasyButtonAtInt01.svg?)](https://www.ardu-badge.com/EasyButtonAtInt01)
[![Commits since latest](https://img.shields.io/github/commits-since/ArminJo/EasyButtonAtInt01/latest)](https://github.com/ArminJo/EasyButtonAtInt01/commits/master)
[![Build Status](https://github.com/ArminJo/EasyButtonAtInt01/workflows/build/badge.svg)](https://github.com/ArminJo/EasyButtonAtInt01/actions)
[![Build Status](https://github.com/ArminJo/EasyButtonAtInt01/workflows/LibraryBuild/badge.svg)](https://github.com/ArminJo/EasyButtonAtInt01/actions)
[![Hit Counter](https://hitcounter.pythonanywhere.com/count/tag.svg?url=https%3A%2F%2Fgithub.com%2FArminJo%2FEasyButtonAtInt01)](https://github.com/brentvollebregt/hit-counter)

Arduino library for handling push buttons just connected between ground and INT0 and / or INT1 pin.<br/>
Expand Down
7 changes: 0 additions & 7 deletions arduino-cli.yaml

This file was deleted.

1 change: 0 additions & 1 deletion examples/EasyButtonExample/.ATtiny85_1MHz.test.skip

This file was deleted.

1 change: 0 additions & 1 deletion examples/EasyButtonExample/.Digispark_1MHz.test.skip

This file was deleted.

8 changes: 4 additions & 4 deletions examples/EasyButtonExample/ATtinyUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

#include "ATtinyUtils.h"

#include <avr/boot.h> // needed for boot_signature_byte_get()
#include <avr/power.h> // needed for clock_prescale_set()
#include <avr/sleep.h> // needed for isBODSFlagExistent()
#include <avr/boot.h> // required for boot_signature_byte_get()
#include <avr/power.h> // required for clock_prescale_set()
#include <avr/sleep.h> // required for isBODSFlagExistent()
#include "digitalWriteFast.h"

// since we have not included Arduino.h
Expand Down Expand Up @@ -160,7 +160,7 @@ void changeDigisparkClock() {
/*
* Code to reset Digispark OCCAL tweak
*/
#define SIGRD 5 // needed for boot_signature_byte_get()
#define SIGRD 5 // required for boot_signature_byte_get()
uint8_t tStoredOSCCAL = boot_signature_byte_get(1);
if (OSCCAL != tStoredOSCCAL) {
#ifdef DEBUG
Expand Down
2 changes: 1 addition & 1 deletion examples/EasyButtonExample/EasyButtonExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void loop() {
/*
* Button 1
*/
Button1AtPin3.updateButtonState(); // this is ONLY needed if we expect a regular button press which is shorter than BUTTON_DEBOUNCING_MILLIS!
Button1AtPin3.updateButtonState(); // this is ONLY required if we expect a regular button press which is shorter than BUTTON_DEBOUNCING_MILLIS!
if (Button1AtPin3.ButtonStateHasJustChanged) {
Button1AtPin3.ButtonStateHasJustChanged = false; // Acknowledge button state change flag

Expand Down
2 changes: 1 addition & 1 deletion src/EasyButtonAtInt01.cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ void EasyButton::handleINT01Interrupts() {
if (ButtonPressCallback != NULL) {
/*
* Call callback function.
* interrupts() is needed if callback function needs more time to allow millis() to proceed.
* interrupts() is required if callback function needs more time to allow millis() to proceed.
* Otherwise we may see bouncing instead of button release followed by spike instead of button press
*/
interrupts();
Expand Down
16 changes: 8 additions & 8 deletions src/digitalWriteFast.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,18 +314,18 @@
#elif defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)
# if defined(ARDUINO_AVR_DIGISPARKPRO)
/// Strange enumeration of pins on Digispark board and core library
#define __digitalPinToPortReg(P) (((P) >= 0 && (P) <= 4) ? &PORTB : &PORTA)
#define __digitalPinToDDRReg(P) (((P) >= 0 && (P) <= 4) ? &DDRB : &DDRA)
#define __digitalPinToPINReg(P) (((P) >= 0 && (P) <= 4) ? &PINB : &PINA)
#define __digitalPinToBit(P) (((P) >= 0 && (P) <= 2) ? (P) : (((P) == 3) ? 6 : (((P) == 4) ? 3 : (((P) == 5) ? 7 : (P) - 6 ))))
#define __digitalPinToPortReg(P) (((P) <= 4) ? &PORTB : &PORTA)
#define __digitalPinToDDRReg(P) (((P) <= 4) ? &DDRB : &DDRA)
#define __digitalPinToPINReg(P) (((P) <= 4) ? &PINB : &PINA)
#define __digitalPinToBit(P) (((P) <= 2) ? (P) : (((P) == 3) ? 6 : (((P) == 4) ? 3 : (((P) == 5) ? 7 : (P) - 6 ))))

# else
// ATtinyX4: PORTA for 0 to 7, PORTB for 8 to 11
// ATtinyX7: PORTA for 0 to 7, PORTB for 8 to 15
#define __digitalPinToPortReg(P) (((P) >= 0 && (P) <= 7) ? &PORTA : &PORTB)
#define __digitalPinToDDRReg(P) (((P) >= 0 && (P) <= 7) ? &DDRA : &DDRB)
#define __digitalPinToPINReg(P) (((P) >= 0 && (P) <= 7) ? &PINA : &PINB)
#define __digitalPinToBit(P) (((P) >= 0 && (P) <= 7) ? (P) : (P) - 8 )
#define __digitalPinToPortReg(P) (((P) <= 7) ? &PORTA : &PORTB)
#define __digitalPinToDDRReg(P) (((P) <= 7) ? &DDRA : &DDRB)
#define __digitalPinToPINReg(P) (((P) <= 7) ? &PINA : &PINB)
#define __digitalPinToBit(P) (((P) <= 7) ? (P) : (P) - 8 )
# endif

// --- Other ---
Expand Down

0 comments on commit dcdd975

Please sign in to comment.