Skip to content

Commit

Permalink
Add build image function to GitHub Actions
Browse files Browse the repository at this point in the history
The 'Build Image' action was primarily written by Holger Friedrich and
then edited for better functionality in the openHABian core repo.

This also contains other changes to the CI setup, such as moving the
ShellCheck checks out of Travis and instead enforcing them in GitHub
Actions.

Fixes #991

Co-authored-by: Holger Friedrich <[email protected]>
Co-authored-by: Markus Storm <[email protected]>
Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
3 people committed Jul 6, 2020
1 parent 1cf7926 commit d78eda4
Show file tree
Hide file tree
Showing 13 changed files with 385 additions and 231 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/build-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Build Image

# Trigger the workflow on push or pull request
on:
push:
paths:
- 'build.bash'
- 'build-image/openhabian-installer.service'
pull_request:
paths:
- 'build.bash'
- 'build-image/openhabian-installer.service'

jobs:
build32:
# Using latest Ubuntu (not the GitHub Actions default) to get latest tool versions in GitHub Actions environment
runs-on: ubuntu-20.04

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Environment variables
run: sudo -E bash -c set
- name: Install required packages
run: sudo apt-get install git curl unzip libarchive-zip-perl dos2unix xz-utils kpartx
- name: getimagename
id: getimagename
run: |
echo "::set-output name=image::$(basename "$(curl "https://downloads.raspberrypi.org/raspios_lite_armhf_latest" -s -L -I -o /dev/null -w '%{url_effective}')")"
- name: Cache Raspberry Pi OS image
uses: actions/cache@v2
with:
path: ${{ steps.getimagename.outputs.image }}
key: ${{ steps.getimagename.outputs.image }}
- name: Run build.bash rpi
run: |
sudo -E ./ci-setup.bash github pi-raspios32
sudo -E ./build.bash rpi
- name: getfilename
id: getfilename
run: echo "::set-output name=file::$(ls openhabian-*.img.xz)"
- name: Archive
uses: actions/upload-artifact@v2
with:
name: ${{ steps.getfilename.outputs.file }}
path: ${{ steps.getfilename.outputs.file }}
build64experimental:
# Using latest Ubuntu (not the GitHub Actions default) to get latest tool versions in GitHub Actions environment
runs-on: ubuntu-20.04

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Environment variables
run: sudo -E bash -c set
- name: Install required packages
run: sudo apt-get install git curl unzip libarchive-zip-perl dos2unix xz-utils kpartx
- name: getimagename
id: getimagename
run: |
echo "::set-output name=image::$(basename "$(curl "https://downloads.raspberrypi.org/raspios_arm64_latest" -s -L -I -o /dev/null -w '%{url_effective}')")"
- name: Cache Raspberry Pi OS image
uses: actions/cache@v2
with:
path: ${{ steps.getimagename.outputs.image }}
key: ${{ steps.getimagename.outputs.image }}
- name: Run build.bash rpi64
run: |
sudo -E ./ci-setup.bash github pi-raspios64beta
sudo -E ./build.bash rpi64
- name: getfilename
id: getfilename
run: echo "::set-output name=file::$(ls openhabian-*.img.xz)"
- name: Archive
uses: actions/upload-artifact@v2
with:
name: ${{ steps.getfilename.outputs.file }}
path: ${{ steps.getfilename.outputs.file }}
56 changes: 36 additions & 20 deletions .github/workflows/shellcheck-action.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# This is a basic workflow to help you get started with Actions
name: ShellCheck

name: shellcheck

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
# Trigger the workflow on push or pull request
on:
push
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
push:
paths:
- '**.bash'
- '**.sh'
- '!test.bash'
pull_request:
paths:
- '**.bash'
- '**.sh'
- '!test.bash'

jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
shellcheck:
# Using latest Ubuntu (not the GitHub Actions default) to get latest tool versions in GitHub Actions environment
runs-on: ubuntu-20.04

