Skip to content

Commit

Permalink
Build and Test for the CI (#63)
Browse files Browse the repository at this point in the history
Co-authored-by: Zois Pagoulatos <zpagoulatos@hotmail.com>
  • Loading branch information
drpaneas and zoispag committed Oct 10, 2020
1 parent 1b6333b commit a0e68c9
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.go text eol=lf
60 changes: 60 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build

on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:

jobs:
Building:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
steps:
- name: Checkout out source code
uses: actions/checkout@v2.3.3
with:
fetch-depth: 0

- name: Set up Go environment
uses: actions/setup-go@v2.1.3
with:
go-version: 1.15

- name: Cache Go modules
uses: actions/cache@v2.1.1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: make setup
run: |
make setup
- name: make lint
run: |
make lint
- name: make build
run: |
make build
- name: make test
run: |
make test
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: romie ${{ matrix.os }}
path: ${{ github.workspace }}

- name: make run
run: |
make run
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode/
coverage.txt
romie
bin/goreleaser
19 changes: 8 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ export GO111MODULE := on
export GOPROXY = https://proxy.golang.org,direct

# go source files
SRC = $(shell find . -type f -name '*.go')
SRC = $(shell find . -type f -name "*.go")
# The name of the executable (default is current directory name)
TARGET := $(shell echo $${PWD-`pwd`})

.PHONY: all build setup fmt test cover lint ci clean todo run help
.PHONY: all build setup fmt test cover lint clean todo run help

## all: Default target, now is build
all: build

## build: Builds the binary
build:
## build: Builds the binary
build: fmt
@echo "Building..."
@$(GOCMD) build -o ${NAME}

## setup: Runs mod download and generate
setup:
@echo "Downloading tools and dependencies..."
@$(GOCMD) mod download
@$(GOCMD) mod download -x
@$(GOCMD) generate -v ./...

## fmt: Runs go goimports and go fmt
## fmt: Runs go goimports and gofmt
fmt: setup
@echo "Checking the imports..."
@$(GOCMD)imports -w ${SRC}
Expand All @@ -45,17 +45,14 @@ test:
cover: test
@$(GOCMD) tool cover -html=coverage.txt

## lint: Runs golangci-lint (configuration at .golangci.yml) and misspell
## lint: Runs golangci-lint (configuration at .golangci.yml) and misspell
lint: setup
@echo "Running linters..."
@golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 ./...
@misspell ./...

## ci: Runs steup build, test, fmt, lint
ci: setup build test fmt lint

## clean: Runs go clean
clean:
clean:
@echo "Cleaning..."
@$(GOCMD) clean

Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
*/
//go:generate go install github.com/golangci/golangci-lint/cmd/golangci-lint
//go:generate go install github.com/client9/misspell/cmd/misspell
//go:generate go install golang.org/x/tools/cmd/goimports

package main

Expand Down
2 changes: 2 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ import (
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
// Import misspell
_ "github.com/client9/misspell/cmd/misspell"
// import goimports
_ "golang.org/x/tools/cmd/goimports"
)

0 comments on commit a0e68c9

Please sign in to comment.