Skip to content

Build and test Go commands #19

Build and test Go commands

Build and test Go commands #19

name: Go build and test
run-name: Build and test Go commands
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download dependencies
run: go mod download
- name: Build all actions
run: make build
- name: Run tests
run: make test
- name: Verify no uncommitted changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "Error: There are uncommitted changes after build/test:"
git status --porcelain
git diff
exit 1
fi