diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..9f233b8 --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.24" + + - name: Format + run: | + make format + git diff --exit-code + + - name: Lint + uses: golangci/golangci-lint-action@v4 + with: + version: v1.56 + args: --timeout=5m + + - name: Test + run: make test diff --git a/.woodpecker/ci.yml b/.woodpecker/ci.yml new file mode 100644 index 0000000..4353088 --- /dev/null +++ b/.woodpecker/ci.yml @@ -0,0 +1,23 @@ +when: + event: + - push + - pull_request + branch: + - main + +steps: + format: + image: golang:1.24 + commands: + - make format + - git diff --exit-code # Fail if files were changed + + lint: + image: golang:1.24 + commands: + - make ci-lint + + test: + image: golang:1.24 + commands: + - make test diff --git a/Makefile b/Makefile index 290c9e5..0951519 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,8 @@ 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 @@ -78,13 +80,21 @@ run: ### Executes the project build locally .PHONY: format format: ### Executes the formatting pipeline on the project $(info: Make: Format) - @bash scripts/format.sh + @go fmt ./... + @go mod tidy + +.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 ./... .PHONY: lint lint: ### Check the project for errors $(info: Make: Lint) - @bash scripts/lint.sh + @golangci-lint run ./... .PHONY: test test: ### Runs the test suite - @bash scripts/test.sh + $(info: Make: Test) + CGO_ENABLED=1 go test ${TEST_OPTIONS} -timeout=${TEST_TIMEOUT} ${SOURCE_FILES}