Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go_version: ['1.25']
go_version: ['1.26']
os: [ubuntu-latest, windows-latest, macos-latest]
env:
OS: ${{ matrix.os }}
Expand All @@ -39,7 +39,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.5.0
version: v2.9.0
args: --timeout=30m

- name: Test
Expand All @@ -51,10 +51,10 @@ jobs:
run: make build

- name: Code coverage with codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v6
with:
env_vars: OS,GO
file: ./coverage.out
files: ./coverage.out
flags: unittests
fail_ci_if_error: false
verbose: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ jobs:
- name: Set up Go (latest version)
uses: actions/setup-go@v6
with:
go-version: '>=1.25.0'
go-version: '>=1.26.0'
check-latest: true

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -72,7 +72,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@v4

# ℹ️ 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
Expand All @@ -85,6 +85,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ~1.25
go-version: ~1.26

- name: Check configuration snippets in documentation
run: go run ./config/checkdoc -r docs/content -i changelog.md
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ~1.25
go-version: ~1.26
check-latest: true

- name: Set up QEMU
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
version: '~> v2'
args: release --clean --config .goreleaser-docker-only.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ~1.25
go-version: ~1.26

- name: Check configuration snippets in documentation
run: go run ./config/checkdoc -r docs/content -i changelog.md
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ~1.25
go-version: ~1.26
check-latest: true

- name: Set up QEMU
Expand All @@ -47,7 +47,7 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ~1.25
go-version: ~1.26
check-latest: true

- name: Set up QEMU
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
version: '~> v2'
args: release --clean --snapshot --config .goreleaser-snapshot.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Makefile for resticprofile
#
GOCMD=go
GOCMD=$(shell command -v go)
GOBUILD=$(GOCMD) build
GOINSTALL=$(GOCMD) install
GORUN=$(GOCMD) run
Expand Down Expand Up @@ -75,7 +75,7 @@ all: prepare_test test build
.PHONY: all verify prepare_test prepare_build install clean ramdisk rest-server nightly toc syslog checkdoc

verify: ## Verify go installation
ifeq ($(wildcard $(GOPATH)/.),)
ifeq ($(GOPATH),)
@echo "GOPATH not found, please check your go installation"
exit 1
endif
Expand All @@ -94,11 +94,11 @@ $(GOBIN)/github-markdown-toc.go: verify $(GOBIN)/eget

$(GOBIN)/mockery: verify $(GOBIN)/eget
@echo "[*] $@"
"$(GOBIN)/eget" vektra/mockery --tag v3.5.5 --upgrade-only --to '$(GOBIN)'
"$(GOBIN)/eget" vektra/mockery --tag v3.7.0 --upgrade-only --to '$(GOBIN)'

$(GOBIN)/golangci-lint: verify $(GOBIN)/eget
$(GOBIN)/golangci-lint-v2: verify $(GOBIN)/eget
@echo "[*] $@"
"$(GOBIN)/eget" golangci/golangci-lint --tag v2.5.0 --asset=tar.gz --upgrade-only --to '$(GOBIN)'
"$(GOBIN)/eget" golangci/golangci-lint --tag v2.9.0 --asset=tar.gz --upgrade-only --to '$(GOBIN)/golangci-lint-v2'
Comment thread
creativeprojects marked this conversation as resolved.

$(GOBIN)/hugo: $(GOBIN)/eget
@echo "[*] $@"
Expand Down Expand Up @@ -321,20 +321,20 @@ checklinks: $(GOBIN)/muffet ## Check for broken links in the documentation site
http://127.0.0.1:1313/resticprofile/

.PHONY: lint
lint: $(GOBIN)/golangci-lint ## Run golangci-lint
lint: $(GOBIN)/golangci-lint-v2 ## Run golangci-lint
@echo "[*] $@"
GOOS=darwin golangci-lint run
GOOS=linux golangci-lint run
GOOS=windows golangci-lint run
GOOS=darwin $(GOBIN)/golangci-lint-v2 run
GOOS=linux $(GOBIN)/golangci-lint-v2 run
GOOS=windows $(GOBIN)/golangci-lint-v2 run

.PHONY: fix
fix: $(GOBIN)/golangci-lint ## Run golangci-lint with --fix
fix: $(GOBIN)/golangci-lint-v2 ## Run golangci-lint with --fix
@echo "[*] $@"
$(GOCMD) mod tidy
$(GOCMD) fix ./...
GOOS=darwin golangci-lint run --fix
GOOS=linux golangci-lint run --fix
GOOS=windows golangci-lint run --fix
GOOS=darwin $(GOBIN)/golangci-lint-v2 run --fix
GOOS=linux $(GOBIN)/golangci-lint-v2 run --fix
GOOS=windows $(GOBIN)/golangci-lint-v2 run --fix

