From 81d1829e1f1c7ea123672b4e23c0769c966e20c1 Mon Sep 17 00:00:00 2001 From: Farbod Ahmadian Date: Thu, 1 Feb 2024 17:06:07 +0100 Subject: [PATCH] feat: add CI for running Go fmt and go build --- .github/workflows/go.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..3afc1b8 --- /dev/null +++ b/.github/workflows/go.yml @@ -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 ./...