Skip to content

Commit 63ec1cd

Browse files
authored
Add testing and linter validation workflow (#110)
Adds a testing and linter validation workflow Signed-off-by: Chris Collins <collins.christopher@gmail.com>
1 parent f54f5d6 commit 63ec1cd

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 }}

.github/workflows/go-ci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+

0 commit comments

Comments
 (0)