Skip to content

Implement the remainder of NUT Networked protocol… #19

Implement the remainder of NUT Networked protocol…

Implement the remainder of NUT Networked protocol… #19

Workflow file for this run

# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
name: "GHA-04: Maven NIT"
on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '22 12 * * 0'
workflow_dispatch:
# Allow manually running the action, e.g. if disabled after some quietness in the source
jobs:
maven-NIT:
name: "Compile the project, test against NUT data server"
runs-on: ${{ matrix.os }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
compilerpkg: [ 'openjdk-21-jdk' ]
# TOTHINK: various JDK versions?
os: [ 'ubuntu-latest' ]
# TOTHINK: windows-latest, macos-latest?
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Using hints from https://askubuntu.com/questions/272248/processing-triggers-for-man-db
- if: matrix.os == 'ubuntu-latest'
name: NUT CI Prerequisite packages (Ubuntu)
run: |
echo "set man-db/auto-update false" | sudo debconf-communicate
sudo dpkg-reconfigure man-db
sudo apt update
sudo apt install ${{ matrix.compilerpkg }} maven nut
date > .timestamp-init
- name: Prepare maven cache
# Based on https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#example-using-the-cache-action example
id: cache-m2cache
uses: actions/cache@v4
env:
cache-name: cache-m2cache-
with:
path: |
~/.m2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/.timestamp-init') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- name: Maven build and test
run: mvn package
# Setup NUT, run client (add in-tree script for that and call it)
# NOTE: We use binaries from the package for speedier turnaround
# TOTHINK: No SSL self-reporting before NUT v2.8.5 ...
- name: Checkout NUT sources (for NIT script)
run: |
git clone --depth=1 https://github.com/networkupstools/nut
- if: matrix.os == 'ubuntu-latest'
name: Test jNut with NIT
run: |
PATH="/lib/nut:/libexec/nut:/usr/sbin:/usr/bin:$JAVA_HOME/bin:$PATH"
export PATH
#NIT_CASE="generatecfg_upsd_add_SSL && generatecfg_upsdusers_trivial && generatecfg_ups_dummy"
WITH_SSL_SERVER=NSS WITH_SSL_CLIENT=NSS \
NIT_CASE="generatecfg_sandbox" DEBUG_SLEEP=1 ./nut/tests/NIT/nit.sh || exit
if [ -s ./nut/tests/NIT/tmp/etc/NIT.env ]; then
. ./nut/tests/NIT/tmp/etc/NIT.env || exit
else . ./tmp/etc/NIT.env || exit ; fi
echo 'maxstartdelay = 30' > "$NUT_CONFPATH/ups.conf.x"
grep -v maxstartdelay < "$NUT_CONFPATH/ups.conf" >> "$NUT_CONFPATH/ups.conf.x"
mv -f "$NUT_CONFPATH/ups.conf.x" "$NUT_CONFPATH/ups.conf"
SSL_ARGS=""
if [ -d "$NUT_CONFPATH/cert/upsd" ] ; then
mkdir -p "${NUT_CONFPATH}/cert/jks"
JNUTKS="${NUT_CONFPATH}/cert/jks/jNut.jks"
# For client we need Root CA cert (maybe server cert?) and own cert/key (upsmon)
# and NIT script already leaves (most of) them there as PEM files
keytool -importcert -noprompt -trustcacerts -keystore "${JNUTKS}" -storetype JKS -storepass "changeit" -alias "${TESTCERT_ROOTCA_NAME}" -file "${TESTCERT_PATH_ROOTCA}/rootca.pem"
keytool -importcert -noprompt -keystore "${JNUTKS}" -storepass "changeit" -alias "${TESTCERT_SERVER_NAME}" -file "${TESTCERT_PATH_SERVER}/server.crt"
if [ ! -e "${TESTCERT_PATH_CLIENT}/client.p12" ] ; then
pk12util -o "${TESTCERT_PATH_CLIENT}/client.p12" -n "${TESTCERT_CLIENT_NAME}" -d "${TESTCERT_PATH_CLIENT}" -W "${TESTCERT_CLIENT_PASS}"
fi
# keytool -importcert -noprompt -keystore "${JNUTKS}" -storepass "changeit" -alias "${TESTCERT_CLIENT_NAME}" -file "${TESTCERT_PATH_CLIENT}/client.crt"
keytool -importkeystore -srckeystore "${TESTCERT_PATH_CLIENT}/client.p12" -srcstoretype PKCS12 -srcstorepass "${TESTCERT_CLIENT_PASS}" -srckeypass "${TESTCERT_CLIENT_PASS}" -destkeystore "${JNUTKS}" -deststoretype JKS -deststorepass "changeit" -destkeypass "changeit" -srcalias "${TESTCERT_CLIENT_NAME}" -destalias "${TESTCERT_CLIENT_NAME}" -v
ls -la "${NUT_CONFPATH}/cert/jks/"
SSL_ARGS="${JNUTKS} changeit 1 1"
fi
upsdrvctl start
upsd -DDDDDD &
UPSD_PID="$!"
trap 'kill $UPSD_PID ; upsdrvctl stop' 0 1 2 3 15
java -jar ./jNutList/target/jNutList-*-jar-with-dependencies.jar localhost "${NUT_PORT}" "admin" "${TESTPASS_ADMIN}" $SSL_ARGS || exit