Skip to content

Commit 988a3fc

Browse files
authored
Merge pull request #28 from networkupstools/modernize-2026
Modernize 2026
2 parents 67d7fb1 + c76d0c0 commit 988a3fc

24 files changed

Lines changed: 946 additions & 604 deletions

File tree

.editorconfig

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
# https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties
3+
4+
# top-most EditorConfig file
5+
root = true
6+
7+
[*]
8+
charset = utf-8
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
max_line_length = 80
13+
14+
indent_style = tab
15+
tab_width = 4
16+
#indent_style = space
17+
#indent_size = 4
18+
19+
# Platform-dependent, except for certain interpreters
20+
# whose sources must use LF, see .gitattributes
21+
###end_of_line = lf
22+
23+
#ij_formatter_enabled = false
24+
25+
[.editorconfig]
26+
trim_trailing_whitespace = false
27+
28+
[*.{bat,cmd,ps1}]
29+
end_of_line = crlf
30+
31+
[*.{am,hwdb,service,target,path}{,.in}]
32+
end_of_line = lf
33+
line_comment = #
34+
35+
[*.sh{,.in}]
36+
end_of_line = lf
37+
line_comment = #
38+
39+
# Borrowed from https://github.com/armbian/build/blob/master/.editorconfig
40+
shell_variant = bash
41+
binary_next_line = false
42+
switch_case_indent = true
43+
space_redirects = true
44+
keep_padding = false
45+
function_next_line = false
46+
47+
[*.{m4,ac}{,.in}]
48+
end_of_line = lf
49+
line_comment = dnl
50+
51+
[*.{conf,sample}{,.in}]
52+
max_line_length = 76
53+
line_comment = #
54+
55+
[*.txt{,.in},*.adoc{,.in},AUTHORS,COPYING,INSTALL.nut,MAINTAINERS,NEWS,README,TODO,UPGRADING]
56+
max_line_length = 76
57+
indent_style = space
58+
indent_size = 4
59+
60+
# Assumes asciidoc comments:
61+
block_comment_start = ////////
62+
block_comment_end = ////////
63+
64+
[*.{java,groovy,yaml,yml,json}{,.in}]
65+
indent_style = space
66+
indent_size = 4
67+
68+
[pom.xml]
69+
indent_style = space
70+
indent_size = 2
71+
72+
################################################################
73+
# Primary concern: C/C++ style
74+
# See also docs/developers.txt => Code Style chapter
75+
76+
[*.{c,h,cpp}{,.in}]
77+
spaces_around_operators = true
78+
spaces_around_brackets = none
79+
80+
# Plus one TAB:
81+
continuation_indent_size = 1
82+
83+
indent_brace_style = K&R
84+
85+
block_comment_start = /*
86+
block_comment_end = */

.gitattributes

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Windows script files should be CR+LF always:
2+
*.bat text eol=crlf
3+
4+
# Unix/Linux script files should be LF always:
5+
*.sh text eol=lf
6+
*.m4 text eol=lf
7+
*.ac text eol=lf
8+
*.am text eol=lf
9+
*.hwdb text eol=lf
10+
11+
# Aspell claims issues finding `utf-8\r` sometimes (from heading line of
12+
# the dictionary file), with messages like this:
13+
# .cset" could not be opened for reading or does not exist.lib/aspell/utf-8
14+
# which tends to happen in mixed-OS development environments. Tracer shows it:
15+
# read(3, "personal_ws-1.1 en 3225 utf-8\r\nA"..., 4096) = 4096
16+
# access("/usr/lib/aspell/utf-8\r.cset", F_OK) = -1 ENOENT (No such file or directory)
17+
/docs/nut.dict text eol=lf
18+
19+
# Some files are binary always:
20+
*.png bin
21+
*.ico bin
22+
23+
# The rest are assumed text sources with platform-dependent EOL being okay,
24+
# or we let Git guess otherwise:
25+
* text=auto

.github/codeql/codeql-config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
paths:
2+
- .

