Compare commits

..

17 Commits

Author SHA1 Message Date
IamTheFij
5f6c924089 Merge pull request 'golang-1-26' (#27) from golang-1-26 into main
Reviewed-on: https://git.iamthefij.com/iamthefij/minitor-go/pulls/27
2026-02-18 17:39:24 +00:00
Ian Fijolek
e614fb35b5 Clean up golangci-lint config 2026-02-18 17:39:24 +00:00
Ian Fijolek
3323a562c9 Run go fix 2026-02-18 17:39:24 +00:00
Ian Fijolek
c40841ef61 Bump go to 1.26 2026-02-18 17:39:24 +00:00
IamTheFij
59ce31c35f Merge pull request 'Update https://git.iamthefij.com/iamthefij/pre-commit-action action to v3.1.0' (#26) from renovate/https-git.iamthefij.com-iamthefij-pre-commit-action-3.x into main
Reviewed-on: https://git.iamthefij.com/iamthefij/minitor-go/pulls/26
2026-02-15 01:19:36 +00:00
Renovate Bot
39359ffb1e Update https://git.iamthefij.com/iamthefij/pre-commit-action action to v3.1.0 2026-02-13 00:03:15 +00:00
Renovate Bot
7d92458a7a Update golang Docker tag to v1.26 2026-02-12 22:37:59 +00:00
Ian Fijolek
723cf7d127 Add armv7 docker build 2026-01-16 10:36:49 -08:00
Ian Fijolek
fd8e81cb1a Update slog to v2 2026-01-15 10:58:35 -08:00
Renovate Bot
0e291719c9 Update golang Docker tag to v1.25 2026-01-15 01:06:41 +00:00
Renovate Bot
884fbaceac Update module git.iamthefij.com/iamthefij/slog to v2 2026-01-15 00:03:12 +00:00
Ian Fijolek
e262afdb1f Merge branch 'master' into next-major 2026-01-13 21:45:27 -08:00
Renovate Bot
a5268ae1f6 Update actions/setup-python action to v6 2026-01-14 05:45:09 +00:00
Renovate Bot
16ad16d873 Update actions/setup-go action to v6 2026-01-14 05:44:37 +00:00
Renovate Bot
200cfd1a2d Update actions/checkout action to v6 2026-01-07 00:02:31 +00:00
Ian Fijolek
afacf40ec8 Update build to better detect tags and versions 2026-01-05 16:20:51 -08:00
Renovate Bot
0a7aab7030 Update actions/checkout action to v6 2025-12-12 00:02:32 +00:00
16 changed files with 35 additions and 71 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ name: test
steps: steps:
- name: test - name: test
image: golang:1.21 image: golang:1.26
environment: environment:
VERSION: ${DRONE_TAG:-${DRONE_COMMIT}} VERSION: ${DRONE_TAG:-${DRONE_COMMIT}}
commands: commands:
@@ -30,7 +30,7 @@ trigger:
steps: steps:
- name: build all binaries - name: build all binaries
image: golang:1.21 image: golang:1.26
environment: environment:
VERSION: ${DRONE_TAG:-${DRONE_COMMIT}} VERSION: ${DRONE_TAG:-${DRONE_COMMIT}}
commands: commands:
+9 -10
View File
@@ -3,19 +3,17 @@ on:
push: push:
branches: branches:
- main - main
- master
tags: tags:
- "v*" - "v*"
pull_request: pull_request:
branches: branches:
- main - main
- master
jobs: jobs:
tests: tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v6 uses: actions/setup-go@v6
@@ -28,7 +26,7 @@ jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v6 uses: actions/setup-go@v6
@@ -39,14 +37,14 @@ jobs:
uses: actions/setup-python@v6 uses: actions/setup-python@v6
- name: Run pre-commit - name: Run pre-commit
uses: https://git.iamthefij.com/iamthefij/pre-commit-action@v3.0.2 uses: https://git.iamthefij.com/iamthefij/pre-commit-action@v3.1.0
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: test needs: test
if: "${{ github.event_name != 'pull_request' }}" if: "${{ github.event_name != 'pull_request' }}"
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v6 uses: actions/setup-go@v6
@@ -55,17 +53,17 @@ jobs:
- name: Build binaries - name: Build binaries
env: env:
VERSION: "${{ vars.REF_NAME }}" VERSION: "${{ github.REF_NAME }}"
run: make all run: make all
# Package binaries and create release if this is a tagged build # Package binaries and create release if this is a tagged build
- name: Compress binaries - name: Compress binaries
if: "${{ github.event_name == 'tag' }}" if: "${{ github.ref_type == 'tag' }}"
run: find ./dist -type f -executable -execdir tar -czvf {}.tar.gz {} \; run: find ./dist -type f -executable -execdir tar -czvf {}.tar.gz {} \;
- name: Upload release - name: Upload release
uses: https://gitea.com/actions/gitea-release-action@v1 uses: https://gitea.com/actions/gitea-release-action@v1
if: "${{ github.event_name == 'tag' }}" if: "${{ github.ref_type == 'tag' }}"
with: with:
files: |- files: |-
dist/*.tar.gz dist/*.tar.gz
@@ -89,6 +87,7 @@ jobs:
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
if: "${{ github.event_name != 'pull_request' }}"
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
@@ -108,6 +107,6 @@ jobs:
platforms: | platforms: |
linux/amd64 linux/amd64
linux/arm64 linux/arm64
linux/arm linux/arm/v7
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
+9 -27
View File
@@ -1,52 +1,34 @@
version: "2" version: "2"
linters: linters:
enable: enable:
- errcheck
- errname - errname
- errorlint - errorlint
- exhaustive - exhaustive
- goprintffuncname - gosec
- govet
- ineffassign
- misspell - misspell
- mnd - mnd
- tagliatelle - modernize
- staticcheck
- tagalign
- testpackage - testpackage
- thelper - thelper
- tparallel - tparallel
- unconvert - unconvert
- unused
- wrapcheck - wrapcheck
- wsl - wsl_v5
disable:
- gochecknoglobals
settings:
gosec:
excludes:
- G204
tagliatelle:
case:
rules:
json: snake
yaml: snake
exclusions: exclusions:
generated: lax generated: lax
presets: presets:
- comments
- common-false-positives - common-false-positives
- legacy
- std-error-handling
rules: rules:
- linters: - linters:
- gosec - gosec
path: _test\.go path: _test\.go
paths:
- third_party$
- builtin$
- examples$
formatters: formatters:
enable: enable:
- gofumpt - gofumpt
- goimports - goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
+1 -1
View File
@@ -11,7 +11,7 @@ repos:
- id: end-of-file-fixer - id: end-of-file-fixer
- id: check-merge-conflict - id: check-merge-conflict
- repo: https://github.com/golangci/golangci-lint - repo: https://github.com/golangci/golangci-lint
rev: v2.7.2 rev: v2.10.1
hooks: hooks:
- id: golangci-lint - id: golangci-lint
- repo: https://github.com/hadolint/hadolint - repo: https://github.com/hadolint/hadolint
+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.25 AS builder FROM golang:1.26 AS builder
WORKDIR /app WORKDIR /app
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"text/template" "text/template"
"time" "time"
"git.iamthefij.com/iamthefij/slog" "git.iamthefij.com/iamthefij/slog/v2"
) )
var ( var (
-3
View File
@@ -22,7 +22,6 @@ func TestAlertValidate(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -77,7 +76,6 @@ func TestAlertSend(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -123,7 +121,6 @@ func TestAlertBuildTemplate(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"time" "time"
"git.iamthefij.com/iamthefij/slog" "git.iamthefij.com/iamthefij/slog/v2"
"github.com/hashicorp/hcl/v2/hclsimple" "github.com/hashicorp/hcl/v2/hclsimple"
) )
+2 -4
View File
@@ -24,7 +24,6 @@ func TestLoadConfig(t *testing.T) {
{"./test/valid-config.hcl", nil, "Valid config file"}, {"./test/valid-config.hcl", nil, "Valid config file"},
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -51,7 +50,7 @@ func TestDefaultConfig(t *testing.T) {
m.Config{ m.Config{
CheckInterval: 1 * time.Second, CheckInterval: 1 * time.Second,
DefaultAlertAfter: 2, DefaultAlertAfter: 2,
DefaultAlertEvery: Ptr(0), DefaultAlertEvery: new(0),
DefaultAlertDown: []string{"log_command"}, DefaultAlertDown: []string{"log_command"},
}, },
"override defaults", "override defaults",
@@ -61,7 +60,7 @@ func TestDefaultConfig(t *testing.T) {
m.Config{ m.Config{
CheckInterval: 30 * time.Second, CheckInterval: 30 * time.Second,
DefaultAlertAfter: 1, DefaultAlertAfter: 1,
DefaultAlertEvery: Ptr(-1), DefaultAlertEvery: new(-1),
DefaultAlertDown: []string{}, DefaultAlertDown: []string{},
}, },
"default defaults", "default defaults",
@@ -69,7 +68,6 @@ func TestDefaultConfig(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
+2 -2
View File
@@ -1,9 +1,9 @@
module git.iamthefij.com/iamthefij/minitor-go/v2 module git.iamthefij.com/iamthefij/minitor-go/v2
go 1.25.0 go 1.26.0
require ( require (
git.iamthefij.com/iamthefij/slog v1.3.0 git.iamthefij.com/iamthefij/slog/v2 v2.0.1
github.com/hashicorp/hcl/v2 v2.11.1 github.com/hashicorp/hcl/v2 v2.11.1
github.com/prometheus/client_golang v1.23.2 github.com/prometheus/client_golang v1.23.2
) )
+2 -2
View File
@@ -1,5 +1,5 @@
git.iamthefij.com/iamthefij/slog v1.3.0 h1:4Hu5PQvDrW5e3FrTS3q2iIXW0iPvhNY/9qJsqDR3K3I= git.iamthefij.com/iamthefij/slog/v2 v2.0.1 h1:eXf3ga0aMTkm0l6EMYOQpg34S+dQw7cN8o+W1Cg/0C0=
git.iamthefij.com/iamthefij/slog v1.3.0/go.mod h1:1RUj4hcCompZkAxXCRfUX786tb3cM/Zpkn97dGfUfbg= git.iamthefij.com/iamthefij/slog/v2 v2.0.1/go.mod h1:VFjX1e1tfHADyQr2wJBAz0JUQT+K/5FBjzSHgUKOuu8=
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"strings" "strings"
"time" "time"
"git.iamthefij.com/iamthefij/slog" "git.iamthefij.com/iamthefij/slog/v2"
) )
var ( var (
-6
View File
@@ -6,10 +6,6 @@ import (
m "git.iamthefij.com/iamthefij/minitor-go/v2" m "git.iamthefij.com/iamthefij/minitor-go/v2"
) )
func Ptr[T any](v T) *T {
return &v
}
// TestCheckConfig tests the checkConfig function // TestCheckConfig tests the checkConfig function
// It also tests results for potentially invalid configuration. For example, no alerts // It also tests results for potentially invalid configuration. For example, no alerts
func TestCheckMonitors(t *testing.T) { func TestCheckMonitors(t *testing.T) {
@@ -91,7 +87,6 @@ func TestCheckMonitors(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -171,7 +166,6 @@ func TestFirstRunAlerts(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"os/exec" "os/exec"
"time" "time"
"git.iamthefij.com/iamthefij/slog" "git.iamthefij.com/iamthefij/slog/v2"
) )
// Monitor represents a particular periodic check of a command // Monitor represents a particular periodic check of a command
+3 -8
View File
@@ -25,7 +25,6 @@ func TestMonitorValidate(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -103,7 +102,6 @@ func TestMonitorGetAlertNames(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -175,7 +173,6 @@ func TestMonitorFailureAlertAfter(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -204,15 +201,14 @@ func TestMonitorFailureAlertEvery(t *testing.T) {
}{ }{
{m.Monitor{ShellCommand: "false", AlertAfter: 1}, []bool{true}, "No AlertEvery set"}, // Defaults to true because AlertAfter and AlertEvery default to nil {m.Monitor{ShellCommand: "false", AlertAfter: 1}, []bool{true}, "No AlertEvery set"}, // Defaults to true because AlertAfter and AlertEvery default to nil
// Alert first time only, after 1 // Alert first time only, after 1
{m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: Ptr(0)}, []bool{true, false, false}, "Alert first time only after 1"}, {m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: new(0)}, []bool{true, false, false}, "Alert first time only after 1"},
// Alert every time, after 1 // Alert every time, after 1
{m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: Ptr(1)}, []bool{true, true, true}, "Alert every time after 1"}, {m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: new(1)}, []bool{true, true, true}, "Alert every time after 1"},
// Alert every other time, after 1 // Alert every other time, after 1
{m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: Ptr(2)}, []bool{true, false, true, false}, "Alert every other time after 1"}, {m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: new(2)}, []bool{true, false, true, false}, "Alert every other time after 1"},
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -301,7 +297,6 @@ func TestMonitorCheck(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -24,7 +24,6 @@ func TestUtilEqualSliceString(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(fmt.Sprintf("%v %v", c.a, c.b), func(t *testing.T) { t.Run(fmt.Sprintf("%v %v", c.a, c.b), func(t *testing.T) {
t.Parallel() t.Parallel()