Skip to content

Commit

Permalink
Adopt go-makefile-maker
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuckal777 committed Apr 15, 2024
1 parent 95bc1e0 commit 7ba4ea6
Show file tree
Hide file tree
Showing 19 changed files with 684 additions and 125 deletions.
57 changes: 57 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"extends": [
"config:base",
"default:pinDigestsDisabled",
"mergeConfidence:all-badges",
"docker:disable"
],
"assignees": [
"Nuckal777",
"SuperSandro2000"
],
"commitMessageAction": "Renovate: Update",
"constraints": {
"go": "1.22"
},
"dependencyDashboardOSVVulnerabilitySummary": "all",
"osvVulnerabilityAlerts": true,
"postUpdateOptions": [
"gomodTidy",
"gomodUpdateImportPaths"
],
"packageRules": [
{
"matchPackageNames": [
"golang"
],
"allowedVersions": "1.22.x"
},
{
"matchPackagePatterns": [
"^github\\.com\\/sapcc\\/.*"
],
"automerge": true,
"groupName": "github.com/sapcc"
},
{
"excludePackagePatterns": [
"^github\\.com\\/sapcc\\/.*"
],
"matchPackagePatterns": [
".*"
],
"groupName": "External dependencies"
},
{
"matchPackagePrefixes": [
"k8s.io/"
],
"allowedVersions": "0.28.x"
}
],
"prHourlyLimit": 0,
"schedule": [
"before 8am on Friday"
],
"semanticCommits": "disabled"
}
42 changes: 42 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
################################################################################
# This file is AUTOGENERATED with <https://github.com/sapcc/go-makefile-maker> #
# Edit Makefile.maker.yaml instead. #
################################################################################

