ci: migrate from Woodpecker CI to Forgejo Actions #1
7 changed files with 144 additions and 157 deletions
58
.github/workflows/ci.yml
vendored
Normal file
58
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
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
|
||||||
27
.github/workflows/release.yml
vendored
Normal file
27
.github/workflows/release.yml
vendored
Normal file
|
|
@ -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 }}
|
||||||
|
|
@ -1,23 +1,16 @@
|
||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
gitea_urls:
|
|
||||||
api: https://git.nakama.town/api/v1
|
|
||||||
download: https://git.nakama.town
|
|
||||||
|
|
||||||
before:
|
before:
|
||||||
hooks:
|
hooks:
|
||||||
- go mod tidy
|
- go mod tidy
|
||||||
|
|
||||||
git:
|
|
||||||
ignore_tags:
|
|
||||||
- "{{ if not .IsNightly }}*-rc*{{ end }}"
|
|
||||||
|
|
||||||
builds:
|
builds:
|
||||||
- binary: dharma
|
- binary: dharma
|
||||||
main: ./cmd/dharma
|
main: ./cmd/dharma
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
- GIN_MODE=release
|
ldflags:
|
||||||
|
- -s -w
|
||||||
tags:
|
tags:
|
||||||
- netgo
|
- netgo
|
||||||
- osusergo
|
- osusergo
|
||||||
|
|
@ -40,14 +33,14 @@ builds:
|
||||||
goarch: arm64
|
goarch: arm64
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- id: dharma
|
- formats:
|
||||||
name_template: >-
|
- tar.gz
|
||||||
{{ .ProjectName }}_
|
- zip
|
||||||
{{- 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 }}
|
|
||||||
format_overrides:
|
format_overrides:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
format: zip
|
formats:
|
||||||
|
- zip
|
||||||
|
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
|
||||||
|
|
||||||
nfpms:
|
nfpms:
|
||||||
- maintainer: Felipe Martin <me@fmartingr.com>
|
- maintainer: Felipe Martin <me@fmartingr.com>
|
||||||
|
|
@ -61,48 +54,40 @@ nfpms:
|
||||||
|
|
||||||
upx:
|
upx:
|
||||||
- enabled: true
|
- enabled: true
|
||||||
ids:
|
|
||||||
- dharma
|
|
||||||
goos: [linux, darwin]
|
goos: [linux, darwin]
|
||||||
goarch: [amd64, arm, arm64]
|
goarch: [amd64, arm, arm64]
|
||||||
goarm: ["7"]
|
goarm: ["7"]
|
||||||
|
|
||||||
checksum:
|
checksum:
|
||||||
name_template: "checksums.txt"
|
name_template: checksums.txt
|
||||||
|
|
||||||
snapshot:
|
|
||||||
version_template: "{{ incpatch .Version }}-next"
|
|
||||||
|
|
||||||
changelog:
|
changelog:
|
||||||
sort: asc
|
sort: asc
|
||||||
groups:
|
groups:
|
||||||
- title: Features
|
- title: Features
|
||||||
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
|
regexp: "^.*feat.*$"
|
||||||
order: 0
|
order: 0
|
||||||
- title: "Fixes"
|
- title: Bug Fixes
|
||||||
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
|
regexp: "^.*fix.*$"
|
||||||
order: 1
|
order: 1
|
||||||
- title: "Performance"
|
- title: Performance
|
||||||
regexp: '^.*?perf(\([[:word:]]+\))??!?:.+$'
|
regexp: "^.*perf.*$"
|
||||||
order: 2
|
order: 2
|
||||||
- title: API
|
|
||||||
regexp: '^.*?api(\([[:word:]]+\))??!?:.+$'
|
|
||||||
order: 3
|
|
||||||
- title: Documentation
|
- title: Documentation
|
||||||
regexp: '^.*?docs(\([[:word:]]+\))??!?:.+$'
|
regexp: "^.*docs.*$"
|
||||||
|
order: 3
|
||||||
|
- title: CI/CD
|
||||||
|
regexp: "^.*ci.*$"
|
||||||
order: 4
|
order: 4
|
||||||
- title: "Tests"
|
|
||||||
regexp: '^.*?test(\([[:word:]]+\))??!?:.+$'
|
|
||||||
order: 5
|
|
||||||
- title: CI and Delivery
|
|
||||||
regexp: '^.*?ci(\([[:word:]]+\))??!?:.+$'
|
|
||||||
order: 6
|
|
||||||
- title: Others
|
- title: Others
|
||||||
order: 999
|
order: 999
|
||||||
filters:
|
|
||||||
exclude:
|
|
||||||
- "^deps:"
|
|
||||||
- "^chore\\(deps\\):"
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
|
gitea:
|
||||||
|
owner: fmartingr
|
||||||
|
name: dharma
|
||||||
prerelease: auto
|
prerelease: auto
|
||||||
|
|
||||||
|
gitea_urls:
|
||||||
|
api: https://git.nakama.town/api/v1
|
||||||
|
download: https://git.nakama.town
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
114
Makefile
114
Makefile
|
|
@ -1,100 +1,52 @@
|
||||||
PROJECT_NAME := dharma
|
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
|
CGO_ENABLED := 0
|
||||||
|
|
||||||
BUILDS_PATH := ./dist
|
DIST_PATH := ./dist
|
||||||
FROM_MAKEFILE := y
|
TEST_OPTIONS := -v -failfast -race -cover
|
||||||
|
|
||||||
CONTAINERFILE_NAME := Containerfile
|
GOLANGCI_LINT_VERSION := v1.64.5
|
||||||
CONTAINER_ALPINE_VERSION := 3.20
|
|
||||||
CONTAINER_SOURCE_URL := "https://git.nakama.town/fmartingr/${PROJECT_NAME}"
|
|
||||||
CONTAINER_MAINTAINER := "Felipe Martin <me@fmartingr.com>"
|
|
||||||
CONTAINER_BIN_NAME := ${PROJECT_NAME}
|
|
||||||
|
|
||||||
BUILDX_PLATFORMS := linux/amd64,linux/arm64,linux/arm/v7
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
export PROJECT_NAME
|
## help: Display this help message
|
||||||
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
|
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help: ### this screen. Keep it first target to be default
|
help:
|
||||||
ifeq ($(UNAME), Linux)
|
@echo "Available targets:"
|
||||||
@grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
|
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / /' | 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
|
|
||||||
|
|
||||||
|
## build: Build project using goreleaser (snapshot)
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: clean ### builds the project for the setup os/arch combinations
|
build:
|
||||||
$(info: Make: Build)
|
goreleaser build --snapshot --clean
|
||||||
@goreleaser --clean --snapshot
|
|
||||||
|
|
||||||
.PHONY: quick-run
|
|
||||||
quick-run: ### Executes the project using golang
|
|
||||||
CGO_ENABLED=${CGO_ENABLED} go run ./cmd/${PROJECT_NAME}/*.go
|
|
||||||
|
|
||||||
|
## run: Run the project directly
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: ### Executes the project build locally
|
run:
|
||||||
@make build
|
go run ./cmd/$(PROJECT_NAME)
|
||||||
${BUILDS_PATH}/${PROJECT_NAME}
|
|
||||||
|
|
||||||
|
## format: Format code and tidy modules
|
||||||
.PHONY: format
|
.PHONY: format
|
||||||
format: ### Executes the formatting pipeline on the project
|
format:
|
||||||
$(info: Make: Format)
|
go fmt ./...
|
||||||
@go fmt ./...
|
go mod tidy
|
||||||
@go mod tidy
|
|
||||||
|
|
||||||
|
## ci-lint: Run golangci-lint (installs if missing)
|
||||||
.PHONY: ci-lint
|
.PHONY: ci-lint
|
||||||
ci-lint: ### Check the project for errors
|
ci-lint:
|
||||||
$(info: Make: Lint)
|
@which golangci-lint > /dev/null 2>&1 || go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
|
||||||
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
|
golangci-lint run ./...
|
||||||
@golangci-lint run ./...
|
|
||||||
|
|
||||||
|
## lint: Run linters
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint: ### Check the project for errors
|
lint: ci-lint
|
||||||
$(info: Make: Lint)
|
|
||||||
@golangci-lint run ./...
|
|
||||||
|
|
||||||
|
## test: Run tests with coverage
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: ### Runs the test suite
|
test:
|
||||||
$(info: Make: Test)
|
CGO_ENABLED=1 go test $(TEST_OPTIONS) -timeout 1m ./...
|
||||||
CGO_ENABLED=1 go test ${TEST_OPTIONS} -timeout=${TEST_TIMEOUT} ${SOURCE_FILES}
|
|
||||||
|
## clean: Remove build artifacts
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
rm -rf $(DIST_PATH)
|
||||||
|
go clean -cache
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ func TestPrettyReporter_Generate(t *testing.T) {
|
||||||
if !strings.Contains(output, "Website scan report for") {
|
if !strings.Contains(output, "Website scan report for") {
|
||||||
t.Error("Output doesn't contain report title")
|
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")
|
t.Error("Output doesn't contain errors section")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue