Skip to content

Commit

Permalink
Add skeleton app (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleyvega committed Feb 12, 2021
1 parent 6ab2af8 commit b314c28
Show file tree
Hide file tree
Showing 10 changed files with 666 additions and 0 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---

name: Go

"on":
push:
branches: [main]
pull_request:
branches: [main, develop]

jobs:

build-linux:
name: Linux build
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.15', '1.14']
env:
GO_VER: ${{ matrix.go }}
steps:

- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
id: go

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

- name: Get dependencies
run: make deps

- name: Build
run: make build

- name: Tests
run: make test

- name: Lint
run: make lint

- name: Vet
run: make vet

- name: Run Gosec Security Scanner
uses: securego/[email protected]
env:
GOROOT: /usr/local/go
GOTOOLDIR: /usr/local/go/pkg/tool/linux_amd64
with:
args: ./...
if: env.GO_VER == '1.15'

build-macos:
name: MacOS build
runs-on: macos-latest
strategy:
matrix:
go: ['1.15', '1.14']
steps:

- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
id: go

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

- name: Get dependencies
run: make deps

- name: Build
run: make build

- name: Tests
run: make test

- name: Lint
run: make lint

- name: Vet
run: make vet

build-windows:
name: Windows Build
runs-on: windows-latest
strategy:
matrix:
go: ['1.15', '1.14']
steps:

- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
id: go

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

- name: Get dependencies
run: make deps

- name: Build
run: make build

- name: Tests
run: make test

- name: Lint
run: make lint

- name: Vet
run: make vet
134 changes: 134 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
---

name: Release

"on":
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, e.g. v1.0, v20.15.10

jobs:

release-linux:
name: Linux release
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: "1.15"
id: go

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

- name: Get dependencies
run: make deps

- name: Tests
run: make test

- name: Lint
run: make lint

- name: Vet
run: make vet

- name: Set release version
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Build
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: make release-linux

- name: Release
uses: softprops/action-gh-release@v1
with:
files: build/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release-macos:
name: MacOS release
runs-on: macos-latest
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: "1.15"
id: go

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

- name: Get dependencies
run: make deps

- name: Tests
run: make test

- name: Lint
run: make lint

- name: Vet
run: make vet

- name: Set release version
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Build
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: make release-macos

- name: Release
uses: softprops/action-gh-release@v1
with:
files: build/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release-windows:
name: Windows release
runs-on: windows-latest
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: "1.15"
id: go

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

- name: Get dependencies
run: make deps

- name: Tests
run: make test

- name: Lint
run: make lint

- name: Vet
run: make vet

- name: Set release version
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- name: Build
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: make release-windows

- name: Release
uses: softprops/action-gh-release@v1
with:
files: build/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---

name: YAML lint

"on":
pull_request:
branches: [develop, main]

jobs:

yamllint:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: yaml-lint
uses: ibiqlik/action-yamllint@v3
with:
config_data: |
extends: default
rules:
line-length:
max: 160
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.bak
*.tmp

build
102 changes: 102 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Makefile

ifeq ($(CI),)
# Not in CI
VERSION := dev-$(USER)
VERSION_HASH := $(shell git rev-parse HEAD | cut -b1-8)
else
# In CI
ifneq ($(RELEASE_VERSION),)
VERSION := $(RELEASE_VERSION)
else
# No tag, so make one
VERSION := $(shell git describe --tags 2>/dev/null)
endif
VERSION_HASH := $(shell echo "$(GITHUB_SHA)" | cut -b1-8)
endif

GO_FLAGS := -ldflags "-X main.Version=$(VERSION) -X main.VersionHash=$(VERSION_HASH)"

.PHONY: all
default: deps build test lint vet

.PHONY: coverage
coverage:
@go test -covermode=count -coverprofile="coverage.txt" ./...
@go tool cover -func="coverage.txt"

.PHONY: coveragehtml
coveragehtml: coverage
@go tool cover -html=coverage.txt -o coverage.html

.PHONY: deps
deps:
@go get -t -d ./...

.PHONY: gosec
gosec:
@gosec ./...

.PHONY: mocks
mocks:
@go generate ./...

.PHONY: build
build:
@mkdir -p build
@go build $(GO_FLAGS) -o build/liqbot ./cmd/liqbot

.PHONY: install
install:
@go install $(GO_FLAGS) ./cmd/liqbot

.PHONY: release-linux
release-linux:
@mkdir -p build
@env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -v -o build/liqbot-linux-amd64 $(GO_FLAGS) ./cmd/liqbot
@cd build && zip liqbot-linux-amd64.zip liqbot-linux-amd64

.PHONY: release-macos
release-macos:
@mkdir -p build
@env GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -v -o build/liqbot-darwin-amd64 $(GO_FLAGS) ./cmd/liqbot
@cd build && zip liqbot-darwin-amd64.zip liqbot-darwin-amd64

.PHONY: release-windows
release-windows:
@env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build -v -o build/liqbot-amd64.exe $(GO_FLAGS) ./cmd/liqbot
@cd build && 7z a -tzip liqbot-windows-amd64.zip liqbot-amd64.exe

.PHONY: lint
lint:
@go install golang.org/x/lint/golint
@outputfile="$$(mktemp)" ; \
go list ./... | xargs golint 2>&1 | \
sed -e "s#^$$GOPATH/src/##" | tee "$$outputfile" ; \
lines="$$(wc -l <"$$outputfile")" ; \
rm -f "$$outputfile" ; \
exit "$$lines"

.PHONY: race
race: ## Run data race detector
@env CGO_ENABLED=1 go test -race ./...

.PHONY: retest
retest: ## Force re-run of all tests
@go test -count=1 ./...

.PHONY: staticcheck
staticcheck: ## Run statick analysis checks
@staticcheck ./...

.PHONY: test
test: ## Run tests
@go test ./...

.PHONY: vet
vet: deps
@go vet ./...

.PHONY: clean
clean:
@rm -rf ./build ./cmd/liqbot/liqbot
Loading

0 comments on commit b314c28

Please sign in to comment.