How to use Github action with golang

Configuration

in .github/workflows/main.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: Build
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.16'
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Lint
run: |
go get -u golang.org/x/lint/golint
make lint
- name: report
run: |
make report
- name: Test
run: |
make test-unit
- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}