Adding junit testing and reporting

This commit is contained in:
2026-01-18 10:39:10 -05:00
parent cdc010720f
commit 725ed205c4
3 changed files with 51 additions and 22 deletions

30
.github/workflows/main.yaml vendored Normal file
View 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

View File

@@ -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
View File

@@ -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