Compare commits

...

2 Commits

Author SHA1 Message Date
5f450e206f Add ci/cd commit validation and a makefile to do common operations
All checks were successful
Validate the build / validate-build (push) Successful in 1m1s
2025-05-20 22:33:48 +02:00
eae48cf9ae Reduce go mod version compatibility to 1.23 2025-05-20 22:01:37 +02:00
4 changed files with 77 additions and 1 deletions

View File

@ -0,0 +1,40 @@
name: Validate the build
run-name: ${{ gitea.actor }} is validating
on: [push]
jobs:
validate-build:
runs-on: ubuntu-latest
container:
image: node:current-alpine
steps:
- name: Install dependencies
run: |
echo "https://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
apk update
apk add --no-cache git make bash go
GOBIN=/usr/local/bin go install mvdan.cc/gofumpt@latest
export "PATH=$PATH:/root/go/bin"
echo "---------------------"
echo "Go version:"
go version
echo "---------------------"
- name: Check out repository code
uses: actions/checkout@v4
- name: Fetch dependencies
run: |
go mod download
- name: Validate the code and formatting
run: |
make validate
- name: Run tests
run: |
make test

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/reports
/bin

34
Makefile Normal file
View File

@ -0,0 +1,34 @@
BINARY_DIR = bin
BINARIES = $(patsubst cmd/%/,%,$(wildcard cmd/*/))
.PHONY: all build test coverage validate clean purge $(BINARIES)
all: build
build: $(BINARIES)
$(BINARY_DIR):
mkdir -p $(BINARY_DIR)
$(BINARIES): %: $(BINARY_DIR)
go build -o $(BINARY_DIR)/$@ ./cmd/$@/
test:
go test ./... -cover
coverage:
mkdir -p reports/
go test -coverprofile=reports/coverage.out ./... && go tool cover -html=reports/coverage.out
validate:
@test -z "$(shell gofumpt -l .)" && echo "No files need formatting" || (echo "Incorrect formatting in:"; gofumpt -l .; exit 1)
go vet ./...
clean:
rm -rf $(BINARY_DIR)
go clean
purge: clean
rm -rf reports

2
go.mod
View File

@ -1,6 +1,6 @@
module git.omicron.one/playground/cryptography
go 1.24.2
go 1.23.0
require (
github.com/stretchr/testify v1.10.0