Skip to content

Commit 4948e28

Browse files
committed
switch to golang 1.25 and update deps
Signed-off-by: Markus Blaschke <[email protected]>
1 parent 48409d5 commit 4948e28

File tree

19 files changed

+177
-121
lines changed

19 files changed

+177
-121
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 'Setup-Go'
2+
description: 'Setup go with dependencies'
3+
runs:
4+
using: composite
5+
steps:
6+
7+
- uses: actions/setup-go@v6
8+
with:
9+
go-version-file: 'go.mod'
10+
cache-dependency-path: "go.sum"
11+
check-latest: true
12+
13+
- name: GoLang dependencies
14+
shell: bash
15+
run: |
16+
go mod vendor
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: 'Setup-Runner'
2+
description: 'Setup runner'
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Set Swap Space
7+
uses: pierotofy/set-swap-space@fc79b3f67fa8a838184ce84a674ca12238d2c761
8+
with:
9+
swap-size-gb: 12

.github/workflows/build-docker.yaml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,16 @@ jobs:
1111
lint:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v6
1515

16-
- name: Set Swap Space
17-
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
18-
with:
19-
swap-size-gb: 12
16+
- name: Setup runner
17+
uses: ./.github/actions/setup-runner
2018

21-
- uses: actions/setup-go@v5
22-
with:
23-
go-version-file: 'go.mod'
24-
cache-dependency-path: "go.sum"
25-
check-latest: true
19+
- name: Setup go
20+
uses: ./.github/actions/setup-go
2621

2722
- name: Run Golangci lint
28-
uses: golangci/golangci-lint-action@v7
23+
uses: golangci/golangci-lint-action@v9
2924
with:
3025
version: latest
3126
args: --print-resources-usage
@@ -44,18 +39,13 @@ jobs:
4439

4540
runs-on: ubuntu-latest
4641
steps:
47-
- uses: actions/checkout@v4
42+
- uses: actions/checkout@v6
4843

49-
- name: Set Swap Space
50-
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
51-
with:
52-
swap-size-gb: 12
44+
- name: Setup runner
45+
uses: ./.github/actions/setup-runner
5346

54-
- uses: actions/setup-go@v5
55-
with:
56-
go-version-file: 'go.mod'
57-
cache-dependency-path: "go.sum"
58-
check-latest: true
47+
- name: Setup go
48+
uses: ./.github/actions/setup-go
5949

6050
- name: Docker meta
6151
id: docker_meta
@@ -101,3 +91,5 @@ jobs:
10191
push: ${{ inputs.publish }}
10292
tags: ${{ steps.docker_meta.outputs.tags }}
10393
labels: ${{ steps.docker_meta.outputs.labels }}
94+
cache-from: type=gha
95+
cache-to: type=gha,mode=max

.github/workflows/ci-docker.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: "ci/docker"
22

33
on: [pull_request, workflow_dispatch]
44

5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
59
jobs:
610
build:
711
uses: ./.github/workflows/build-docker.yaml

.github/workflows/release-assets.yaml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,34 @@ on:
44
release:
55
types: [created]
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: false
10+
11+
env:
12+
RELEASE_TAG: ${{ github.ref_name }}
13+
714
jobs:
8-
release:
15+
build:
16+
name: "${{ matrix.task }}"
917
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- task: release-assets
1023
steps:
11-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v6
1225

13-
- name: Set Swap Space
14-
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
15-
with:
16-
swap-size-gb: 12
26+
- name: Setup runner
27+
uses: ./.github/actions/setup-runner
1728

18-
- uses: actions/setup-go@v5
19-
with:
20-
go-version-file: 'go.mod'
21-
cache-dependency-path: "go.sum"
22-
check-latest: true
29+
- name: Setup go
30+
uses: ./.github/actions/setup-go
2331

2432
- name: Build
2533
run: |
26-
make release-assets
34+
make "${{ matrix.task }}"
2735
2836
- name: Upload assets to release
2937
uses: svenstaro/upload-release-action@v2
@@ -33,3 +41,4 @@ jobs:
3341
tag: ${{ github.ref }}
3442
overwrite: true
3543
file_glob: true
44+
promote: false