.github/workflows/04-maven-nit.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
name: "GHA-04: Maven NIT"
8+
9+
on:
10+
push:
11+
branches: [ "master" ]
12+
pull_request:
13+
# The branches below must be a subset of the branches above
14+
branches: [ "master" ]
15+
schedule:
16+
- cron: '22 12 * * 0'
17+
workflow_dispatch:
18+
# Allow manually running the action, e.g. if disabled after some quietness in the source
19+
20+
jobs:
21+
maven-NIT:
22+
name: "Compile the project, test against NUT data server"
23+
runs-on: ${{ matrix.os }}
24+
permissions:
25+
actions: read
26+
contents: read
27+
security-events: write
28+
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
compilerpkg: [ 'openjdk-21-jdk' ]
33+
# TOTHINK: various JDK versions?
34+
os: [ 'ubuntu-latest' ]
35+
# TOTHINK: windows-latest, macos-latest?
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v3
40+
41+
# Using hints from https://askubuntu.com/questions/272248/processing-triggers-for-man-db
42+
- if: matrix.os == 'ubuntu-latest'
43+
name: NUT CI Prerequisite packages (Ubuntu)
44+
run: |
45+
echo "set man-db/auto-update false" | sudo debconf-communicate
46+
sudo dpkg-reconfigure man-db
47+
sudo apt update
48+
sudo apt install ${{ matrix.compilerpkg }} maven nut
49+
date > .timestamp-init
50+
51+
- name: Prepare maven cache
52+
# Based on https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#example-using-the-cache-action example
53+
id: cache-m2cache
54+
uses: actions/cache@v4
55+
env:
56+
cache-name: cache-m2cache-
57+
with:
58+
path: |
59+
~/.m2
60+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/.timestamp-init') }}
61+
restore-keys: |
62+
${{ runner.os }}-build-${{ env.cache-name }}-
63+
${{ runner.os }}-build-
64+
${{ runner.os }}-
65+
66+
# ℹ️ Command-line programs to run using the OS shell.
67+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
68+
69+
- name: Maven build and test
70+
run: mvn package
71+
72+
# TODO: Setup NUT, run client (add in-tree script for that and call it)
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "GHA-06: CodeQL Java"
13+
14+
on:
15+
push:
16+
branches: [ "master" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ "master" ]
20+
schedule:
21+
- cron: '32 12 * * 0'
22+
workflow_dispatch:
23+
# Allow manually running the action, e.g. if disabled after some quietness in the source
24+
25+
jobs:
26+
analyze:
27+
name: Analyze
28+
runs-on: ${{ matrix.os }}
29+
permissions:
30+
actions: read
31+
contents: read
32+
security-events: write
33+
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
38+
language: [ 'java' ]
39+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
40+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
41+
compilerpkg: [ 'openjdk-21-jdk' ]
42+
# TOTHINK: various JDK versions?
43+
os: [ 'ubuntu-latest' ]
44+
# TOTHINK: windows-latest, macos-latest?
45+
build-mode: [ 'autobuild' ]
46+
# manual ?
47+
# https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
48+
# Abusing "manual" here to try building with ccache (and
49+
# have codeql not intercept that build but parse C/C++
50+
# files on its own), and "manual" to custom-build without;
51+
# the "autobuild" mode is handled by codeql itself but
52+
# would probably ignore our CC/CXX setting
53+
# NOTE: We do not add ccache to PATH when actually compiling NUT code
54+
# (we only speed up "configure" stages), so compilation always happens
55+
# and is parsed by current CodeQL detectors of the day as they evolve!
56+
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v3
60+
61+
# Using hints from https://askubuntu.com/questions/272248/processing-triggers-for-man-db
62+
- if: matrix.language == 'java' && matrix.os == 'ubuntu-latest'
63+
name: NUT CI Prerequisite packages (Ubuntu)
64+
run: |
65+
echo "set man-db/auto-update false" | sudo debconf-communicate
66+
sudo dpkg-reconfigure man-db
67+
sudo apt update
68+
sudo apt install ${{ matrix.compilerpkg }} maven
69+
date > .timestamp-init
70+
71+
- name: Prepare maven cache
72+
# Based on https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#example-using-the-cache-action example
73+
id: cache-m2cache
74+
uses: actions/cache@v4
75+
env:
76+
cache-name: cache-m2cache-
77+
with:
78+
path: |
79+
~/.m2
80+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/.timestamp-init') }}
81+
restore-keys: |
82+
${{ runner.os }}-build-${{ env.cache-name }}-
83+
${{ runner.os }}-build-
84+
${{ runner.os }}-
85+
86+
# Initializes the CodeQL tools for scanning.
87+
- name: Initialize CodeQL
88+
uses: github/codeql-action/init@v3
89+
with:
90+
languages: ${{ matrix.language }}
91+
build-mode: ${{ matrix.build-mode }}
92+
# If you wish to specify custom queries, you can do so here or in a config file.
93+
# By default, queries listed here will override any specified in a config file.
94+
# Prefix the (whole) list here with "+" to use these queries and those in the config file.
95+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
96+
queries: +security-extended,security-and-quality
97+
config-file: ./.github/codeql/codeql-config.yml
98+
99+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
100+
# If this step fails, then you should remove it and run the build manually (see below)
101+
# https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
102+
- if: matrix.build-mode == 'autobuild'
103+
name: Autobuild
104+
uses: github/codeql-action/autobuild@v3
105+
106+
# ℹ️ Command-line programs to run using the OS shell.
107+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
108+
109+
- if: matrix.build-mode != 'autobuild' && matrix.language == 'java'
110+
name: Maven build and test
111+
run: mvn package
112+
113+
- name: Perform CodeQL Analysis
114+
uses: github/codeql-action/analyze@v3
115+
with:
116+
category: "/language:${{matrix.language}}"

README

Lines changed: 0 additions & 19 deletions
This file was deleted.

README.adoc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
jNut
2+
====
3+
4+
A NUT Client for Java: library, sample command-line client, WAR suitable
5+
for deployment into web application servers to handle NUT via REST API.
6+
7+
Java NUT Client files
8+
~~~~~~~~~~~~~~~~~~~~~
9+
10+
This directory contains various NUT Client related java source files,
11+
originally written by Emilien Kia in 2011, sponsored by Eaton, and
12+
released under GPL v2 as part of NUT code base (repository separated
13+
as a standalone project in 2013).
14+
15+
Submodules are:
16+
17+
* "jNut": this directory contains maven project and source files for jNut,
18+
which is a Java abstraction bundle to access NUT server(s).
19+
You can use it in Java programs to access NUT's `upsd` data server
20+
in a simple way, without having to know the NUT protocol.
21+
22+
* "jNutList": this directory contains maven project and source files for
23+
jNutList, a simple Java example program using jNut which connects to an
24+
`upsd`, and lists its devices and their variables and commands.
25+
Rough equivalent to `upsc` "example client" in NUT itself.
26+
27+
* "jNutWebAPI": this directory contains maven project and source files for
28+
jNutWebAPI, a simple Java web archive to access NUT information via REST
29+
web services.

README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)