Skip to content

Commit 2a09e17

Browse files
authored
Added go test & goimports actions (#28)
* Added actions * Removed `make deps swag`
1 parent cb764b4 commit 2a09e17

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

.github/workflows/go-format.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Go format
2+
3+
on:
4+
pull_request:
5+
branches: [ '**' ]
6+
7+
jobs:
8+
goimports_diff:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/setup-go@v2
13+
with:
14+
go-version: '1.16'
15+
16+
- name: Install goimports
17+
run: go install golang.org/x/tools/cmd/goimports@latest
18+
19+
- name: checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Format all .go files
23+
run:
24+
echo "Checking files:"
25+
find . -name '*.go'
26+
goimports -w $(find . -name '*.go')
27+
28+
- name: Git diff
29+
run: git diff --exit-code

.github/workflows/go-test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Go test
2+
3+
on:
4+
pull_request:
5+
branches: [ '**' ]
6+
7+
jobs:
8+
run_tests:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Setup Go
13+
uses: actions/setup-go@v2
14+
with:
15+
go-version: '1.16'
16+
17+
- name: Set up gotestfmt
18+
uses: haveyoudebuggedit/gotestfmt-action@v1
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
version: v1.0.0
22+
23+
- name: checkout
24+
uses: actions/checkout@v2
25+
26+
- name: Run tests
27+
run: |
28+
# One for GitHub Action logging purposes
29+
go test -v ./... 2>&1 | gotestfmt
30+
# One for golang-test-annotations
31+
go test -json ./... > test-results.json
32+
33+
- name: Annotate tests
34+
if: always()
35+
uses: guyarb/golang-test-annotations@v0.5.0
36+
with:
37+
test-results: test-results.json

0 commit comments

Comments
 (0)