Skip to content

Commit 96a09de

Browse files
authored
Merge pull request #4 from mikesep/add-github-action
Add a main GitHub Actions workflow
2 parents dbfb17f + 42c63f1 commit 96a09de

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

.github/workflows/main.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Main
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
10+
jobs:
11+
test:
12+
name: Test and report coverage
13+
runs-on: ubuntu-latest
14+
env:
15+
COVERAGE_DIR: COVERAGE
16+
steps:
17+
- name: Set up Go 1.x
18+
uses: actions/setup-go@v2
19+
with:
20+
go-version: 1.x
21+
22+
- name: Checkout code
23+
uses: actions/checkout@v2
24+
25+
- name: Run tests
26+
run: |
27+
mkdir "$COVERAGE_DIR"
28+
go test \
29+
-coverprofile="${COVERAGE_DIR}/main" \
30+
-race \
31+
-v \
32+
./...
33+
34+
- name: Merge coverage profiles
35+
run: |
36+
(cd "$GOPATH" && go get github.com/wadey/gocovmerge)
37+
rm -rf "$GOPATH/src/github.com/wadey"
38+
gocovmerge $(find "$COVERAGE_DIR" -type f) > coverage.out
39+
40+
- name: Show per-function coverage profile
41+
run: go tool cover -func=coverage.out
42+
43+
- name: Convert coverage profile to lcov format
44+
uses: jandelgado/[email protected]
45+
with:
46+
infile: coverage.out
47+
outfile: coverage.lcov
48+
49+
- name: Report to Coveralls
50+
uses: coverallsapp/[email protected]
51+
with:
52+
github-token: ${{ secrets.GITHUB_TOKEN }}
53+
path-to-lcov: coverage.lcov
54+
55+
golangci-lint:
56+
name: golangci-lint
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v2
61+
62+
- name: Run golangci-lint
63+
uses: golangci/golangci-lint-action@v2
64+
with:
65+
version: v1.29
66+
67+
prettier:
68+
name: Prettier
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout code
72+
uses: actions/checkout@v2
73+
74+
- name: Run Prettier
75+
uses: creyD/[email protected]
76+
with:
77+
dry: true
78+
prettier_options: --check .

0 commit comments

Comments
 (0)