name: Checks
"on":
push:
branches:
- master
pull_request:
branches:
- '*'
permissions:
checks: write
contents: read
jobs:
checks:
name: Checks
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
check-latest: true
go-version: 1.22.2
- name: Dependency Licenses Review
run: make check-dependency-licenses
- name: Run govulncheck
uses: golang/govulncheck-action@v1
- name: Check for spelling errors
uses: reviewdog/action-misspell@v1
with:
exclude: ./vendor/*
fail_on_error: true
github_token: ${{ secrets.GITHUB_TOKEN }}
ignore: importas
reporter: github-check
- name: Check if source code files have license header
run: make check-license-headers
52 changes: 52 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
################################################################################
# This file is AUTOGENERATED with <https://github.com/sapcc/go-makefile-maker> #
# Edit Makefile.maker.yaml instead. #
################################################################################

name: CI
"on":
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
branches:
- '*'
paths-ignore:
- '**.md'
permissions:
contents: read
jobs:
buildAndLint:
name: Build & Lint
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
check-latest: true
go-version: 1.22.2
- name: Build all binaries
run: make build-all
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
test:
name: Test
needs:
- buildAndLint
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
check-latest: true
go-version: 1.22.2
- name: Run tests and generate coverage report
run: make build/cover.out
40 changes: 40 additions & 0 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
################################################################################
# This file is AUTOGENERATED with <https://github.com/sapcc/go-makefile-maker> #
# Edit Makefile.maker.yaml instead. #
################################################################################

name: CodeQL
"on":
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: '00 07 * * 1'
permissions:
actions: read
contents: read
security-events: write
jobs:
analyze:
name: CodeQL
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
check-latest: true
go-version: 1.22.2
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: go
queries: security-extended
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ _testmain.go
*.test
*.prof

build/*
kubernetes-eventexporter
154 changes: 154 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
################################################################################
# This file is AUTOGENERATED with <https://github.com/sapcc/go-makefile-maker> #
# Edit Makefile.maker.yaml instead. #
################################################################################

run:
timeout: 3m # 1m by default
modules-download-mode: vendor

output:
# Do not print lines of code with issue.
print-issued-lines: false

issues:
exclude:
# It is idiomatic Go to reuse the name 'err' with ':=' for subsequent errors.
# Ref: https://go.dev/doc/effective_go#redeclaration
- 'declaration of "err" shadows declaration at'
exclude-rules:
- path: _test\.go
linters:
- bodyclose
- dupl
# '0' disables the following options.
max-issues-per-linter: 0
max-same-issues: 0

linters-settings:
copyloopvar:
ignore-alias: true
dupl:
# Tokens count to trigger issue, 150 by default.
threshold: 100
errcheck:
# Report about assignment of errors to blank identifier.
check-blank: true
# Report about not checking of errors in type assertions.
check-type-assertions: true
forbidigo:
forbid:
# ioutil package has been deprecated: https://github.com/golang/go/issues/42026
- ^ioutil\..*$
# Using http.DefaultServeMux is discouraged because it's a global variable that some packages silently and magically add handlers to (esp. net/http/pprof).
# Applications wishing to use http.ServeMux should obtain local instances through http.NewServeMux() instead of using the global default instance.
- ^http\.DefaultServeMux$
- ^http\.Handle(?:Func)?$
goconst:
ignore-tests: true
min-occurrences: 5
gocritic:
enabled-checks:
- boolExprSimplify
- builtinShadow
- emptyStringTest
- evalOrder
- httpNoBody
- importShadow
- initClause
- methodExprCall
- paramTypeCombine
- preferFilepathJoin
- ptrToRefParam
- redundantSprint
- returnAfterHttpError
- stringConcatSimplify
- timeExprSimplify
- truncateCmp
- typeAssertChain
- typeUnparen
- unnamedResult
- unnecessaryBlock
- unnecessaryDefer
- weakCond
- yodaStyleExpr
goimports:
# Put local imports after 3rd-party packages.
local-prefixes: github.com/sapcc/kubernetes-eventexporter
gosec:
excludes:
# gosec wants us to set a short ReadHeaderTimeout to avoid Slowloris attacks, but doing so would expose us to Keep-Alive race conditions (see https://iximiuz.com/en/posts/reverse-proxy-http-keep-alive-and-502s/)
- G112
# created file permissions are restricted by umask if necessary
- G306
govet:
enable-all: true
disable:
- fieldalignment
nolintlint:
require-specific: true
stylecheck:
dot-import-whitelist:
- github.com/onsi/ginkgo/v2
- github.com/onsi/gomega
usestdlibvars:
constant-kind: true
crypto-hash: true
default-rpc-path: true
http-method: true
http-status-code: true
os-dev-null: true
sql-isolation-level: true
syslog-priority: true
time-weekday: true
time-month: true
time-layout: true
tls-signature-scheme: true
whitespace:
# Enforce newlines (or comments) after multi-line function signatures.
multi-func: true

linters:
# We use 'disable-all' and enable linters explicitly so that a newer version
# does not introduce new linters unexpectedly.
disable-all: true
enable:
- bodyclose
- containedctx
- copyloopvar
- dupl
- dupword
- durationcheck
- errcheck
- errname
- errorlint
- forbidigo
- ginkgolinter
- gocheckcompilerdirectives
- goconst
- gocritic
- gofmt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- intrange
- misspell
- nilerr
- noctx
- nolintlint
- nosprintfhostport
- perfsprint
- predeclared
- rowserrcheck
- sqlclosecheck
- staticcheck
- stylecheck
- tenv
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- whitespace
4 changes: 4 additions & 0 deletions .license-scan-overrides.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"name": "github.com/chzyer/logex", "licenceType": "MIT"}
{"name": "github.com/hashicorp/vault/api/auth/approle", "licenceType": "MPL-2.0"}
{"name": "github.com/jpillora/longestcommon", "licenceType": "MIT"}
{"name": "github.com/spdx/tools-golang", "licenceTextOverrideFile": "vendor/github.com/spdx/tools-golang/LICENSE.code"}
11 changes: 11 additions & 0 deletions .license-scan-rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"allowlist": [
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"ISC",
"MIT",
"MPL-2.0",
"Unlicense"
]
}
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ FROM golang:1.22 AS builder
WORKDIR /go/src/github.com/sapcc/kuberntes-eventexporter
ADD go.mod go.sum ./
RUN go mod download
ADD cache/main.go .
RUN CGO_ENABLED=0 go build -v -o /dev/null
ADD . .
RUN go test -v .
RUN CGO_ENABLED=0 go build -v -o /kubernetes-eventexporter
Expand Down
Loading

0 comments on commit 7ba4ea6

Please sign in to comment.