Skip to content

Commit bff9b30

Browse files
committed
feat(ci): integrate benchmark suite into fortress workflows
1 parent f5ff8b1 commit bff9b30

File tree

4 files changed

+124
-4
lines changed

4 files changed

+124
-4
lines changed

.github/.env.shared

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ SECONDARY_RUNNER=ubuntu-24.04 # Set identical to PRIMARY_RUNNER if you
3838
# ───────────────────────────────────────────────────────────────────────────────
3939
# ENV: Feature Flags
4040
# ───────────────────────────────────────────────────────────────────────────────
41+
ENABLE_BENCHMARKS=true # Enable benchmark tests (runs make bench)
4142
ENABLE_CODE_COVERAGE=true # Enable code coverage reporting (upload to Codecov)
4243
ENABLE_FUZZ_TESTING=true # Enable fuzz running tests (requires Go 1.18+)
4344
ENABLE_GO_LINT=true # Enable Go code linting steps (golangci-lint)

.github/workflows/fortress-performance-summary.yml

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ name: GoFortress (Performance Summary)
1313
on:
1414
workflow_call:
1515
inputs:
16+
benchmarks-result:
17+
description: "Benchmarks job result"
18+
required: false
19+
type: string
20+
default: "skipped"
1621
start-epoch:
1722
description: "Workflow start epoch time"
1823
required: true
@@ -126,7 +131,8 @@ jobs:
126131
echo ""
127132
128133
# Process cache statistics if available
129-
if ls cache-stats-*.json >/dev/null 2>&1; then
134+
# Use a more robust file existence check
135+
if compgen -G "cache-stats-*.json" >/dev/null 2>&1; then
130136
echo "### 💾 Cache Performance" >> $GITHUB_STEP_SUMMARY
131137
echo "| OS | Go Version | Module Cache | Build Cache | Module Size | Build Size |" >> $GITHUB_STEP_SUMMARY
132138
echo "|----|------------|--------------|-------------|-------------|------------|" >> $GITHUB_STEP_SUMMARY
@@ -155,8 +161,54 @@ jobs:
155161
done
156162
fi
157163
164+
# Process benchmark statistics if available
165+
# Use a more robust file existence check
166+
if compgen -G "benchmark-stats-*.json" >/dev/null 2>&1; then
167+
echo "" >> $GITHUB_STEP_SUMMARY
168+
echo "### 🏃 Benchmark Performance" >> $GITHUB_STEP_SUMMARY
169+
echo "| Benchmark Suite | Duration | Benchmarks | Status |" >> $GITHUB_STEP_SUMMARY
170+
echo "|-----------------|----------|------------|--------|" >> $GITHUB_STEP_SUMMARY
171+
172+
for stats_file in benchmark-stats-*.json; do
173+
if [ -f "$stats_file" ]; then
174+
NAME=$(jq -r '.name' "$stats_file")
175+
DURATION=$(jq -r '.duration_seconds' "$stats_file")
176+
BENCHMARK_COUNT=$(jq -r '.benchmark_count' "$stats_file")
177+
STATUS=$(jq -r '.status' "$stats_file")
178+
BENCHMARK_SUMMARY=$(jq -r '.benchmark_summary' "$stats_file")
179+
180+
DURATION_MIN=$((DURATION / 60))
181+
DURATION_SEC=$((DURATION % 60))
182+
STATUS_ICON=$([[ "$STATUS" == "success" ]] && echo "✅" || echo "❌")
183+
184+
echo "| $NAME | ${DURATION_MIN}m ${DURATION_SEC}s | $BENCHMARK_COUNT | $STATUS_ICON |" >> $GITHUB_STEP_SUMMARY
185+
fi
186+
done
187+
188+
# Display detailed benchmark results
189+
echo "" >> $GITHUB_STEP_SUMMARY
190+
echo "<details>" >> $GITHUB_STEP_SUMMARY
191+
echo "<summary>Detailed Benchmark Results</summary>" >> $GITHUB_STEP_SUMMARY
192+
echo "" >> $GITHUB_STEP_SUMMARY
193+
194+
for stats_file in benchmark-stats-*.json; do
195+
if [ -f "$stats_file" ]; then
196+
NAME=$(jq -r '.name' "$stats_file")
197+
BENCHMARK_SUMMARY=$(jq -r '.benchmark_summary' "$stats_file")
198+
if [ -n "$BENCHMARK_SUMMARY" ] && [ "$BENCHMARK_SUMMARY" != "null" ]; then
199+
echo "#### $NAME" >> $GITHUB_STEP_SUMMARY
200+
echo "$BENCHMARK_SUMMARY" >> $GITHUB_STEP_SUMMARY
201+
echo "" >> $GITHUB_STEP_SUMMARY
202+
fi
203+
fi
204+
done
205+
206+
echo "</details>" >> $GITHUB_STEP_SUMMARY
207+
fi
208+
158209
# Process test statistics if available
159-
if ls test-stats-*.json >/dev/null 2>&1; then
210+
# Use a more robust file existence check
211+
if compgen -G "test-stats-*.json" >/dev/null 2>&1; then
160212
echo "" >> $GITHUB_STEP_SUMMARY
161213
echo "### 🧪 Test Execution Performance" >> $GITHUB_STEP_SUMMARY
162214
echo "| Test Suite | Duration | Tests | Examples | Status | Race | Coverage | Fuzz |" >> $GITHUB_STEP_SUMMARY
@@ -206,6 +258,10 @@ jobs:
206258
echo "| 🔒 Security Scans | ${{ inputs.security-result }} | $([ "${{ inputs.security-result }}" = "success" ] && echo "✅" || echo "❌") |"
207259
echo "| 📊 Code Quality | ${{ inputs.code-quality-result }} | $([ "${{ inputs.code-quality-result }}" = "success" ] && echo "✅" || echo "❌") |"
208260
echo "| 🧪 Test Suite | ${{ inputs.test-suite-result }} | $([ "${{ inputs.test-suite-result }}" = "success" ] && echo "✅" || echo "❌") |"
261+
# Only show benchmarks row if it was attempted
262+
if [[ "${{ inputs.benchmarks-result }}" != "skipped" ]]; then
263+
echo "| 🏃 Benchmarks | ${{ inputs.benchmarks-result }} | $([ "${{ inputs.benchmarks-result }}" = "success" ] && echo "✅" || echo "❌") |"
264+
fi
209265
# Only show release row if it was attempted
210266
if [[ "${{ inputs.release-result }}" != "skipped" ]]; then
211267
echo "| 🚀 Release | ${{ inputs.release-result }} | $([ "${{ inputs.release-result }}" = "success" ] && echo "✅" || echo "❌") |"
@@ -254,6 +310,7 @@ jobs:
254310
[ "${{ inputs.security-result }}" != "success" ] && [ "${{ inputs.security-result }}" != "skipped" ] && FAILED_JOBS="${FAILED_JOBS}Security Scans, "
255311
[ "${{ inputs.code-quality-result }}" != "success" ] && [ "${{ inputs.code-quality-result }}" != "skipped" ] && FAILED_JOBS="${FAILED_JOBS}Code Quality, "
256312
[ "${{ inputs.test-suite-result }}" != "success" ] && [ "${{ inputs.test-suite-result }}" != "skipped" ] && FAILED_JOBS="${FAILED_JOBS}Test Suite, "
313+
[ "${{ inputs.benchmarks-result }}" != "success" ] && [ "${{ inputs.benchmarks-result }}" != "skipped" ] && FAILED_JOBS="${FAILED_JOBS}Benchmarks, "
257314
[ "${{ inputs.release-result }}" != "success" ] && [ "${{ inputs.release-result }}" != "skipped" ] && FAILED_JOBS="${FAILED_JOBS}Release, "
258315
259316
if [ -n "$FAILED_JOBS" ]; then

