Skip to content

Commit

Permalink
ci: add lint and test CI checks
Browse files Browse the repository at this point in the history
  • Loading branch information
shraddhaag committed Jan 23, 2024
1 parent c26fea4 commit 3f269eb
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/backend-sanity-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: backend-sanity-checks
on:
push:
paths:
- "**.go"
- ".github/workflows/backend-sanity-checks.yml"

jobs:
go-vet:
name: Go Vet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.20.x"
- name: Run go vet
run: go vet ./... > govetresult.json
- name: Upload Go test results
uses: actions/upload-artifact@v3
with:
name: go-vet-results
path: govetresult.json
go-fmt:
name: Go fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.20.x"
- name: Run go fmt
id: run-go-fmt
run: |
go fmt ./... >> gofmtresult.json
# [ -s <filename> ] returns true is file exists and size is greater than zero
echo "gofmt_needed=$(if [ -s gofmtresult.json ];then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT
- name: Check if any files need to be formatted with go fmt
if: steps.run-go-fmt.outputs.gofmt_needed == 'true'
run: |
echo "go fmt needs to be run on the following files:"
cat gofmtresult.json
exit 1
go-test:
name: Go Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.20.x"
- name: Install dependencies
run: |
go install gotest.tools/gotestsum@latest
- name: Run Tests
run: gotestsum --format testname --jsonfile testresult.json -- -v ./...
- name: Upload Go test results
uses: actions/upload-artifact@v3
with:
name: go-test-results
path: testresult.json

0 comments on commit 3f269eb

Please sign in to comment.