Skip to content

Commit ebb8f38

Browse files
committed
Add CI workflows
1 parent fa9357b commit ebb8f38

File tree

3 files changed

+146
-0
lines changed

3 files changed

+146
-0
lines changed

.github/workflows/build.yaml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: build
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write # For creating releases.
11+
12+
# Cancel in-progress runs for pull requests when developers push
13+
# additional changes
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
26+
- uses: actions/setup-go@v3
27+
with:
28+
go-version: "~1.19"
29+
30+
- name: Get Go cache paths
31+
id: go-cache-paths
32+
run: |
33+
echo "::set-output name=go-build::$(go env GOCACHE)"
34+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
35+
36+
- name: Go build cache
37+
uses: actions/cache@v3
38+
with:
39+
path: ${{ steps.go-cache-paths.outputs.go-build }}
40+
key: ${{ runner.os }}-release-go-build-${{ hashFiles('**/go.sum') }}
41+
42+
- name: Go mod cache
43+
uses: actions/cache@v3
44+
with:
45+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
46+
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
47+
48+
- run: make build
49+
50+
- uses: softprops/action-gh-release@v1
51+
with:
52+
draft: true
53+
files: ./bin/*

.github/workflows/lint.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
# Cancel in-progress runs for pull requests when developers push
11+
# additional changes
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
15+
16+
jobs:
17+
lint:
18+
timeout-minutes: 5
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
25+
- uses: actions/setup-go@v3
26+
with:
27+
go-version: "~1.19"
28+
- name: golangci-lint
29+
uses: golangci/[email protected]
30+
with:
31+
version: v1.48.0

.github/workflows/test.yaml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
# Cancel in-progress runs for pull requests when developers push
11+
# additional changes
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
15+
16+
jobs:
17+
test:
18+
name: "test/go"
19+
runs-on: ${{ matrix.os }}
20+
timeout-minutes: 20
21+
strategy:
22+
matrix:
23+
os:
24+
- ubuntu-latest
25+
- macos-latest
26+
- windows-2022
27+
steps:
28+
- uses: actions/checkout@v3
29+
with:
30+
fetch-depth: 0
31+
32+
- uses: actions/setup-go@v3
33+
with:
34+
go-version: "~1.19"
35+
36+
- name: Echo Go Cache Paths
37+
id: go-cache-paths
38+
run: |
39+
echo "::set-output name=go-build::$(go env GOCACHE)"
40+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
41+
42+
- name: Go Build Cache
43+
uses: actions/cache@v3
44+
with:
45+
path: ${{ steps.go-cache-paths.outputs.go-build }}
46+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go') }}
47+
48+
- name: Go Mod Cache
49+
uses: actions/cache@v3
50+
with:
51+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
52+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
53+
54+
- name: Install gotestsum
55+
uses: jaxxstorm/[email protected]
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
with:
59+
repo: gotestyourself/gotestsum
60+
tag: v1.7.0
61+
62+
- run: make test

0 commit comments

Comments
 (0)