Skip to content

Commit c854018

Browse files
committed
Github CI and makefile
1 parent 2fafa77 commit c854018

File tree

5 files changed

+91
-15
lines changed

5 files changed

+91
-15
lines changed

.github/workflows/gommon.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- '**.go'
9+
- 'go.*'
10+
- '_fixture/**'
11+
- '.github/**'
12+
- 'codecov.yml'
13+
pull_request:
14+
branches:
15+
- master
16+
paths:
17+
- '**.go'
18+
- 'go.*'
19+
- '_fixture/**'
20+
- '.github/**'
21+
- 'codecov.yml'
22+
23+
jobs:
24+
test:
25+
strategy:
26+
matrix:
27+
os: [ubuntu-latest, macos-latest, windows-latest]
28+
# Each major Go release is supported until there are two newer major releases. https://golang.org/doc/devel/release.html#policy
29+
# Echo tests with last four major releases
30+
go: [1.14, 1.15, 1.16, 1.17]
31+
name: ${{ matrix.os }} @ Go ${{ matrix.go }}
32+
runs-on: ${{ matrix.os }}
33+
steps:
34+
- name: Set up Go ${{ matrix.go }}
35+
uses: actions/setup-go@v2
36+
with:
37+
go-version: ${{ matrix.go }}
38+
39+
- name: Checkout Code
40+
uses: actions/checkout@v2
41+
with:
42+
ref: ${{ github.ref }}
43+
44+
- name: Run Tests
45+
run: |
46+
golint -set_exit_status ./...
47+
go test -race --coverprofile=coverage.coverprofile --covermode=atomic ./...
48+
49+
- name: Upload coverage to Codecov
50+
if: success() && matrix.go == 1.17 && matrix.os == 'ubuntu-latest'
51+
uses: codecov/codecov-action@v2
52+
with:
53+
fail_ci_if_error: false

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1+
.DS_Store
2+
coverage.txt
3+
_test
14
vendor
5+
.idea
6+
*.iml
7+
*.out
8+
.vscode

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
PKG := "github.com/labstack/gommon"
2+
PKG_LIST := $(shell go list ${PKG}/...)
3+
4+
.DEFAULT_GOAL := check
5+
check: lint vet race ## Check project
6+
7+
init:
8+
@go get -u golang.org/x/lint/golint
9+
10+
lint: ## Lint the files
11+
@golint -set_exit_status ${PKG_LIST}
12+
13+
vet: ## Vet the files
14+
@go vet ${PKG_LIST}
15+
16+
test: ## Run tests
17+
@go test -short ${PKG_LIST}
18+
19+
race: ## Run tests with data race detector
20+
@go test -race ${PKG_LIST}
21+
22+
benchmark: ## Run benchmarks
23+
@go test -run="-" -bench=".*" ${PKG_LIST}
24+
25+
help: ## Display this help screen
26+
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
27+
28+
goversion ?= "1.15"
29+
test_version: ## Run tests inside Docker with given version (defaults to 1.15 oldest supported). Example: make test_version goversion=1.15
30+
@docker run --rm -it -v $(shell pwd):/project golang:$(goversion) /bin/sh -c "cd /project && make init check"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Gommon [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/labstack/gommon) [![Build Status](http://img.shields.io/travis/labstack/gommon.svg?style=flat-square)](https://travis-ci.org/labstack/gommon) [![Coverage Status](http://img.shields.io/coveralls/labstack/gommon.svg?style=flat-square)](https://coveralls.io/r/labstack/gommon)
1+
# Gommon [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/labstack/gommon) [![Coverage Status](http://img.shields.io/coveralls/labstack/gommon.svg?style=flat-square)](https://coveralls.io/r/labstack/gommon)
22

33
Common packages for Go
44
- [Bytes](https://github.com/labstack/gommon/tree/master/bytes) - Format/parse bytes.

0 commit comments

Comments
 (0)