Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dependencies 1 #45

Merged
merged 8 commits into from
Feb 13, 2024
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
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
labels:
- "skip-release-notes"
- "dependencies"
open-pull-requests-limit: 20 # setting a higher number so we can bundle all the weekly updates together
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
labels:
- "skip-release-notes"
- "dependencies"
open-pull-requests-limit: 10 # setting a higher number so we can bundle all the weekly updates together
31 changes: 31 additions & 0 deletions .github/workflows/check-manifest-generation-diff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check for diff after manifest and generated targets

on:
pull_request: {}

jobs:
diff-check-manifests:
name: Check for diff
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: '${{ github.workspace }}/go.mod'
- name: Restore Go cache
uses: actions/cache@v4
with:
path: /home/runner/work/_temp/_github_home/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: go mod tidy
run: |
go mod tidy
- name: Check for diff
run: |
git diff --exit-code --shortstat
56 changes: 39 additions & 17 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,54 @@ on:
push:
tags:
- 'v*'

permissions:
contents: read
env:
REGISTRY: ghcr.io
DOCKERFILE: ${{ github.workspace }}/goreleaser.dockerfile

jobs:
build-push:
release:
permissions:
contents: 'write'
id-token: 'write'
pull-requests: 'read'
repository-projects: 'write'
packages: 'write'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Prepare
id: prep
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: '${{ github.workspace }}/go.mod'
- name: Cache go-build and mod
uses: actions/cache@v3
VERSION=sha-${GITHUB_SHA::8}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF/refs\/tags\//}
fi
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=VERSION::${VERSION}
- name: Generate manifests
run: |
mkdir -p output
kustomize build ./config/default > ./output/install.yaml
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
path: |
~/.cache/go-build/
~/go/pkg/mod/
key: go-${{ hashFiles('go.sum') }}
restore-keys: |
go-
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Helm
uses: azure/setup-helm@v3
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3.2.0
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --release-notes=docs/release_notes/${{ env.RELEASE_VERSION }}.md --skip-validate
args: release --release-notes=docs/release_notes/${{ steps.prep.outputs.VERSION }}.md --skip-validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build and release the helm charts
run: |
helm registry login ghcr.io -u skarlso -p ${{ secrets.GITHUB_TOKEN }}
helm package --version ${{ steps.prep.outputs.VERSION }} --app-version ${{ steps.prep.outputs.VERSION }} ./crd-bootstrap
helm push ${{ github.event.repository.name }}-${{ steps.prep.outputs.VERSION }}.tgz oci://ghcr.io/skarlso/helm
38 changes: 38 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: test and lint

on:
pull_request:
paths-ignore:
- 'CODE_OF_CONDUCT.md'
- 'README.md'
- 'Contributing.md'
workflow_call:

push:
branches:
- main

permissions:
contents: read # for actions/checkout to fetch code

jobs:
run-test-suite:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: '${{ github.workspace }}/go.mod'
- name: Restore Go cache
uses: actions/cache@v4
with:
path: /home/runner/work/_temp/_github_home/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run lint
run: make lint
- name: Run tests
run: make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
crd-to-yaml
dist/
.idea
bin
cty
wasm/wasm
154 changes: 154 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
run:
go: "1.21"
timeout: 10m
tests: false
allow-parallel-runners: true
issues-exit-code: 2
skip-dirs:
- "hack"

linters:
enable-all: true
disable:
# We are working on it
- wrapcheck
- depguard
# Logical next step
- forcetypeassert # Priority: that can lead to serious crashes.
- exportloopref
- goerr113 # Do not define dynamic errors with Errorf.
- varnamelen # m, d, p < These are not so meaningful variables.
- testpackage # Blackbox testing is preffered.
- funlen # Break long functions.
- gomnd # Give constant values a name with constants.
- ireturn # Accept interface, return concrate.
- nestif # Some nexted if statements are 8 or 9 deep.
- dupl # Check code duplications.
- cyclop # Complex functions are not good.
- gochecknoinits # Init functions cause an import to have side effects,
# and side effects are hard to test,
# reduce readability and increase the complexity of code.
- containedctx # Struct should not contain context, action does.
- nilnil # A function should return either something valuable
# or an error, but both value and error as nil is
# useless. Like when I call it, why is it nil? Tell me
# in an error why.
- bodyclose
- unparam
- nonamedreturns # Either named return, or use simply `return`.

# Opinionated (we may want to keep it disabled)
- gochecknoglobals
- lll
- paralleltest
- tagliatelle
- wsl
- interfacebloat


# Disabled with reason
- dogsled
- exhaustruct # Doesn't really make sense.
- exhaustive # Doesn't really make sense.
- logrlint # Doesn't really make sense.
- goimports # acts weirdly, dci handles imports anyway

# Disabled because of generics in go 1.18
- contextcheck
- rowserrcheck
- sqlclosecheck
- wastedassign

# Deprecated
- deadcode
- exhaustivestruct
- golint
- ifshort
- interfacer
- maligned
- scopelint
- structcheck
- varcheck
- gci
- nosnakecase

linters-settings:
gci:
sections:
- standard
- blank
- dot
- default
- prefix(github.com/open-component-model/ocm)
custom-order: true
staticcheck:
go: "1.21"
stylecheck:
go: "1.21"
funlen:
lines: 110
statements: 60
cyclop:
max-complexity: 45
skip-tests: true
gocognit:
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
min-complexity: 45
nolintlint:
allow-unused: false
require-explanation: true
require-specific: false
varnamelen:
ignore-names:
- err
- wg
- id
govet:
check-shadowing: true
lll:
line-length: 120
gosec:
exclude-generated: true

issues:
exclude:
- composites
exclude-rules:
- path: cmds/
linters:
- forbidigo
- text: "should not use dot imports|don't use an underscore in package name"
linters:
- golint
- source: "https://"
linters:
- lll
- text: "shadow: declaration of \"err\""
linters:
- govet
- text: "shadow: declaration of \"ok\""
linters:
- govet
- path: _test\.go
linters:
- goerr113
- gocyclo
- errcheck
- gosec
- dupl
- funlen
- scopelint
- text: "Spec.DeepCopyInto undefined"
linters:
- typecheck
- text: "G601: Implicit memory aliasing in for loop"
# Ignored cos why not, that was the request.
linters:
- gosec
- source: "// .* #\\d+"
linters:
- godox
- path: ignore/.*\.go
linters:
- dupword
30 changes: 27 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ BUILDDIR := bin
# VERSION defines the project version for the bundle.
VERSION ?= 0.0.1

# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

# List the GOOS and GOARCH to build
GO_LDFLAGS_STATIC="-s -w $(CTIMEVAR) -extldflags -static"

Expand All @@ -30,14 +47,21 @@ bootstrap: ## Installs necessary third party components

##@ Testing

test: lint ## Lints Krok then runs all tests
test: ## Runs all tests
go test -count=1 ./...

clean: ## Runs go clean
go clean -i

lint: ## Runs golangci-lint on crd
golangci-lint run ./...
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.56.1

golangci-lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT): $(LOCALBIN)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_LINT_VERSION)

lint: golangci-lint ## Run golangci-lint.
$(GOLANGCI_LINT) run

##@ Utilities

Expand Down
Loading