Skip to content

Commit

Permalink
Added go test & goimports actions (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
applejag committed Nov 17, 2021
1 parent e0d0d1d commit b8b968b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/go-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Go format

on:
pull_request:
branches: [ '**' ]

jobs:
goimports_diff:
runs-on: ubuntu-latest

steps:
- uses: actions/setup-go@v2
with:
go-version: '1.16'

- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest

- name: checkout
uses: actions/checkout@v2

- name: Format all .go files
run:
echo "Checking files:"
find . -name '*.go'
goimports -w $(find . -name '*.go')

- name: Git diff
run: git diff --exit-code
40 changes: 40 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Go test

on:
pull_request:
branches: [ '**' ]

jobs:
run_tests:
runs-on: ubuntu-latest

steps:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.16'

- name: Set up gotestfmt
uses: haveyoudebuggedit/gotestfmt-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v1.0.0

- name: checkout
uses: actions/checkout@v2

- name: Setup repo
run: make deps swag

- name: Run tests
run: |
# One for GitHub Action logging purposes
go test -v ./... 2>&1 | gotestfmt
# One for golang-test-annotations
go test -json ./... > test-results.json
- name: Annotate tests
if: always()
uses: guyarb/golang-test-annotations@v0.5.0
with:
test-results: test-results.json

0 comments on commit b8b968b

Please sign in to comment.