File tree Expand file tree Collapse file tree
actions/setup-go-from-mod Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Setup Go From go.mod
2+ description : Setup Go based on the version specified in go.mod
3+ runs :
4+ using : " composite"
5+ steps :
6+ - name : Extract Go version
7+ shell : bash
8+ run : |
9+ echo "GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')" >> $GITHUB_ENV
10+
11+ - name : Set up Go
12+ uses : actions/setup-go@v5
13+ with :
14+ go-version : ${{ env.GO_VERSION }}
Original file line number Diff line number Diff line change 1+ # .github/workflows/go-ci.yml
2+
3+ name : Go CI
4+
5+ on :
6+ push :
7+ branches :
8+ - main
9+ - ' feature/**'
10+ pull_request :
11+ branches :
12+ - main
13+
14+ jobs :
15+ lint :
16+ name : Lint Code
17+ runs-on : ubuntu-latest
18+
19+ steps :
20+ - name : Checkout repository
21+ uses : actions/checkout@v4
22+
23+ - name : Set up Go from go.mod
24+ uses : ./.github/actions/setup-go-from-mod
25+
26+ - name : Cache Go modules
27+ uses : actions/cache@v4
28+ with :
29+ path : |
30+ ~/.cache/go-build
31+ ~/go/pkg/mod
32+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
33+ restore-keys : |
34+ ${{ runner.os }}-go-
35+
36+ - name : Install dependencies
37+ run : go mod tidy
38+
39+ - name : Run Lint
40+ run : make lint
41+
42+ test :
43+ name : Run Unit Tests
44+ runs-on : ubuntu-latest
45+ needs : lint
46+
47+ steps :
48+ - name : Checkout repository
49+ uses : actions/checkout@v4
50+
51+ - name : Set up Go from go.mod
52+ uses : ./.github/actions/setup-go-from-mod
53+
54+ - name : Cache Go modules
55+ uses : actions/cache@v4
56+ with :
57+ path : |
58+ ~/.cache/go-build
59+ ~/go/pkg/mod
60+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
61+ restore-keys : |
62+ ${{ runner.os }}-go-
63+
64+ - name : Install dependencies
65+ run : go mod tidy
66+
67+ - name : Run Tests
68+ run : make test
69+
You can’t perform that action at this time.
0 commit comments