.github/workflows/fortress-setup-config.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ on:
2727
description: "GitHub token for API access"
2828
required: true
2929
outputs:
30+
benchmarks-enabled:
31+
description: "Whether benchmarks are enabled"
32+
value: ${{ jobs.setup-config.outputs.benchmarks-enabled }}
33+
benchmark-matrix:
34+
description: "Benchmark matrix JSON"
35+
value: ${{ jobs.setup-config.outputs.benchmark-matrix }}
3036
code-coverage-enabled:
3137
description: "Whether code coverage is enabled"
3238
value: ${{ jobs.setup-config.outputs.code-coverage-enabled }}
@@ -90,6 +96,8 @@ jobs:
9096
name: 🎯 Setup CI Config
9197
runs-on: ${{ inputs.primary-runner }}
9298
outputs:
99+
benchmarks-enabled: ${{ steps.config.outputs.benchmarks-enabled }}
100+
benchmark-matrix: ${{ steps.matrix.outputs.matrix }}
93101
code-coverage-enabled: ${{ steps.config.outputs.code-coverage-enabled }}
94102
fuzz-testing-enabled: ${{ steps.config.outputs.fuzz-testing-enabled }}
95103
go-primary-version: ${{ steps.config.outputs.go-primary-version }}
@@ -271,6 +279,7 @@ jobs:
271279
fi
272280
273281
# Feature flags
282+
echo "benchmarks-enabled=${{ env.ENABLE_BENCHMARKS }}" >> $GITHUB_OUTPUT
274283
echo "code-coverage-enabled=${{ env.ENABLE_CODE_COVERAGE }}" >> $GITHUB_OUTPUT
275284
echo "go-lint-enabled=${{ env.ENABLE_GO_LINT }}" >> $GITHUB_OUTPUT
276285
echo "yaml-lint-enabled=${{ env.ENABLE_YAML_LINT }}" >> $GITHUB_OUTPUT
@@ -338,6 +347,7 @@ jobs:
338347
echo "## 🚀 Feature Flags" >> $GITHUB_STEP_SUMMARY
339348
echo "| Feature | Status | Impact |" >> $GITHUB_STEP_SUMMARY
340349
echo "|---------|--------|--------|" >> $GITHUB_STEP_SUMMARY
350+
echo "| **Benchmarks** | $([ "${{ env.ENABLE_BENCHMARKS }}" == "true" ] && echo "✅ Enabled" || echo "❌ Disabled") | Performance benchmarks will $([ "${{ env.ENABLE_BENCHMARKS }}" == "true" ] && echo "run and collect metrics" || echo "be skipped") |" >> $GITHUB_STEP_SUMMARY
341351
echo "| **Code Coverage** | $([ "${{ env.ENABLE_CODE_COVERAGE }}" == "true" ] && echo "✅ Enabled" || echo "❌ Disabled") | Code coverage reports will $([ "${{ env.ENABLE_CODE_COVERAGE }}" == "true" ] && echo "be generated and uploaded to Codecov" || echo "not be generated") |" >> $GITHUB_STEP_SUMMARY
342352
echo "| **Fuzz Testing** | $([ "${{ env.ENABLE_FUZZ_TESTING }}" == "true" ] && echo "✅ Enabled" || echo "❌ Disabled") | Fuzz tests will $([ "${{ env.ENABLE_FUZZ_TESTING }}" == "true" ] && echo "run on Linux with primary Go version" || echo "be skipped") |" >> $GITHUB_STEP_SUMMARY
343353
echo "| **Go Linting** | $([ "${{ env.ENABLE_GO_LINT }}" == "true" ] && echo "✅ Enabled" || echo "❌ Disabled") | golangci-lint will $([ "${{ env.ENABLE_GO_LINT }}" == "true" ] && echo "analyze code quality" || echo "be skipped") |" >> $GITHUB_STEP_SUMMARY

