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
|
||||
|
||||
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
|
||||
|
|
@ -40,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 <me@fmartingr.com>
|
||||
|
|
@ -61,48 +54,40 @@ 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:
|
||||
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
|
||||
|
||||
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 <me@fmartingr.com>"
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue