Skip to content

Commit 14e3900

Browse files
chore: update/cleanup workflows (#446)
* chore: update/cleanup workflows * fix: formatting check * fix: revert workflow job name
1 parent f814365 commit 14e3900

File tree

1 file changed

+33
-22
lines changed

1 file changed

+33
-22
lines changed

.github/workflows/go.yml

+33-22
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
name: Go
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: main
6+
pull_request:
7+
types: [opened, synchronize, ready_for_review]
48

59
jobs:
6-
710
build:
811
runs-on: ubuntu-latest
12+
913
steps:
10-
- uses: actions/checkout@v4
11-
- name: Set up Go
12-
uses: actions/setup-go@v5
13-
with:
14-
go-version: "1.23"
15-
- name: Check Formatting
16-
run: |
17-
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
18-
gofmt -s -l .
19-
echo "Please format Go code by running: go fmt ./..."
20-
exit 1
21-
fi
22-
- name: Build
23-
run: go build -v ./...
24-
- name: Test
25-
run: go test -v ./... -coverprofile=coverage.out -covermode=atomic
26-
- name: Codecov
27-
uses: codecov/codecov-action@v5
28-
env:
29-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: "1.23"
20+
21+
- name: Check Formatting
22+
run: |
23+
unformatted=$(gofmt -s -l .)
24+
if [ -n "$unformatted" ]; then
25+
echo "::error::The following files are not formatted properly:"
26+
echo "$unformatted"
27+
echo "Please run `gofmt -s -w .` to format your code."
28+
exit 1
29+
fi
30+
31+
- name: Build
32+
run: go build -v ./...
33+
34+
- name: Test
35+
run: go test -v ./... -coverprofile=coverage.out -covermode=atomic
36+
37+
- name: Codecov
38+
uses: codecov/codecov-action@v5
39+
env:
40+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

0 commit comments

Comments
 (0)