Feat: add workflows
This commit is contained in:
29
.gitea/workflows/test.yml
Normal file
29
.gitea/workflows/test.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
name: Go test
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
run-go-vet:
|
||||
runs-on: imgbuilder
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Run go vet
|
||||
run: go vet
|
||||
run-go-test:
|
||||
needs: run-go-vet
|
||||
runs-on: imgbuilder
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Run go test
|
||||
run: make test-ci
|
||||
cleanup-go-test:
|
||||
needs: run-go-test
|
||||
runs-on: imgbuilder
|
||||
if: always()
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Run make docker-clean
|
||||
run: make docker-clean
|
||||
26
Makefile
26
Makefile
@@ -1,4 +1,5 @@
|
||||
.PHONY: all swagger docker install test
|
||||
.PHONY: all swagger install postgres test test-ci \
|
||||
docker docker-quiet docker-clean
|
||||
|
||||
SWAG ?= go run github.com/swaggo/swag/cmd/swag@v1.16.4
|
||||
DOCKER ?= docker
|
||||
@@ -9,22 +10,33 @@ TARGET := backend
|
||||
|
||||
all: swagger docker
|
||||
|
||||
swagger:
|
||||
$(SWAG) fmt
|
||||
$(SWAG) init -o docs -g cmds/serve.go -pdl 1
|
||||
|
||||
docker: $(TARGET)
|
||||
$(DOCKER) compose up -d --force-recreate --build backend
|
||||
|
||||
$(TARGET): $(SOURCE)
|
||||
$(GO_ENV) go build -o $@
|
||||
|
||||
install:
|
||||
$(GO_ENV) go install
|
||||
|
||||
test:
|
||||
go test -v ./tests -count=1
|
||||
go test -v ./tests -count=1 -failfast
|
||||
|
||||
postgres:
|
||||
$(DOCKER) compose exec postgres psql \
|
||||
postgres://go2025:go2025@postgres:5432/go2025?sslmode=disable
|
||||
|
||||
swagger:
|
||||
$(SWAG) fmt
|
||||
$(SWAG) init -o docs -g cmds/serve.go -pdl 1
|
||||
test-ci: docker-quiet test docker-clean
|
||||
|
||||
$(TARGET): $(SOURCE)
|
||||
$(GO_ENV) go build -o $@
|
||||
docker-quiet: $(TARGET)
|
||||
$(DOCKER) compose -p go2025-backend up -d \
|
||||
--force-recreate --build backend \
|
||||
--quiet-build --quiet-pull
|
||||
sleep 5
|
||||
|
||||
docker-clean:
|
||||
$(DOCKER) compose -p go2025-backend down -v --remove-orphans
|
||||
|
||||
@@ -64,6 +64,7 @@ services:
|
||||
context: .
|
||||
env_file:
|
||||
- path: ./.env
|
||||
required: false
|
||||
ports:
|
||||
- 8080:8080
|
||||
volumes:
|
||||
|
||||
Reference in New Issue
Block a user