👷 Updated CI/CD configs by Makefile

This commit is contained in:
Maxim Lebedev 2022-02-02 00:51:53 +05:00
parent 8655ce36bf
commit af1ebed585
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
3 changed files with 32 additions and 19 deletions

25
Makefile Normal file
View File

@ -0,0 +1,25 @@
SHELL:=/bin/bash
PROJECT_NAME=indieauth
VERSION=$(shell cat VERSION)
GO_BUILD_ENV=CGO_ENABLED=0 GOOS=linux GOARCH=amd64
GO_FILES=$(shell go list ./... | grep -v /vendor/)
build:
$(GO_BUILD_ENV) go build .
run:
go run .
clean:
go clean
test:
go test -race -cover ./...
dep:
go mod download
lint:
golangci-lint run
.PHONY: build run clean test dep lint

View File

@ -8,17 +8,17 @@ steps:
volumes: volumes:
- name: deps - name: deps
path: /go path: /go
commands: commands:
- go test -v -cover -race ./... - make test
- name: build - name: build
image: golang image: golang
volumes: volumes:
- name: deps - name: deps
path: /go path: /go
commands: commands:
- go build -ldflags "-extldflags '-static'" -o ./indieauth ./cmd/indieauth - make build
depends_on: depends_on:
- test - test
volumes: volumes:
- name: deps - name: deps
temp: {} temp: {}

View File

@ -17,12 +17,11 @@ before_script:
stages: stages:
- test - test
- build - build
- deploy
test: test:
stage: test stage: test
before_script: before_script:
- go get gotest.tools/gotestsum - go install gotest.tools/gotestsum@latest
script: script:
- gotestsum --junitfile report.xml --format testname - gotestsum --junitfile report.xml --format testname
artifacts: artifacts:
@ -33,7 +32,7 @@ test:
cover: cover:
stage: test stage: test
before_script: before_script:
- go get github.com/t-yuki/gocover-cobertura - go install github.com/t-yuki/gocover-cobertura@latest
script: script:
- go test -coverprofile=coverage.txt -covermode count $REPO_NAME/... - go test -coverprofile=coverage.txt -covermode count $REPO_NAME/...
- gocover-cobertura < coverage.txt > coverage.xml - gocover-cobertura < coverage.txt > coverage.xml
@ -44,18 +43,7 @@ cover:
build: build:
stage: build stage: build
script: script:
- go build -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/indieauth $REPO_NAME/cmd/indieauth - make build
artifacts: artifacts:
paths: paths:
- indieauth - indieauth
pages:
image: alpine:latest
stage: deploy
script:
- mv website public
artifacts:
paths:
- public
only:
- master