Skip to content

Commit

Permalink
Enhancement: update build scripts
Browse files Browse the repository at this point in the history
* add Tasks(generate, test) to Taskfile
* improve taskfile output
* update .goreleaser
* add test action
* update release action name
  • Loading branch information
rugwirobaker committed Oct 3, 2020
1 parent 4979e56 commit 4fa9efd
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: publish artifacts
name: release
on:
push:
tags:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14

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

- name: Restore Cache
uses: actions/cache@preview
id: cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test
env:
GOPROXY: "https://proxy.golang.org"
CODECOV_TOKEN: ${{ secrets.SuperSecret }}
run: |
go test -race -coverprofile=coverage.out -covermode=atomic ./...
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
Expand Down
35 changes: 30 additions & 5 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ version: '3'

dotenv: ['.env']

output: prefixed

silent: true

tasks:
default:
desc: Default task
cmds:
- task: run

build:
desc: Build the application
deps: [generate]
cmds:
- echo "compiling binary..."
- CGO_ENABLED=0 go build -ldflags="{{.LDFLAGS}}" -o bin/helmes ./cmd/helmes
Expand All @@ -14,14 +25,28 @@ tasks:
sh: date -u +%Y-%m-%d-%H:%M:%S-%Z
LDFLAGS: "-X github.com/rugwirobaker/helmes.version={{.VERSION}} -X github.com/rugwirobaker/helmes.buildDate={{.DATE}}"

run:
deps: [build]
generate:
desc: Generate code
cmds:
- ./bin/helmes

- go generate ./...
image:
desc: Build the application container images
cmds:
- docker build --network host -t helmes:{{.GIT_COMMIT}} .
vars:
GIT_COMMIT:
sh: git rev-parse --short HEAD
sh: git rev-parse --short HEAD

run:
desc: Start the application
deps: [build]
cmds:
- ./bin/helmes

test:
desc: Run unit tests
deps: [generate]
cmds:
- go generate ./...
- go test -race -covermode=atomic ./...

0 comments on commit 4fa9efd

Please sign in to comment.