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
91 changes: 63 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,94 @@ on:

jobs:
build:
name: Continous Integration
name: Build & Test
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Check out code
uses: actions/checkout@v6

- name: Set up Go 1.21.x
uses: actions/setup-go@v2
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ^1.21
id: go

- name: Build
shell: bash
run: |
make build
run: go build -v ./...

- name: Test
shell: bash
run: |
make test
run: go list ./... | grep -v /test | xargs -I% go test % -v -cover -race

scans:
name: Checks, Lints and Scans
lint:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Check out code
uses: actions/checkout@v6

- name: Set up Go 1.21.x
uses: actions/setup-go@v2
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ^1.21
id: go

- name: Format Check
shell: bash
run: |
make format-check
RESULT=$(gofmt -l .)
if [ -n "$RESULT" ]; then
echo "Files need formatting:"
echo "$RESULT"
exit 1
fi

- name: Lint
shell: bash
run: |
make lint-docker
uses: golangci/golangci-lint-action@v9

security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6

- name: Run Gosec Security Scanner
uses: securego/gosec@master
uses: securego/gosec@v2.22.11
with:
# let the report trigger content trigger a failure using the GitHub Security features.
args: '-no-fail -fmt sarif -out results.sarif -exclude-dir internal -exclude-dir vendor -severity high ./...'

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v1
uses: github/codeql-action/upload-sarif@v4
with:
# path to SARIF file relative to the root of the repository
sarif_file: results.sarif

tag:
name: Auto Tag Release
needs: [build, lint, security]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out code
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Extract version from CHANGELOG.md
id: version
run: |
VERSION=$(grep -oP '## \[\K[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md | head -1)
echo "version=v${VERSION}" >> "$GITHUB_OUTPUT"

- name: Check if tag already exists
id: check
run: |
if git rev-parse "${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

- name: Create and push tag
if: steps.check.outputs.exists == 'false'
run: |
git tag "${{ steps.version.outputs.version }}"
git push origin "${{ steps.version.outputs.version }}"
11 changes: 11 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "2"

run:
timeout: 600s

linters:
exclusions:
paths:
- test
- internal
- _mock.go
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2026-02-11

### Changed

- Fork from vmware/vmware-go-kcl-v2
- Update module path to github.com/ODudek/go-kcl
- Bump minimum Go version to 1.21
- Upgrade AWS SDK and dependencies
31 changes: 12 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ help: ## - Show this help message
@printf "\033[32m\xE2\x9c\x93 usage: make [target]\n\n\033[0m"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: up
up: ## - start docker compose
@ cd _support/docker && docker-compose -f docker-compose.yml up

.PHONY: build-common
build-common: ## - execute build common tasks clean and mod tidy
@ go version
Expand All @@ -22,32 +18,29 @@ build: build-common ## - build a debug binary to the current platform (windows,

.PHONY: format-check
format-check: ## - check files format using gofmt
@ ./_support/scripts/ci.sh fmtCheck

.PHONY: format-check
@RESULT=$$(gofmt -l .); \
if [ -n "$$RESULT" ]; then \
echo "You need to run \"gofmt -w ./\" to fix your formatting."; \
echo "$$RESULT"; \
exit 1; \
fi

.PHONY: format
format: ## - apply golang file format using gofmt
@ ./_support/scripts/ci.sh format
@ gofmt -w ./

.PHONY: test
test: build-common ## - execute go test command for unit and mocked tests
@ ./_support/scripts/ci.sh unitTest
@ go list ./... | grep -v /test | xargs -I% go test % -v -cover -race

.PHONY: integration-test
integration-test: ## - execute go test command for integration tests (aws credentials needed)
@ go test -v -cover -race ./test

.PHONY: scan
scan: ## - execute static code analysis
@ ./_support/scripts/ci.sh scan

.PHONY: local-scan
local-scan: ## - execute static code analysis locally
@ ./_support/scripts/ci.sh localScan
@ gosec -fmt=sarif -out=results.sarif -exclude-dir=internal -exclude-dir=vendor -severity=high ./...

.PHONY: lint
lint: ## - runs golangci-lint
@ ./_support/scripts/ci.sh lint

.PHONY: lint-docker
lint-docker: ## - runs golangci-lint with docker container
@ ./_support/scripts/ci.sh lintDocker
@ golangci-lint run --timeout=600s --verbose
128 changes: 0 additions & 128 deletions _support/scripts/ci.sh

This file was deleted.

4 changes: 2 additions & 2 deletions clientlibrary/checkpoint/dynamodb-checkpointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const (
)

var (
NoLeaseOwnerErr = errors.New("no LeaseOwner in checkpoints table")
ErrNoLeaseOwner = errors.New("no LeaseOwner in checkpoints table")
)

// DynamoCheckpoint implements the Checkpoint interface using DynamoDB as a backend
Expand Down Expand Up @@ -350,7 +350,7 @@ func (checkpointer *DynamoCheckpoint) GetLeaseOwner(shardID string) (string, err
assignedVar, assignedToOk := currentCheckpoint[LeaseOwnerKey]

if !assignedToOk {
return "", NoLeaseOwnerErr
return "", ErrNoLeaseOwner
}

return assignedVar.(*types.AttributeValueMemberS).Value, nil
Expand Down
Loading