Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Go Build, Test, and Format
name: Go CI

on:
push:
Expand All @@ -12,7 +12,7 @@ on:

jobs:
build-test:
name: Build and Test on ${{ matrix.os }}
name: Build, Test & Coverage on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -30,13 +30,23 @@ jobs:
- name: Build
run: go build ./...

- name: Run Tests
run: go test ./...
- name: Run Tests with Coverage
run: |
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
shell: bash

- name: Upload coverage report
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.out

format:
name: Format
name: Auto-format with gofmt (Linux only)
runs-on: ubuntu-latest
if: github.event_name == 'push' # only format on push events (not PRs from forks)
if: github.event_name == 'push' && github.repository_owner == github.actor

steps:
- name: Checkout code
Expand All @@ -47,11 +57,11 @@ jobs:
with:
go-version: '1.24.4'

- name: Auto-format code with gofmt and commit changes
- name: Run gofmt and commit changes if needed
run: |
gofmt -w .
if [ -n "$(git status --porcelain)" ]; then
echo "Code was not formatted. Applying gofmt and committing changes..."
echo "Code was not formatted. Committing changes..."
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add .
Expand Down
Loading