.PHONY: deploy-current
deploy-current: build-linux build-pi
Expand Down
2 changes: 1 addition & 1 deletion complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func TestCompleter(t *testing.T) {
prefix := fmt.Sprintf("%s.", profile)
completions := completer.Complete(newArgs("--config", DevConfig, prefix))

var expected []string
expected := make([]string, 0, len(commands)+1)
for _, commandName := range commands {
expected = append(expected, prefix+commandName)
}
Expand Down
2 changes: 1 addition & 1 deletion darwin/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func generateTreeOfSchedules(event *calendar.Event) []*treeElement {
}
subTree := getElements(values, currentTypeValue)
if len(*currentElements) > 0 {
newCurrentElements := make([]*treeElement, 0)
newCurrentElements := make([]*treeElement, 0, len(*currentElements)*len(subTree))
for _, element := range *currentElements {
// add each new element to the child of all the current elements
element.subElements = make([]*treeElement, len(subTree))
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/creativeprojects/resticprofile

go 1.25.8
go 1.26.1

require (
github.com/Masterminds/semver/v3 v3.4.0
Expand Down
2 changes: 1 addition & 1 deletion schedule/handler_crond_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestCreateReadDeleteCrondSchedules(t *testing.T) {
}).(*HandlerCrond)
handler.fs = afero.NewMemMapFs()

expectedJobs := []Config{}
expectedJobs := make([]Config, 0, len(testCases))
for _, testCase := range testCases {
expectedJobs = append(expectedJobs, testCase.job)

Expand Down
2 changes: 1 addition & 1 deletion schedule/handler_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (h *HandlerLaunchd) DisplayJobStatus(job *Config) error {
}

func (h *HandlerLaunchd) Scheduled(profileName string) ([]Config, error) {
jobs := make([]Config, 0)
jobs := make([]Config, 0, 10)
if profileName == "" {
profileName = "*"
} else {
Expand Down
2 changes: 1 addition & 1 deletion schedule/handler_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestReadingLaunchdScheduled(t *testing.T) {
handler := NewHandler(SchedulerLaunchd{}).(*HandlerLaunchd)
handler.fs = afero.NewMemMapFs()

expectedJobs := []Config{}
expectedJobs := make([]Config, 0, len(testCases))
for _, testCase := range testCases {
expectedJobs = append(expectedJobs, testCase.job)

Expand Down
2 changes: 1 addition & 1 deletion schedule/handler_systemd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestReadingSystemdScheduled(t *testing.T) {

handler := NewHandler(SchedulerSystemd{}).(*HandlerSystemd)

expectedJobs := []Config{}
expectedJobs := make([]Config, 0, len(testCases))
for _, testCase := range testCases {
job := testCase.job
err := handler.CreateJob(&job, testCase.schedules, PermissionFromConfig(schedulePermission))
Expand Down
4 changes: 2 additions & 2 deletions schtasks/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ func convertMonths(input []int) Months {
func convertDaysOfMonth(input []int) DaysOfMonth {
if len(input) == 0 {
all := make([]int, 31)
for i := 1; i <= 31; i++ {
all[i-1] = i
for i := 0; i <= 30; i++ {
all[i] = i + 1
}
return DaysOfMonth{all}
}
Expand Down
56 changes: 56 additions & 0 deletions schtasks/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,59 @@ func TestCompileDifferences(t *testing.T) {
assert.ElementsMatch(t, testItem.unique, uniques, "unique set of durations between triggers")
}
}

func TestConvertDaysOfMonth(t *testing.T) {
allDays := make([]int, 31)
for i := 0; i <= 30; i++ {
allDays[i] = i + 1
}

testData := []struct {
description string
input []int
expected DaysOfMonth
}{
{
description: "empty input returns all 31 days",
input: []int{},
expected: DaysOfMonth{Day: allDays},
},
{
description: "nil input returns all 31 days",
input: nil,
expected: DaysOfMonth{Day: allDays},
},
{
description: "single day",
input: []int{15},
expected: DaysOfMonth{Day: []int{15}},
},
{
description: "first day of month",
input: []int{1},
expected: DaysOfMonth{Day: []int{1}},
},
{
description: "last day of month",
input: []int{31},
expected: DaysOfMonth{Day: []int{31}},
},
{
description: "multiple specific days",
input: []int{1, 15, 28},
expected: DaysOfMonth{Day: []int{1, 15, 28}},
},
{
description: "consecutive days",
input: []int{10, 11, 12, 13},
expected: DaysOfMonth{Day: []int{10, 11, 12, 13}},
},
}

for _, testItem := range testData {
t.Run(testItem.description, func(t *testing.T) {
result := convertDaysOfMonth(testItem.input)
assert.Equal(t, testItem.expected, result)
})
}
}
4 changes: 3 additions & 1 deletion util/maybe/duration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/creativeprojects/resticprofile/util/maybe"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestDurationDecoder(t *testing.T) {
Expand Down Expand Up @@ -67,7 +68,8 @@ func TestDurationDecoder(t *testing.T) {

decoded, err := decoder(from, to, fixture.source)
if fe, ok := fixture.expected.(error); ok {
assert.Equal(t, fe, err)
require.Error(t, err)
assert.Equal(t, fe.Error(), err.Error())
Comment thread
creativeprojects marked this conversation as resolved.
} else {
assert.NoError(t, err)
assert.Equal(t, fixture.expected, decoded)
Expand Down
3 changes: 1 addition & 2 deletions wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,8 @@ func (r *resticWrapper) runShellCommands(commands []string, commandsType, comman

// runFinalShellCommands runs all shell commands defined in "run-finally".
func (r *resticWrapper) runFinalShellCommands(command string, fail error) {
var commands []string

profileCommands, sectionCommands := r.profile.GetRunShellCommandsSections(command)
commands := make([]string, 0, len(sectionCommands.RunFinally)+len(profileCommands.RunFinally))
commands = append(commands, sectionCommands.RunFinally...)
commands = append(commands, profileCommands.RunFinally...)

Expand Down
Loading