Skip to content

Commit

Permalink
feat: add CI for running Go fmt and go build
Browse files Browse the repository at this point in the history
  • Loading branch information
farbodahm committed Feb 1, 2024
1 parent d4636bb commit 81d1829
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Go Build and Format

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
go:
name: Go ${{ matrix.task }}
runs-on: ubuntu-latest
strategy:
matrix:
task: [fmt, build]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "^1.20" # Set this to your Go version
- name: Install dependencies
run: go mod tidy
- name: Run go fmt
if: matrix.task == 'fmt'
run: |
if [ -n "$(go fmt ./...)" ]; then
echo "Go files must be formatted with gofmt. Please run 'go fmt ./...' locally."
exit 1
fi
- name: Run go build
if: matrix.task == 'build'
run: go build ./...

0 comments on commit 81d1829

Please sign in to comment.