steps:
- name: Checkout repository
Expand All @@ -20,12 +25,23 @@ jobs:
run: sudo -E bash -c set
- name: Install required packages
run: sudo apt-get install shellcheck
- name: "Check 1"
run: shellcheck -x -s bash openhabian-setup.sh && echo "shellcheck openhabian-setup.sh - OK";
- name: "Check 2"
run: shellcheck -x -s bash functions/*.bash && echo "shellcheck functions/*.bash - OK";
- name: "Check 3"
run: shellcheck -x -s bash build-image/*.bash && echo "shellcheck build-image/*.bash - OK";
- name: "Check 4"
run: shellcheck -x -s bash build.bash && echo "shellcheck build.bash - OK"

- name: "ShellCheck openhabian-setup.sh"
run: |
echo "ShellCheck openhabian-setup.sh..."
if shellcheck -x -s bash openhabian-setup.sh; then echo "OK"; else echo "FAILED"; exit 1; fi
shell: bash
- name: "ShellCheck functions/*.bash"
run: |
echo "ShellCheck functions/*.bash..."
if shellcheck -x -s bash functions/*.bash; then echo "OK"; else echo "FAILED"; exit 1; fi
shell: bash
- name: "ShellCheck build-image/*.bash"
run: |
echo "ShellCheck build-image/*.bash..."
if shellcheck -x -s bash build-image/*.bash; then echo "OK"; else echo "FAILED"; exit 1; fi
shell: bash
- name: "ShellCheck build.bash"
run: |
echo "ShellCheck build.bash..."
if shellcheck -x -s bash build.bash; then echo "OK"; else echo "FAILED"; exit 1; fi
shell: bash
31 changes: 12 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
language: shell
os: linux
# using latest Ubuntu (not the travis-ci default) to get latest tool versions in Travis environment
# Using latest Ubuntu (not the Travis-CI default) to get latest tool versions in Travis environment
dist: focal

cache: false

addons:
apt:
packages:
- shellcheck
update: true

git:
submodules: false
quiet: true
Expand All @@ -19,19 +13,19 @@ services:
- docker

stages:
- BATS and ShellCheck tests
- BATS tests
- openHABian installation tests

install:
- ./test.bash travis
- ./ci-setup.bash travis

jobs:
fast_finish: true
allow_failures:
- stage: BATS and ShellCheck tests
- stage: BATS tests
include:
- stage: BATS and ShellCheck tests
name: BATS and ShellCheck tests on virtual RPi4
- stage: BATS tests
name: BATS tests on virtual RPi4
env: HW=rpi4
arch: arm64
script:
Expand All @@ -42,14 +36,13 @@ jobs:
- docker run --name "unit-tests" -i openhabian/bats-openhabian bash -c 'bats --tap --recursive --filter "unit-." .'
- docker run --name "installation-tests" -i openhabian/bats-openhabian bash -c 'bats --tap --recursive --filter "installation-." .'
- docker run --name "destructive-tests" -i openhabian/bats-openhabian bash -c 'bats --tap --recursive --filter "destructive-." .'
- shellcheck -x -s bash openhabian-setup.sh functions/*.bash build-image/*.bash build.bash && echo "shellcheck - OK"
- stage: openHABian installation tests
name: openHABian installation test with 64bit Azul Java 8 on native amd64
env: HW=amd64
arch: amd64
script:
# 64bit Azul Java 8 on a 64bit amd64 virtual platform, running in a 64bit OS on Travis AMD64 HW
- sed -i 's/^java_opt=.*$/java_opt=Zulu8-64/' build-image/openhabian.conf
- sed -i 's|^java_opt=.*$|java_opt=Zulu8-64|' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.amd64 .
- echo -e "\n\e[36mopenHABian test installation using 64bit Azul Enterprise Java 8 running on a\e[31m 64bit OS\e[36m running on native ${HW}...\e[0m\n"
- docker run --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
Expand All @@ -59,7 +52,7 @@ jobs:
arch: amd64
script:
# 64bit Azul Java 11 on a 64bit amd64 virtual platform, running in a 64bit => Ubuntu <= OS on Travis AMD64 HW
- sed -i 's/^java_opt=.*$/java_opt=Zulu11-64/' build-image/openhabian.conf
- sed -i 's|^java_opt=.*$|java_opt=Zulu11-64|' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.amd64-ubuntu .
- echo -e "\n\e[36mopenHABian test installation using 64bit Azul Enterprise Java 11 running on a\e[31m 64bit Ubuntu\e[36m running on native ${HW}...\e[0m\n"
- docker run --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
Expand All @@ -69,7 +62,7 @@ jobs:
arch: arm64
script:
# 32bit Azul Java 8 on a 32bit ARMv7l (RPi2) virtual platform, running in a 32bit OS on Travis Arm64 HW
- sed -i 's/^java_opt=.*$/java_opt=Zulu8-32/' build-image/openhabian.conf
- sed -i 's|^java_opt=.*$|java_opt=Zulu8-32|' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.raspberry-pi2 .
- echo -e "\n\e[36mopenHABian test installation using 32bit Azul Embedded Java 8 running on a\e[31m 32bit OS\e[36m running in a virtual ${HW}...\e[0m\n"
- docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian
Expand All @@ -79,7 +72,7 @@ jobs:
arch: arm64
script:
# 32bit Azul Java 11 on a 64bit ARMv8 (RPi3) virtual platform, running in a 32bit OS on Travis Arm64 HW
- sed -i 's/^java_opt=.*$/java_opt=Zulu11-32/' build-image/openhabian.conf
- sed -i 's|^java_opt=.*$|java_opt=Zulu11-32|' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.raspberrypi3 .
- echo -e "\n\e[36mopenHABian test installation using 32bit Azul Embedded Java 11 running on a\e[31m 32bit OS\e[36m running in a virtual ${HW}...\e[0m\n"
- docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
Expand All @@ -89,7 +82,7 @@ jobs:
arch: arm64
script:
# 64bit Azul Java 8 on a 64bit ARMv8 (RPi3) virtual platform, running in a 64bit OS on Travis Arm64 HW
- sed -i 's/^java_opt=.*$/java_opt=Zulu8-64/' build-image/openhabian.conf
- sed -i 's|^java_opt=.*$|java_opt=Zulu8-64|' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.raspberrypi3-64 .
- echo -e "\n\e[36mopenHABian test installation using 64bit Azul Embedded Java 8 running on a\e[31m 64bit OS\e[36m running in a virtual ${HW}...\e[0m\n"
- docker run --memory="2g" --memory-reservation="2g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
Expand All @@ -99,7 +92,7 @@ jobs:
arch: arm64
script:
# AdoptOpenJDK Java 11 on a 32bit ARMv7l (RPi2) virtual platform, running in a 32bit OS on Travis Arm64 HW
- sed -i 's/^java_opt=.*$/java_opt=Adopt11/' build-image/openhabian.conf
- sed -i 's|^java_opt=.*$|java_opt=Adopt11|' build-image/openhabian.conf
- docker build -t openhabian/${HW}-openhabian -f Dockerfile.raspberry-pi2 .
- echo -e "\n\e[36mopenHABian test installation using AdoptOpenJDK Java 11 running on a\e[31m 32bit OS\e[36m running in a virtual ${HW}...\e[0m\n"
- docker run --memory="1g" --memory-reservation="1g" --name "openhabian-${HW}" -d openhabian/${HW}-openhabian;
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.amd64-ubuntu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM balenalib/intel-nuc-ubuntu:focal-build
FROM balenalib/amd64-ubuntu:focal-build


ENV container docker
Expand Down
Loading

0 comments on commit d78eda4

Please sign in to comment.