Skip to content
Merged
Show file tree
Hide file tree
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
63 changes: 45 additions & 18 deletions .github/workflows/utify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

jobs:
validate:
name: Quick Validation
name: Validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -39,16 +39,18 @@ jobs:
else
git diff --exit-code go.mod
fi
- name: Run tests with full coverage
run: go test -v -race -timeout=5m -coverpkg=./... -coverprofile=coverage.out ./...
- name: Run integration tests
run: go test -v -race -timeout=10m -coverpkg=./... ./tests/integration/...
- name: Run tests with full coverage (all packages + tests)
run: |
go test -v -race -timeout=10m -covermode=atomic -coverprofile=coverage.out $(go list ./... | grep -v /examples)
- name: Run benchmarks
run: go test -bench=. -benchtime=5s ./tests/benchmarks/...
- name: Fail if coverage is zero
- name: Analyze coverage
run: |
if [ $(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//') = 0 ]; then
echo "Coverage is 0% - failing." && exit 1
go tool cover -func=coverage.out
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
echo "Total coverage: $COVERAGE%"
if (( $(echo "$COVERAGE < 90" | bc -l) )); then
echo "Coverage below 90% - failing." && exit 1
fi
- name: Upload coverage reports to Codecov
if: github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -84,36 +86,62 @@ jobs:
gocyclo -over 15 .

release:
name: Validate & Prepare Release
name: Release Validation & Preparation
runs-on: ubuntu-latest
needs: validate
if: startsWith(github.ref, 'refs/tags/v')
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Get version
id: get-version
run: |
VERSION="${GITHUB_REF#refs/tags/}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
RAW_VERSION="${GITHUB_REF#refs/tags/}" # e.g., v1.5.1
CLEAN_VERSION="${RAW_VERSION#v}" # e.g., 1.5.1
echo "version=${RAW_VERSION}" >> $GITHUB_OUTPUT
echo "clean_version=${CLEAN_VERSION}" >> $GITHUB_OUTPUT

- name: Validate tag format
run: |
if ! [[ "${{ steps.get-version.outputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
echo "Invalid version format" && exit 1
if ! [[ "${{ steps.get-version.outputs.clean_version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
echo "Invalid version format: ${{ steps.get-version.outputs.clean_version }}" && exit 1
fi

- name: Validate changelog file
run: |
FILE="changelogs/${{ steps.get-version.outputs.clean_version }}.md"
if [ ! -f "$FILE" ]; then
echo "Changelog file $FILE not found for this version!" && exit 1
fi
if ! grep -q "(${FILE})" CHANGELOG.md; then
echo "Changelog file $FILE is missing from the main CHANGELOG.md index!" && exit 1
fi
cp "$FILE" RELEASE_BODY.md

- name: Build all examples
run: |
mkdir -p dist/examples
for dir in ./examples/*/ ; do
name=$(basename "$dir")
go build -o "dist/examples/$name" "$dir"
done
- name: Extract changelog for release
id: changelog

- name: Generate coverage report (Markdown)
run: |
VERSION="${GITHUB_REF#refs/tags/}"
awk '/## \['"${VERSION}"'\]/{flag=1; next} /^## /{flag=0} flag' CHANGELOG.md > RELEASE_BODY.md
go tool cover -func=coverage.out | tee coverage_report.txt
echo "# Coverage Report" > coverage_report.md
echo '```' >> coverage_report.md
cat coverage_report.txt >> coverage_report.md
echo '```' >> coverage_report.md

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage_report.md

- name: Create or Update GitHub Release
uses: softprops/action-gh-release@v2
with:
Expand Down Expand Up @@ -149,4 +177,3 @@ jobs:
GOPROXY=proxy.golang.org go list -m github.com/jsas4coding/utify@${VERSION}
- name: Confirm publication
run: echo "Release ${{ needs.release.outputs.version }} published successfully!"

9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,12 @@ e2e-sandbox/
/anthropic.json
/anthropic.md
/ai.config.yml

############################################################################
# Coverage
############################################################################
*.out
coverage.html
*coverage.html

# No specific changes needed for examples
Loading
Loading