.github/workflows/fortress.yml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,28 @@ jobs:
196196
github-token: ${{ secrets.GH_PAT_TOKEN != '' && secrets.GH_PAT_TOKEN || secrets.GITHUB_TOKEN }}
197197
codecov-token: ${{ secrets.CODECOV_TOKEN }}
198198
# ----------------------------------------------------------------------------------
199+
# Benchmark Suite
200+
# ----------------------------------------------------------------------------------
201+
benchmarks:
202+
name: 🏃 Benchmarks
203+
needs: [load-env, setup, warm-cache, test-makefile]
204+
if: needs.setup.outputs.benchmarks-enabled == 'true'
205+
uses: ./.github/workflows/fortress-benchmarks.yml
206+
with:
207+
env-json: ${{ needs.load-env.outputs.env-json }}
208+
benchmark-matrix: ${{ needs.setup.outputs.benchmark-matrix }}
209+
primary-runner: ${{ needs.setup.outputs.primary-runner }}
210+
go-primary-version: ${{ needs.setup.outputs.go-primary-version }}
211+
go-secondary-version: ${{ needs.setup.outputs.go-secondary-version }}
212+
secrets:
213+
github-token: ${{ secrets.GH_PAT_TOKEN != '' && secrets.GH_PAT_TOKEN || secrets.GITHUB_TOKEN }}
214+
# ----------------------------------------------------------------------------------
199215
# Final Status Check
200216
# ----------------------------------------------------------------------------------
201217
status-check:
202218
name: 🎯 All Tests Passed
203219
if: ${{ always() }}
204-
needs: [setup, test-makefile, security, code-quality, test-suite]
220+
needs: [setup, test-makefile, security, code-quality, test-suite, benchmarks]
205221
runs-on: ${{ needs.setup.outputs.primary-runner }}
206222
steps:
207223
# ————————————————————————————————————————————————————————————————
@@ -219,16 +235,51 @@ jobs:
219235
echo "| 🔒 Security | ${{ needs.security.result }} |"
220236
echo "| 📊 Code Quality | ${{ needs.code-quality.result }} |"
221237
echo "| 🧪 Test Suite | ${{ needs.test-suite.result }} |"
238+
echo "| 🏃 Benchmarks | ${{ needs.benchmarks.result }} |"
222239
} >> "$GITHUB_STEP_SUMMARY"
223240
224241
# ————————————————————————————————————————————————————————————————
225242
# Fail the workflow *only* when a dependency actually failed/canceled
226243
# - 'skipped' is OK (e.g. feature flag off)
244+
# - Only check benchmarks result if benchmarks are enabled
227245
# ————————————————————————————————————————————————————————————————
228246
- name: ❌ Fail if any required job errored
229247
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
230248
run: |
231249
echo "❌ One or more jobs failed or were cancelled – see summary above." >&2
250+
251+
# Check if benchmarks failed only if they were enabled
252+
if [[ "${{ needs.setup.outputs.benchmarks-enabled }}" == "true" && "${{ needs.benchmarks.result }}" == "failure" ]]; then
253+
echo "❌ Benchmarks failed and were enabled" >&2
254+
exit 1
255+
fi
256+
257+
# Check other required jobs
258+
if [[ "${{ needs.setup.result }}" == "failure" || "${{ needs.setup.result }}" == "cancelled" ]]; then
259+
echo "❌ Setup failed or was cancelled" >&2
260+
exit 1
261+
fi
262+
263+
if [[ "${{ needs.test-makefile.result }}" == "failure" || "${{ needs.test-makefile.result }}" == "cancelled" ]]; then
264+
echo "❌ Test makefile failed or was cancelled" >&2
265+
exit 1
266+
fi
267+
268+
if [[ "${{ needs.security.result }}" == "failure" || "${{ needs.security.result }}" == "cancelled" ]]; then
269+
echo "❌ Security scans failed or were cancelled" >&2
270+
exit 1
271+
fi
272+
273+
if [[ "${{ needs.code-quality.result }}" == "failure" || "${{ needs.code-quality.result }}" == "cancelled" ]]; then
274+
echo "❌ Code quality checks failed or were cancelled" >&2
275+
exit 1
276+
fi
277+
278+
if [[ "${{ needs.test-suite.result }}" == "failure" || "${{ needs.test-suite.result }}" == "cancelled" ]]; then
279+
echo "❌ Test suite failed or was cancelled" >&2
280+
exit 1
281+
fi
282+
232283
exit 1
233284
234285
# ————————————————————————————————————————————————————————————————
@@ -264,9 +315,10 @@ jobs:
264315
performance-summary:
265316
name: 📊 Performance Summary
266317
if: always()
267-
needs: [load-env, setup, test-makefile, security, code-quality, test-suite, release]
318+
needs: [load-env, setup, test-makefile, security, code-quality, test-suite, benchmarks, release]
268319
uses: ./.github/workflows/fortress-performance-summary.yml
269320
with:
321+
benchmarks-result: ${{ needs.benchmarks.result }}
270322
code-quality-result: ${{ needs.code-quality.result }}
271323
env-json: ${{ needs.load-env.outputs.env-json }}
272324
primary-runner: ${{ needs.setup.outputs.primary-runner }}

0 commit comments

Comments
 (0)