Add GitHub Actions CI build (#1341)
* Add GHA CI build (Java 11/17) * Add GHA build status badge * Update required Java version range used by the enforcer plugin Signed-off-by: Wouter Born <github@maindrain.net>pull/1344/head
parent
4727a76106
commit
97f18398d3
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "openhab-compile-problems",
|
||||
"severity": "error",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "Failed to execute goal.*Compilation failure"
|
||||
},
|
||||
{
|
||||
"regexp": "^\\[ERROR\\] (.+\\.java):\\[(.+),(.+)\\] (.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"col": 3,
|
||||
"message": 4,
|
||||
"loop": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
|
||||
BUILD_LOG=build.log
|
||||
|
||||
ARGUMENTS="clean verify -B -T 1.5C -U"
|
||||
if [ $# -ge 1 ]; then
|
||||
ARGUMENTS=$@
|
||||
fi
|
||||
|
||||
function print_reactor_summary() {
|
||||
local start_end=$(grep -anE "\[INFO\] \\-{70,}" "$BUILD_LOG" | tail -n4 | cut -f1 -d: | sed -e 1b -e '$!d' | xargs)
|
||||
local start=$(awk '{print $1}' <<< $start_end)
|
||||
local end=$(awk '{print $2}' <<< $start_end)
|
||||
cat "$BUILD_LOG" | sed -n "${start},${end}p" | sed 's/\[INFO\] //'
|
||||
}
|
||||
|
||||
function mvnp() {
|
||||
set -o pipefail # exit build with error when pipes fail
|
||||
local reactor_size=$(find -name "pom.xml" | grep -vE '/src/|/target/' | wc -l)
|
||||
local padding=$(bc -l <<< "scale=0;2*(l($reactor_size)/l(10)+1)")
|
||||
local command=(mvn $@)
|
||||
exec "${command[@]}" 2>&1 | # execute, redirect stderr to stdout
|
||||
tee "$BUILD_LOG" | # write output to log
|
||||
stdbuf -oL grep -aE '^\[INFO\] Building .+ \[.+\]$' | # filter progress
|
||||
stdbuf -o0 sed -uE 's/^\[INFO\] Building (.*[^ ])[ ]+\[([0-9]+\/[0-9]+)\]$/\2| \1/' | # prefix project name with progress
|
||||
stdbuf -o0 sed -e :a -e "s/^.\{1,${padding}\}|/ &/;ta" # right align progress with padding
|
||||
}
|
||||
|
||||
function build_all() {
|
||||
echo
|
||||
echo "Building all projects"
|
||||
echo
|
||||
echo "+ mvn $ARGUMENTS"
|
||||
echo
|
||||
|
||||
mvnp $ARGUMENTS
|
||||
|
||||
status=$?
|
||||
echo
|
||||
|
||||
if [ $status -eq 0 ]; then
|
||||
print_reactor_summary
|
||||
else
|
||||
tail -n 2000 "$BUILD_LOG"
|
||||
fi
|
||||
|
||||
exit $status
|
||||
}
|
||||
|
||||
mvn -v
|
||||
build_all
|
|
@ -0,0 +1,94 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
paths-ignore:
|
||||
- '.github/**/*.md'
|
||||
pull_request:
|
||||
branches:
|
||||
- 'main'
|
||||
paths-ignore:
|
||||
- '.github/**/*.md'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
java: [ '11', '17' ]
|
||||
maven: [ '3.8.4']
|
||||
os: [ 'ubuntu-20.04' ]
|
||||
name: Build (Java ${{ matrix.java }}, ${{ matrix.os }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
if: github.head_ref == ''
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Checkout merge
|
||||
if: github.head_ref != ''
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: refs/pull/${{github.event.pull_request.number}}/merge
|
||||
|
||||
- name: Set up Cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.m2/repository
|
||||
!~/.m2/repository/org/openhab
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
|
||||
- name: Set up Java ${{ matrix.java }}
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: ${{ matrix.java }}
|
||||
|
||||
- name: Set up Maven ${{ matrix.maven }}
|
||||
uses: stCarolas/setup-maven@v4.2
|
||||
with:
|
||||
maven-version: ${{ matrix.maven }}
|
||||
|
||||
- name: Register Problem Matchers
|
||||
if: ${{ matrix.java == '11' }}
|
||||
id: problem_matchers
|
||||
run: |
|
||||
echo "::add-matcher::.github/openhab-compile-problems.json"
|
||||
|
||||
- name: Build
|
||||
id: build
|
||||
run: './.github/scripts/maven-build'
|
||||
env:
|
||||
MAVEN_OPTS: >-
|
||||
-Xmx2g
|
||||
-Dmaven.wagon.http.retryHandler.count=5
|
||||
-Dmaven.wagon.httpconnectionManager.ttlSeconds=25
|
||||
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
|
||||
|
||||
- name: Upload Build Log
|
||||
if: ${{ always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }}
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: build-log-java-${{ matrix.java }}-${{ matrix.os }}
|
||||
path: build.log
|
||||
|
||||
- name: Upload SAT Summary Report
|
||||
if: ${{ always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }}
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: sat-summary-report
|
||||
path: target/summary_report.html
|
||||
|
||||
- name: Report SAT Errors as Annotations
|
||||
if: ${{ matrix.java == '11' && always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }}
|
||||
uses: ghys/checkstyle-github-action@main
|
||||
with:
|
||||
title: CheckStyle Violations
|
||||
path: '**/checkstyle-result.xml'
|
||||
mode: inline
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
<img align="right" width="220" src="./logo.svg" type="image/svg+xml"/>
|
||||
|
||||
[![Build Status](https://ci.openhab.org/job/openHAB-WebUI/badge/icon)](https://ci.openhab.org/job/openHAB-WebUI/)
|
||||
[![GitHub Actions Build Status](https://github.com/openhab/openhab-webui/actions/workflows/ci-build.yml/badge.svg?branch=main)](https://github.com/openhab/openhab-webui/actions/workflows/ci-build.yml)
|
||||
[![Jenkins Build Status](https://ci.openhab.org/job/openHAB-WebUI/badge/icon)](https://ci.openhab.org/job/openHAB-WebUI/)
|
||||
[![EPL-2.0](https://img.shields.io/badge/license-EPL%202-green.svg)](https://opensource.org/licenses/EPL-2.0)
|
||||
[![Crowdin](https://badges.crowdin.net/openhab-webui/localized.svg)](https://crowdin.com/project/openhab-webui)
|
||||
[![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=2164344)](https://www.bountysource.com/teams/openhab/issues?tracker_ids=2164344)
|
||||
|
|
Loading…
Reference in New Issue