Skip to content
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

GitHub actions ci #174

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e18d935
basic ci build
pbronneberg Apr 26, 2021
e2c8972
Simple dependabot to keep actions up2date
pbronneberg Apr 26, 2021
448a92d
Remove redundant comments
pbronneberg Apr 26, 2021
807b979
Fix target branch name to master
pbronneberg Apr 26, 2021
d452e7d
build as super-user
pbronneberg Apr 26, 2021
286997d
Merge branch 'github-actions-ci' of https://github.com/pbronneberg/Op…
pbronneberg Apr 26, 2021
29f4eee
remove silent flag
pbronneberg Apr 26, 2021
3689fd5
Remove explicit SH from build
pbronneberg Apr 26, 2021
d0a2bde
added demo build
pbronneberg Apr 26, 2021
4d86651
use cross-compiler to compile for arm
pbronneberg Apr 27, 2021
421c878
configurable compiler for cross-compilation
pbronneberg Apr 27, 2021
769851b
do not continue build on compiler error
pbronneberg Apr 27, 2021
5496575
g++ as default compiler
pbronneberg Apr 27, 2021
04ed9a7
Check compiler exists or fail
pbronneberg Apr 27, 2021
1aeeb89
Configure cross compilers
pbronneberg Apr 27, 2021
83c1544
fix copy-paste issue
pbronneberg Apr 27, 2021
947d048
fix typo in compiler arguments
pbronneberg Apr 27, 2021
165e13e
missing brace
pbronneberg Apr 27, 2021
bddecf1
Fix getopts in build
pbronneberg Apr 27, 2021
0a392c9
small getopts improvement
pbronneberg Apr 27, 2021
fe11824
explicit quotes to allow for multiple arguments
pbronneberg Apr 27, 2021
4ae6a7c
change order of build arguments
pbronneberg Apr 27, 2021
dff04e8
fix optional arguments
pbronneberg Apr 27, 2021
a788cb5
split prereq install
pbronneberg Apr 27, 2021
0805135
Make cross-compilation optional
pbronneberg Apr 27, 2021
56387bd
remove compiler version check
pbronneberg Apr 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
# Here we tell GitHub that the jobs must be determined
# dynamically depending on a matrix configuration.
strategy:
fail-fast: false
matrix:
target: ["ospi", "osbo", "demo"]
include:
# For cross compilation to ARM use the following example
# - target: "ospi"
# compiler: "arm-linux-gnueabihf-g++"
# compiler-args: "-march=armv6 -mfpu=vfp -mfloat-abi=hard"
# build-packages: "g++-arm-linux-gnueabihf gdb-multiarch"
- target: "ospi"
compiler: "g++"
compiler-args: ""
build-packages: ""
- target: "osbo"
compiler: "g++"
compiler-args: ""
build-packages: ""
- target: "demo"
compiler: "g++"
compiler-args: ""
build-packages: ""

# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Install preconditions
run: |
sudo apt-get update
sudo apt-get install -y build-essential libmosquitto-dev ${{ matrix.build-packages }}
# Finally, we compile towards the selected target
- name: Compile OpenSprinkler
run: |
./build.sh -s -n -c "${{ matrix.compiler }}" -a "${{ matrix.compiler-args }}" ${{ matrix.target }}
65 changes: 48 additions & 17 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,61 @@
#!/bin/bash

while getopts ":s" opt; do
case $opt in
s)
# Default settings
COMPILER=g++
COMPILERARGS=""
INSTALLPREREQ=true
SILENT=false

while getopts "snc:a:" opt; do
case "${opt}" in
n)
echo "## No Prerequisites will be installed"
INSTALLPREREQ=false
;;
s)
echo "## Silent"
SILENT=true
command shift
;;
c)
COMPILER=${OPTARG}
echo "## Configured compiler ${COMPILER}"
;;
a)
COMPILERARGS=${OPTARG}
echo "## Configured compiler arguments ${COMPILERARGS}"
;;
esac
done
echo "Building OpenSprinkler..."

if [ "$1" == "demo" ]; then
echo "Installing required libraries..."
shift $((OPTIND-1)) #This tells getopts to move on to the next argument.

# Check compiler exists or fail
$COMPILER -v
if [[ $? -ne 0 ]] ; then
exit 2
fi

if [[ $INSTALLPREREQ -ne false ]] ; then
echo "## Installing required libraries..."
apt-get install -y libmosquitto-dev
echo "Compiling firmware..."
g++ -o OpenSprinkler -DDEMO -m32 main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
fi

echo "## Building OpenSprinkler..."

if [ "$1" == "demo" ]; then
echo "## Compiling firmware DEMO..."
$COMPILER -o OpenSprinkler -DDEMO $COMPILERARGS -m32 main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
elif [ "$1" == "osbo" ]; then
echo "Installing required libraries..."
apt-get install -y libmosquitto-dev
echo "Compiling firmware..."
g++ -o OpenSprinkler -DOSBO main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
echo "## Compiling firmware for OpenSprinkler OSBO..."
$COMPILER -o OpenSprinkler -DOSBO $COMPILERARGS main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
else
echo "Installing required libraries..."
apt-get install -y libmosquitto-dev
echo "Compiling firmware..."
g++ -o OpenSprinkler -DOSPI main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
echo "## Compiling firmware for OpenSprinkler-PI..."
$COMPILER -o OpenSprinkler -DOSPI $COMPILERARGS main.cpp OpenSprinkler.cpp program.cpp opensprinkler_server.cpp utils.cpp weather.cpp gpio.cpp etherport.cpp mqtt.cpp -lpthread -lmosquitto
fi

# Exit with errorcode 1 on compiler errors
if [[ $? -ne 0 ]] ; then
exit 1
fi

if [ ! "$SILENT" = true ] && [ -f OpenSprinkler.launch ] && [ ! -f /etc/init.d/OpenSprinkler.sh ]; then
Expand Down