Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added go test & goimports actions #36

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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