From 36891e06f4c5f9feb9dc354b26ccdd3890dcc8a3 Mon Sep 17 00:00:00 2001 From: Romain Bertrand Date: Mon, 8 Dec 2025 09:56:54 +0100 Subject: [PATCH] chore: setup CI --- .gitea/workflows/ci.yml | 56 +++++++++++++++++++++++++++++++++++++++++ .golangci.yml | 13 ++++++++++ Makefile | 29 +++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 .gitea/workflows/ci.yml create mode 100644 .golangci.yml create mode 100644 Makefile diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..a582277 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,56 @@ +name: CI + +on: + pull_request: + push: + branches: [ main ] + +jobs: + lint: + runs-on: codeberg-small + steps: + - name: Checkout code + uses: https://github.com/actions/checkout@v4 + + - name: Set up Go + uses: https://github.com/actions/setup-go@v5 + with: + go-version: '1.21' + cache: true + + - name: Install golangci-lint + run: | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.6.2 + + - name: Run golangci-lint + run: golangci-lint run --timeout 5m + + build: + runs-on: codeberg-small + steps: + - name: Checkout code + uses: https://github.com/actions/checkout@v4 + + - name: Set up Go + uses: https://github.com/actions/setup-go@v5 + with: + go-version: '1.21' + cache: true + + - name: Build application + run: make build + + test: + runs-on: codeberg-small + steps: + - name: Checkout code + uses: https://github.com/actions/checkout@v4 + + - name: Set up Go + uses: https://github.com/actions/setup-go@v5 + with: + go-version: '1.21' + cache: true + + - name: Run tests + run: go test -v -race ./... diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..bc67641 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,13 @@ +version: "2" + +run: + timeout: 5m + tests: true + +linters: + enable: + - errcheck + - govet + - ineffassign + - staticcheck + - unused diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..57e8eda --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +.PHONY: help build run test clean lint lint-fix + +help: + @echo "Available commands:" + @echo " make build - Build the application" + @echo " make run - Run the application" + @echo " make test - Run tests" + @echo " make lint - Run golangci-lint" + @echo " make lint-fix - Run golangci-lint with auto-fix" + @echo " make clean - Clean build artifacts" + +build: + go build -o bin/fgj . + +run: + go run . + +test: + go test -v -race ./... + +lint: + golangci-lint run ./... + +lint-fix: + golangci-lint run --fix ./... + +clean: + rm -rf bin/ + go clean