Skip to content

refactor: move to surfacing core validation errors through the high model validation methods #33

refactor: move to surfacing core validation errors through the high model validation methods

refactor: move to surfacing core validation errors through the high model validation methods #33

Workflow file for this run

name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test-and-build:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Install dependencies
run: go mod download
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
- name: Run tests with coverage
run: |
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
go tool cover -html=coverage.out -o coverage.html
- name: Calculate coverage
id: coverage
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}')
echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT
echo "Coverage: $COVERAGE"
- name: Generate coverage summary
id: coverage-summary
run: |
echo "## 📊 Test Coverage Report" > coverage-summary.md
echo "" >> coverage-summary.md
echo "**Overall Coverage:** \`${{ steps.coverage.outputs.coverage }}\`" >> coverage-summary.md
echo "" >> coverage-summary.md
echo "### Coverage by Package" >> coverage-summary.md
echo "\`\`\`" >> coverage-summary.md
go tool cover -func=coverage.out >> coverage-summary.md
echo "\`\`\`" >> coverage-summary.md
echo "" >> coverage-summary.md
echo "- 🧪 All tests passed" >> coverage-summary.md
echo "- 📈 Full coverage report available in workflow artifacts" >> coverage-summary.md
echo "" >> coverage-summary.md
echo "_Generated by GitHub Actions_" >> coverage-summary.md
- name: Comment PR with coverage
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const coverageSummary = fs.readFileSync('coverage-summary.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: coverageSummary
});
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
coverage.out
coverage.html
- name: Build
run: go build -v ./...