Adding junit testing and reporting
This commit is contained in:
30
.github/workflows/main.yaml
vendored
Normal file
30
.github/workflows/main.yaml
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
name: CI with JUnit Report
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: install dependencies and run tests
|
||||||
|
run: |
|
||||||
|
set -x
|
||||||
|
mkdir -p deps
|
||||||
|
git clone ${{ vars.VERSIONERS_URI }} deps/versioners
|
||||||
|
cd deps/versioners
|
||||||
|
make install
|
||||||
|
cd ../../
|
||||||
|
git clone ${{ vars.SHUNIT_URI }} deps/shunit
|
||||||
|
cd deps/shunit
|
||||||
|
make install
|
||||||
|
cd ../../
|
||||||
|
make test-ci
|
||||||
|
cat junit.xml
|
||||||
|
- name: Publish Test Report
|
||||||
|
uses: mikepenz/action-junit-report@v5
|
||||||
|
if: success() || failure() # always run even if the previous step fails
|
||||||
|
with:
|
||||||
|
report_paths: 'junit.xml'
|
||||||
|
annotate_only: true
|
||||||
|
include_passed: true
|
||||||
28
Makefile
28
Makefile
@@ -1,5 +1,9 @@
|
|||||||
VERSION:=$(shell if [ -d .git ]; then bash -c 'gitversion.sh | grep "^MAJOR=" | cut -d = -f 2'; else source version.sh && echo $$MAJOR ; fi)
|
ifndef PREFIX
|
||||||
RELEASE:=$(shell if [ -d .git ]; then bash -c 'gitversion.sh | grep "^BUILD=" | cut -d = -f 2'; else source version.sh && echo $$BUILD ; fi)
|
PREFIX=/usr
|
||||||
|
endif
|
||||||
|
|
||||||
|
VERSION:=$(shell if [ -d .git ]; then bash -c '$(PREFIX)/bin/gitversion.sh | grep "^MAJOR=" | cut -d = -f 2'; else source version.sh && echo $$MAJOR ; fi)
|
||||||
|
RELEASE:=$(shell if [ -d .git ]; then bash -c '$(PREFIX)/bin/gitversion.sh | grep "^BUILD=" | cut -d = -f 2'; else source version.sh && echo $$BUILD ; fi)
|
||||||
DISTFILE=./dist/cmdarg-$(VERSION)-$(RELEASE).tar.gz
|
DISTFILE=./dist/cmdarg-$(VERSION)-$(RELEASE).tar.gz
|
||||||
SPECFILE=cmdarg.spec
|
SPECFILE=cmdarg.spec
|
||||||
ifndef RHEL_VERSION
|
ifndef RHEL_VERSION
|
||||||
@@ -19,12 +23,13 @@ ifndef PREFIX
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
DISTFILE_DEPS=$(shell find . -type f | grep -Ev '\.git|\./dist/|$(DISTFILE)')
|
DISTFILE_DEPS=$(shell find . -type f | grep -Ev '\.git|\./dist/|$(DISTFILE)')
|
||||||
|
JUNIT_DEPS=$(wildcard *.sh) $(wildcard tests/*.sh)
|
||||||
|
|
||||||
all: ./dist/$(RPM)
|
all: ./dist/$(RPM)
|
||||||
|
|
||||||
# --- PHONY targets
|
# --- PHONY targets
|
||||||
|
|
||||||
.PHONY: clean srpm rpm gitclean dist
|
.PHONY: clean srpm rpm gitclean dist test test-ci
|
||||||
clean:
|
clean:
|
||||||
rm -f $(DISTFILE)
|
rm -f $(DISTFILE)
|
||||||
rm -fr dist/cmdarg-$(VERSION)-$(RELEASE)*
|
rm -fr dist/cmdarg-$(VERSION)-$(RELEASE)*
|
||||||
@@ -38,8 +43,18 @@ rpm: ./dist/$(RPM) ./dist/$(SRPM)
|
|||||||
gitclean:
|
gitclean:
|
||||||
git clean -df
|
git clean -df
|
||||||
|
|
||||||
|
test: tunit.txt
|
||||||
|
|
||||||
|
test-ci: junit.xml
|
||||||
|
|
||||||
# --- End phony targets
|
# --- End phony targets
|
||||||
|
|
||||||
|
junit.xml: cmdarg.sh $(JUNIT_DEPS)
|
||||||
|
AK_PREFIX=. $(PREFIX)/bin/shunit.sh -f junit -t tests > junit.xml
|
||||||
|
|
||||||
|
tunit.txt: cmdarg.sh $(JUNIT_DEPS)
|
||||||
|
AK_PREFIX=. $(PREFIX)/bin/shunit.sh -f tunit -t tests | tee tunit.txt
|
||||||
|
|
||||||
version.sh:
|
version.sh:
|
||||||
gitversion.sh > version.sh
|
gitversion.sh > version.sh
|
||||||
|
|
||||||
@@ -65,10 +80,9 @@ $(RHEL_DISTFILE): $(DISTFILE)
|
|||||||
uninstall:
|
uninstall:
|
||||||
rm -f $(PREFIX)/usr/lib/cmdarg.sh
|
rm -f $(PREFIX)/usr/lib/cmdarg.sh
|
||||||
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
mkdir -p $(PREFIX)/usr/lib
|
mkdir -p $(PREFIX)/lib
|
||||||
install ./cmdarg.sh $(PREFIX)/usr/lib/cmdarg.sh
|
install ./cmdarg.sh $(PREFIX)/lib/cmdarg.sh
|
||||||
|
|
||||||
MANIFEST:
|
MANIFEST:
|
||||||
echo /usr/lib/cmdarg.sh > MANIFEST
|
echo $(PREFIX)/lib/cmdarg.sh > MANIFEST
|
||||||
|
|||||||
15
test.sh
15
test.sh
@@ -1,15 +0,0 @@
|
|||||||
#!/usr/bin/bash4
|
|
||||||
|
|
||||||
declare -a cfg_array
|
|
||||||
declare -A cfg_hash
|
|
||||||
|
|
||||||
source ./cmdarg.sh
|
|
||||||
|
|
||||||
cmdarg 'b' 'boolean' 'A boolean argument'
|
|
||||||
cmdarg 's:' 'string' 'A string argument'
|
|
||||||
cmdarg 'a:[]' 'cfg_array' 'An array argument'
|
|
||||||
cmdarg 'H:{}' 'cfg_hash' 'A hash argument'
|
|
||||||
|
|
||||||
cmdarg_parse "$@"
|
|
||||||
|
|
||||||
cmdarg_dump
|
|
||||||
Reference in New Issue
Block a user