Skip to content

Commit

Permalink
workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
LinCrayon committed Sep 16, 2024
1 parent 21c6730 commit 77a4684
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 1 deletion.
63 changes: 63 additions & 0 deletions .github/workflow/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI
on:
push:
branches:
- main
pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.19

- name: Check out code
uses: actions/checkout@v1

- name: Lint Go Code
run: |
go install golang.org/x/lint/golint@latest
export PATH="$PATH:$HOME/go/bin"
make lint

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.19

- name: Check out code
uses: actions/checkout@v1

- name: Run Unit tests.
run: make test-coverage

- name: Upload Coverage report to CodeCov
uses: codecov/[email protected]
with:
token: ${{secrets.CODECOV_TOKEN}}
file: ./coverage.txt

build:
name: Build
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.19

- name: Check out code
uses: actions/checkout@v1

- name: Build
run: make build
1 change: 0 additions & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
PROJECT_NAME := "github.com/LinCrayon/gin-gorm-oj"
PKG := "$(PROJECT_NAME)"
PKG_LIST := $(shell go list ${PKG}/...)
GO_FILES := $(shell find . -name '*.go' | grep -v _test.go)

.PHONY: all dep lint vet test test-coverage build clean

all: build

dep: ## Get the dependencies
@go mod download

lint: ## Lint Golang files
@go install golang.org/x/lint/golint@latest
@golint -set_exit_status ${PKG_LIST}

vet: ## Run go vet
@go vet ${PKG_LIST}

test: ## Run unittests
@go test -short ${PKG_LIST}

test-coverage: ## Run tests with coverage
@go test -short -coverprofile cover.out -covermode=atomic ${PKG_LIST}
@cat cover.out >> coverage.txt

build: dep ## Build the binary file
@go get $(PROJECT_NAME)
@go build -i -o build/main $(PKG)

clean: ## Remove previous build
@rm -f ./build

help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

0 comments on commit 77a4684

Please sign in to comment.