.github/workflows/release-docker.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: "release/docker"
22

33
on:
4+
workflow_dispatch: {}
45
push:
56
branches:
67
- 'main'
@@ -9,6 +10,10 @@ on:
910
tags:
1011
- '*.*.*'
1112

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
1217
jobs:
1318
release:
1419
uses: ./.github/workflows/build-docker.yaml

.github/workflows/schedule-docker.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
schedule:
55
- cron: '45 6 * * 1'
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
711
jobs:
812
schedule:
913
uses: ./.github/workflows/build-docker.yaml

common.logger.go

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,27 @@
11
package main
22

33
import (
4-
"go.uber.org/zap"
5-
"go.uber.org/zap/zapcore"
4+
"os"
5+
6+
"github.com/webdevops/go-common/log/slogger"
67
)
78

89
var (
9-
logger *zap.SugaredLogger
10+
logger *slogger.Logger
1011
)
1112

12-
func initLogger() *zap.SugaredLogger {
13-
var config zap.Config
14-
if Opts.Logger.Development {
15-
config = zap.NewDevelopmentConfig()
16-
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
17-
} else {
18-
config = zap.NewProductionConfig()
19-
}
20-
21-
config.Encoding = "console"
22-
config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
23-
24-
// debug level
25-
if Opts.Logger.Debug {
26-
config.Level = zap.NewAtomicLevelAt(zapcore.DebugLevel)
27-
}
28-
29-
// json log format
30-
if Opts.Logger.Json {
31-
config.Encoding = "json"
32-
33-
// if running in containers, logs already enriched with timestamp by the container runtime
34-
config.EncoderConfig.TimeKey = ""
35-
}
36-
37-
// build logger
38-
log, err := config.Build()
39-
if err != nil {
40-
panic(err)
13+
func initLogger() *slogger.Logger {
14+
loggerOpts := []slogger.LoggerOptionFunc{
15+
slogger.WithLevelText(Opts.Logger.Level),
16+
slogger.WithFormat(slogger.FormatMode(Opts.Logger.Format)),
17+
slogger.WithSourceMode(slogger.SourceMode(Opts.Logger.Source)),
18+
slogger.WithTime(Opts.Logger.Time),
19+
slogger.WithColor(slogger.ColorMode(Opts.Logger.Color)),
4120
}
4221

43-
logger = log.Sugar()
22+
logger = slogger.NewCliLogger(
23+
os.Stderr, loggerOpts...,
24+
)
4425

4526
return logger
4627
}

common.system.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import (
55
)
66

77
func initSystem() {
8-
system.AutoProcMemLimit(logger)
8+
system.AutoProcMemLimit(logger.Logger)
99
}

config/opts.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ type (
99
Opts struct {
1010
// logger
1111
Logger struct {
12-
Debug bool `long:"log.debug" env:"LOG_DEBUG" description:"debug mode"`
13-
Development bool `long:"log.devel" env:"LOG_DEVEL" description:"development mode"`
14-
Json bool `long:"log.json" env:"LOG_JSON" description:"Switch log output to json format"`
12+
Level string `long:"log.level" env:"LOG_LEVEL" description:"Log level" choice:"trace" choice:"debug" choice:"info" choice:"warning" choice:"error" default:"info"` // nolint:staticcheck // multiple choices are ok
13+
Format string `long:"log.format" env:"LOG_FORMAT" description:"Log format" choice:"logfmt" choice:"json" default:"logfmt"` // nolint:staticcheck // multiple choices are ok
14+
Source string `long:"log.source" env:"LOG_SOURCE" description:"Show source for every log message (useful for debugging and bug reports)" choice:"" choice:"short" choice:"file" choice:"full"` // nolint:staticcheck // multiple choices are ok
15+
Color string `long:"log.color" env:"LOG_COLOR" description:"Enable color for logs" choice:"" choice:"auto" choice:"yes" choice:"no"` // nolint:staticcheck // multiple choices are ok
16+
Time bool `long:"log.time" env:"LOG_TIME" description:"Show log time"`
1517
}
1618

1719
Shelly struct {

0 commit comments

Comments
 (0)