From b8b968b92c2e5341b6ec9965397ce4725c510e05 Mon Sep 17 00:00:00 2001 From: "kalle (jag)" Date: Wed, 17 Nov 2021 12:13:02 +0100 Subject: [PATCH] Added `go test` & `goimports` actions (#36) --- .github/workflows/go-format.yml | 29 ++++++++++++++++++++++++ .github/workflows/go-test.yml | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/go-format.yml create mode 100644 .github/workflows/go-test.yml diff --git a/.github/workflows/go-format.yml b/.github/workflows/go-format.yml new file mode 100644 index 0000000..0e5370d --- /dev/null +++ b/.github/workflows/go-format.yml @@ -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 diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml new file mode 100644 index 0000000..923d292 --- /dev/null +++ b/.github/workflows/go-test.yml @@ -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