From 19455619ab716a8103758be480ebd7cceec1f82e Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Tue, 7 Apr 2026 18:22:33 +0200 Subject: [PATCH 1/4] ci: migrate from Woodpecker CI to Forgejo Actions Replace Woodpecker CI pipeline with Forgejo Actions workflows using ci-base container image. Simplify Makefile to match current project conventions and add ldflags to goreleaser for smaller binaries. --- .github/workflows/ci.yml | 58 +++++++++++++++++ .github/workflows/release.yml | 27 ++++++++ .goreleaser.yml | 15 ++--- .woodpecker/ci.yml | 23 ------- .woodpecker/release.yml | 12 ---- Makefile | 114 ++++++++++------------------------ 6 files changed, 124 insertions(+), 125 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .woodpecker/ci.yml delete mode 100644 .woodpecker/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9e13b63 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,58 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + format: + runs-on: docker + container: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0 + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + - run: make format + - run: git diff --exit-code + + goreleaser-lint: + runs-on: docker + container: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0 + steps: + - uses: actions/checkout@v6 + - uses: actions/goreleaser-action@v6.4.0 + with: + args: check + + lint: + runs-on: docker + container: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0 + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + - run: make ci-lint + + test: + runs-on: docker + container: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0 + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + - run: make test + + build: + runs-on: docker + container: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0 + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + - run: make build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..cb39b93 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Release + +on: + push: + tags: ["v*"] + +jobs: + release: + runs-on: docker + container: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0 + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Install Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + + - name: Run GoReleaser + uses: actions/goreleaser-action@v6.4.0 + with: + args: release --clean + env: + GORELEASER_FORCE_TOKEN: gitea + GITEA_TOKEN: ${{ secrets.FORGEJO_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 4a4aa9f..366c843 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,23 +1,16 @@ version: 2 -gitea_urls: - api: https://git.nakama.town/api/v1 - download: https://git.nakama.town - before: hooks: - go mod tidy -git: - ignore_tags: - - "{{ if not .IsNightly }}*-rc*{{ end }}" - builds: - binary: dharma main: ./cmd/dharma env: - CGO_ENABLED=0 - - GIN_MODE=release + ldflags: + - -s -w tags: - netgo - osusergo @@ -106,3 +99,7 @@ changelog: release: prerelease: auto + +gitea_urls: + api: https://git.nakama.town/api/v1 + download: https://git.nakama.town diff --git a/.woodpecker/ci.yml b/.woodpecker/ci.yml deleted file mode 100644 index 0dac5da..0000000 --- a/.woodpecker/ci.yml +++ /dev/null @@ -1,23 +0,0 @@ -when: - event: - - push - - pull_request - branch: - - main - -steps: - format: - image: golang:1.24.2 - commands: - - make format - - git diff --exit-code # Fail if files were changed - - lint: - image: golang:1.24.2 - commands: - - make ci-lint - - test: - image: golang:1.24.2 - commands: - - make test diff --git a/.woodpecker/release.yml b/.woodpecker/release.yml deleted file mode 100644 index 446162e..0000000 --- a/.woodpecker/release.yml +++ /dev/null @@ -1,12 +0,0 @@ -when: - - event: tag - branch: main - -steps: - - name: Release - image: goreleaser/goreleaser:v2.9.0 - environment: - GITEA_TOKEN: - from_secret: GITEA_TOKEN - commands: - - goreleaser release --clean diff --git a/Makefile b/Makefile index f97f7ec..8ce3129 100644 --- a/Makefile +++ b/Makefile @@ -1,100 +1,52 @@ PROJECT_NAME := dharma - -SOURCE_FILES ?=./... - -TEST_OPTIONS ?= -v -failfast -race -bench=. -benchtime=100000x -cover -coverprofile=coverage.out -TEST_TIMEOUT ?=1m - -GOLANGCI_LINT_VERSION ?= v1.64.5 - -CLEAN_OPTIONS ?=-modcache -testcache - CGO_ENABLED := 0 -BUILDS_PATH := ./dist -FROM_MAKEFILE := y +DIST_PATH := ./dist +TEST_OPTIONS := -v -failfast -race -cover -CONTAINERFILE_NAME := Containerfile -CONTAINER_ALPINE_VERSION := 3.20 -CONTAINER_SOURCE_URL := "https://git.nakama.town/fmartingr/${PROJECT_NAME}" -CONTAINER_MAINTAINER := "Felipe Martin " -CONTAINER_BIN_NAME := ${PROJECT_NAME} +GOLANGCI_LINT_VERSION := v1.64.5 -BUILDX_PLATFORMS := linux/amd64,linux/arm64,linux/arm/v7 +.DEFAULT_GOAL := help -export PROJECT_NAME -export FROM_MAKEFILE - -export CGO_ENABLED - -export SOURCE_FILES -export TEST_OPTIONS -export TEST_TIMEOUT -export BUILDS_PATH - -export CONTAINERFILE_NAME -export CONTAINER_ALPINE_VERSION -export CONTAINER_SOURCE_URL -export CONTAINER_MAINTAINER -export CONTAINER_BIN_NAME - -export BUILDX_PLATFORMS - -.PHONY: all -all: help - -# this is godly -# https://news.ycombinator.com/item?id=11939200 +## help: Display this help message .PHONY: help -help: ### this screen. Keep it first target to be default -ifeq ($(UNAME), Linux) - @grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \ - awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' -else - @# this is not tested, but prepared in advance for you, Mac drivers - @awk -F ':.*###' '$$0 ~ FS {printf "%15s%s\n", $$1 ":", $$2}' \ - $(MAKEFILE_LIST) | grep -v '@awk' | sort -endif - -.PHONY: clean -clean: ### clean test cache, build files - $(info: Make: Clean) - @rm -rf ${BUILDS_PATH} - @go clean ${CLEAN_OPTIONS} - @-docker buildx rm ${PROJECT_NAME}_builder +help: + @echo "Available targets:" + @grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / /' | sort +## build: Build project using goreleaser (snapshot) .PHONY: build -build: clean ### builds the project for the setup os/arch combinations - $(info: Make: Build) - @goreleaser --clean --snapshot - -.PHONY: quick-run -quick-run: ### Executes the project using golang - CGO_ENABLED=${CGO_ENABLED} go run ./cmd/${PROJECT_NAME}/*.go +build: + goreleaser build --snapshot --clean +## run: Run the project directly .PHONY: run -run: ### Executes the project build locally - @make build - ${BUILDS_PATH}/${PROJECT_NAME} +run: + go run ./cmd/$(PROJECT_NAME) +## format: Format code and tidy modules .PHONY: format -format: ### Executes the formatting pipeline on the project - $(info: Make: Format) - @go fmt ./... - @go mod tidy +format: + go fmt ./... + go mod tidy +## ci-lint: Run golangci-lint (installs if missing) .PHONY: ci-lint -ci-lint: ### Check the project for errors - $(info: Make: Lint) - @go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} - @golangci-lint run ./... +ci-lint: + @which golangci-lint > /dev/null 2>&1 || go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) + golangci-lint run ./... +## lint: Run linters .PHONY: lint -lint: ### Check the project for errors - $(info: Make: Lint) - @golangci-lint run ./... +lint: ci-lint +## test: Run tests with coverage .PHONY: test -test: ### Runs the test suite - $(info: Make: Test) - CGO_ENABLED=1 go test ${TEST_OPTIONS} -timeout=${TEST_TIMEOUT} ${SOURCE_FILES} +test: + CGO_ENABLED=1 go test $(TEST_OPTIONS) -timeout 1m ./... + +## clean: Remove build artifacts +.PHONY: clean +clean: + rm -rf $(DIST_PATH) + go clean -cache -- 2.52.0 From 3b0d2a1f254d52b7e5dc80cff478b7712e7286ea Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Tue, 7 Apr 2026 18:27:16 +0200 Subject: [PATCH 2/4] fix(ci): use master as the default branch in CI workflow --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e13b63..cb40900 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [main] + branches: [master] pull_request: - branches: [main] + branches: [master] jobs: format: -- 2.52.0 From b58f4d729a6f5d1077562cb1de428437affd09c8 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Tue, 7 Apr 2026 18:46:06 +0200 Subject: [PATCH 3/4] fix(ci): align goreleaser config with project conventions Fix deprecated format_overrides.format, simplify archive naming, add explicit gitea release config, and match changelog format. --- .goreleaser.yml | 50 +++++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 366c843..5febeca 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -33,14 +33,14 @@ builds: goarch: arm64 archives: - - id: dharma - name_template: >- - {{ .ProjectName }}_ - {{- if eq .Os "darwin" }}Darwin{{- else if eq .Os "linux" }}Linux{{- else if eq .Os "windows" }}Windows{{- else }}{{ .Os }}{{ end }}_ - {{- if eq .Arch "amd64" }}x86_64{{- else if eq .Arch "arm64" }}aarch64{{- else }}{{ .Arch }}{{ end }}_{{ .Version }} + - formats: + - tar.gz + - zip format_overrides: - goos: windows - format: zip + formats: + - zip + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" nfpms: - maintainer: Felipe Martin @@ -54,50 +54,38 @@ nfpms: upx: - enabled: true - ids: - - dharma goos: [linux, darwin] goarch: [amd64, arm, arm64] goarm: ["7"] checksum: - name_template: "checksums.txt" - -snapshot: - version_template: "{{ incpatch .Version }}-next" + name_template: checksums.txt changelog: sort: asc groups: - title: Features - regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' + regexp: "^.*feat.*$" order: 0 - - title: "Fixes" - regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$' + - title: Bug Fixes + regexp: "^.*fix.*$" order: 1 - - title: "Performance" - regexp: '^.*?perf(\([[:word:]]+\))??!?:.+$' + - title: Performance + regexp: "^.*perf.*$" order: 2 - - title: API - regexp: '^.*?api(\([[:word:]]+\))??!?:.+$' - order: 3 - title: Documentation - regexp: '^.*?docs(\([[:word:]]+\))??!?:.+$' + regexp: "^.*docs.*$" + order: 3 + - title: CI/CD + regexp: "^.*ci.*$" order: 4 - - title: "Tests" - regexp: '^.*?test(\([[:word:]]+\))??!?:.+$' - order: 5 - - title: CI and Delivery - regexp: '^.*?ci(\([[:word:]]+\))??!?:.+$' - order: 6 - title: Others order: 999 - filters: - exclude: - - "^deps:" - - "^chore\\(deps\\):" release: + gitea: + owner: fmartingr + name: dharma prerelease: auto gitea_urls: -- 2.52.0 From fd995542e2d6f31a9a6ba1f4e12e47458234c667 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Wed, 8 Apr 2026 09:58:16 +0200 Subject: [PATCH 4/4] fix(tests): align PrettyReporter test with current output format The reporter outputs "Errors found:" for internal errors, not "Internal Errors:". Update the test assertion to match. --- pkg/reporter/reporter_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/reporter/reporter_test.go b/pkg/reporter/reporter_test.go index dd4722e..26cb4df 100644 --- a/pkg/reporter/reporter_test.go +++ b/pkg/reporter/reporter_test.go @@ -182,7 +182,7 @@ func TestPrettyReporter_Generate(t *testing.T) { if !strings.Contains(output, "Website scan report for") { t.Error("Output doesn't contain report title") } - if !strings.Contains(output, "Internal Errors:") { + if !strings.Contains(output, "Errors found:") { t.Error("Output doesn't contain errors section") } -- 2.52.0