Skip to content

Commit 4af7e77

Browse files
committed
Resolve local
2 parents 5dee0cb + e27986e commit 4af7e77

File tree

73 files changed

+23274
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+23274
-480
lines changed

.coverletrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"exclude": [
3+
"[*]*.Program",
4+
"[*]*Tests*",
5+
"[*]*Test*",
6+
"[*]*.*Tests",
7+
"[*]*AssemblyInfo*"
8+
],
9+
"excludebyattribute": [
10+
"Obsolete",
11+
"GeneratedCodeAttribute",
12+
"CompilerGeneratedAttribute"
13+
],
14+
"excludebyfile": [
15+
"**/bin/**/*.*",
16+
"**/obj/**/*.*"
17+
]
18+
}

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.github/workflows/*.lock.yml linguist-generated=true merge=ours
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: 'Daily Perf Improver - Build Steps'
2+
description: 'Build and set up environment for performance development work'
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- name: Setup .NET SDK
7+
shell: bash
8+
run: |
9+
echo "=== Setting up .NET SDK ===" | tee -a build-steps.log
10+
dotnet --version >> build-steps.log 2>&1
11+
echo "✓ .NET SDK version:" | tee -a build-steps.log
12+
dotnet --version | tee -a build-steps.log
13+
14+
- name: Restore dependencies
15+
shell: bash
16+
run: |
17+
echo "" | tee -a build-steps.log
18+
echo "=== Restoring dependencies ===" | tee -a build-steps.log
19+
dotnet restore FsMath.sln >> build-steps.log 2>&1
20+
echo "✓ Dependencies restored" | tee -a build-steps.log
21+
22+
- name: Build solution
23+
shell: bash
24+
run: |
25+
echo "" | tee -a build-steps.log
26+
echo "=== Building solution ===" | tee -a build-steps.log
27+
chmod u+x build.sh
28+
./build.sh >> build-steps.log 2>&1
29+
echo "✓ Solution built successfully" | tee -a build-steps.log
30+
31+
- name: Run tests
32+
shell: bash
33+
run: |
34+
echo "" | tee -a build-steps.log
35+
echo "=== Running tests ===" | tee -a build-steps.log
36+
dotnet test tests/FsMath.Tests/FsMath.Tests.fsproj -c Release --no-build --verbosity quiet >> build-steps.log 2>&1
37+
echo "✓ All tests passed" | tee -a build-steps.log
38+
39+
- name: Build benchmarks
40+
shell: bash
41+
run: |
42+
echo "" | tee -a build-steps.log
43+
echo "=== Building benchmarks ===" | tee -a build-steps.log
44+
dotnet build benchmarks/FsMath.Benchmarks/FsMath.Benchmarks.fsproj -c Release >> build-steps.log 2>&1
45+
echo "✓ Benchmarks built successfully" | tee -a build-steps.log
46+
47+
- name: Verify benchmark runs
48+
shell: bash
49+
run: |
50+
echo "" | tee -a build-steps.log
51+
echo "=== Verifying benchmarks can run ===" | tee -a build-steps.log
52+
echo "Note: Running quick dry-run to verify benchmarks work" | tee -a build-steps.log
53+
dotnet run -c Release --project benchmarks/FsMath.Benchmarks/FsMath.Benchmarks.fsproj -- --list flat >> build-steps.log 2>&1 || true
54+
echo "✓ Benchmark infrastructure verified" | tee -a build-steps.log
55+
56+
- name: Summary
57+
shell: bash
58+
run: |
59+
echo "" | tee -a build-steps.log
60+
echo "=== Build Steps Complete ===" | tee -a build-steps.log
61+
echo "✓ Environment is ready for performance development work" | tee -a build-steps.log
62+
echo "✓ You can now run benchmarks with:" | tee -a build-steps.log
63+
echo " dotnet run -c Release --project benchmarks/FsMath.Benchmarks/FsMath.Benchmarks.fsproj" | tee -a build-steps.log
64+
echo "" | tee -a build-steps.log
65+
cat build-steps.log
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: 'Test Coverage Steps'
2+
description: 'Builds project, runs tests with coverage, and uploads coverage report'
3+
runs:
4+
using: "composite"
5+
steps:
6+
# Step 1: Restore NuGet dependencies
7+
- name: Restore dependencies
8+
shell: bash
9+
run: |
10+
echo "=== Restoring dependencies ===" | tee -a coverage-steps.log
11+
dotnet restore 2>&1 | tee -a coverage-steps.log
12+
13+
# Step 2: Build the solution
14+
- name: Build solution
15+
shell: bash
16+
run: |
17+
echo "=== Building solution ===" | tee -a coverage-steps.log
18+
dotnet build --no-restore 2>&1 | tee -a coverage-steps.log
19+
20+
# Step 3: Run tests with coverage collection
21+
# Coverage report will be generated in ./coverage directory
22+
# Uses coverlet.collector which is already configured in the test project
23+
- name: Run tests with coverage
24+
shell: bash
25+
run: |
26+
echo "=== Running tests with coverage collection ===" | tee -a coverage-steps.log
27+
dotnet test tests/FsMath.Tests/FsMath.Tests.fsproj \
28+
--no-build \
29+
--collect:"XPlat Code Coverage" \
30+
--results-directory ./coverage \
31+
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura 2>&1 | tee -a coverage-steps.log
32+
33+
# Step 4: Find and copy coverage file to a consistent location
34+
# The coverage file is generated with a GUID in the path, so we need to find it
35+
- name: Locate coverage report
36+
shell: bash
37+
run: |
38+
echo "=== Locating coverage report ===" | tee -a coverage-steps.log
39+
COVERAGE_FILE=$(find ./coverage -name "coverage.cobertura.xml" | head -n 1)
40+
if [ -n "$COVERAGE_FILE" ]; then
41+
echo "Found coverage file at: $COVERAGE_FILE" | tee -a coverage-steps.log
42+
cp "$COVERAGE_FILE" ./coverage/coverage.cobertura.xml
43+
echo "Copied to: ./coverage/coverage.cobertura.xml" | tee -a coverage-steps.log
44+
else
45+
echo "ERROR: Coverage file not found!" | tee -a coverage-steps.log
46+
exit 1
47+
fi
48+
49+
# Step 5: Display coverage summary
50+
- name: Display coverage summary
51+
shell: bash
52+
run: |
53+
echo "=== Coverage Summary ===" | tee -a coverage-steps.log
54+
if [ -f "./coverage/coverage.cobertura.xml" ]; then
55+
# Extract high-level coverage metrics from the XML
56+
LINE_RATE=$(grep -oP 'line-rate="\K[^"]*' ./coverage/coverage.cobertura.xml | head -n 1)
57+
BRANCH_RATE=$(grep -oP 'branch-rate="\K[^"]*' ./coverage/coverage.cobertura.xml | head -n 1)
58+
LINES_COVERED=$(grep -oP 'lines-covered="\K[^"]*' ./coverage/coverage.cobertura.xml | head -n 1)
59+
LINES_VALID=$(grep -oP 'lines-valid="\K[^"]*' ./coverage/coverage.cobertura.xml | head -n 1)
60+
61+
LINE_PERCENT=$(awk "BEGIN {printf \"%.2f\", $LINE_RATE * 100}")
62+
BRANCH_PERCENT=$(awk "BEGIN {printf \"%.2f\", $BRANCH_RATE * 100}")
63+
64+
echo "Line Coverage: $LINE_PERCENT% ($LINES_COVERED/$LINES_VALID lines)" | tee -a coverage-steps.log
65+
echo "Branch Coverage: $BRANCH_PERCENT%" | tee -a coverage-steps.log
66+
else
67+
echo "ERROR: Coverage report not found at expected location!" | tee -a coverage-steps.log
68+
exit 1
69+
fi
70+
71+
# Step 6: Upload coverage report as artifact
72+
# The coverage report can be downloaded from the workflow run
73+
- name: Upload coverage artifact
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: coverage
77+
path: ./coverage/coverage.cobertura.xml
78+
retention-days: 30

.github/workflows/build-and-test.yml

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
pull_request:
77
branches: [ main ]
88

9+
permissions:
10+
contents: read
11+
pull-requests: write
912

1013
jobs:
1114
build-and-test-linux:
@@ -14,15 +17,96 @@ jobs:
1417

1518
steps:
1619
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
1722
- name: Setup .NET
1823
uses: actions/setup-dotnet@v4
1924
with:
20-
dotnet-version: 9.x.x
25+
dotnet-version: 8.x.x
2126
- name: make script executable
2227
run: chmod u+x build.sh
23-
- name: Build and test
28+
- name: Build and test with coverage
2429
working-directory: ./
25-
run: ./build.sh runtests
30+
run: ./build.sh runtestswithcoverage
31+
32+
- name: Install ReportGenerator
33+
run: dotnet tool install -g dotnet-reportgenerator-globaltool
34+
35+
- name: Generate coverage report
36+
run: |
37+
reportgenerator \
38+
-reports:"TestResults/**/coverage.cobertura.xml" \
39+
-targetdir:"TestResults/CoverageReport" \
40+
-reporttypes:"Html;Cobertura;JsonSummary" \
41+
-verbosity:"Info"
42+
43+
- name: Code Coverage Report
44+
uses: irongut/CodeCoverageSummary@v1.3.0
45+
with:
46+
filename: TestResults/**/coverage.cobertura.xml
47+
badge: true
48+
fail_below_min: false
49+
format: markdown
50+
hide_branch_rate: false
51+
hide_complexity: false
52+
indicators: true
53+
output: both
54+
thresholds: '60 80'
55+
56+
- name: Create Enhanced Coverage Report
57+
run: |
58+
echo "# 📊 Code Coverage Report" > enhanced-coverage-results.md
59+
echo "" >> enhanced-coverage-results.md
60+
echo "## Summary" >> enhanced-coverage-results.md
61+
cat code-coverage-results.md >> enhanced-coverage-results.md
62+
echo "" >> enhanced-coverage-results.md
63+
echo "## 📈 Coverage Analysis" >> enhanced-coverage-results.md
64+
echo "" >> enhanced-coverage-results.md
65+
66+
# Extract coverage percentage for analysis
67+
COVERAGE=$(grep -o '[0-9]\+%' code-coverage-results.md | head -1 | tr -d '%')
68+
69+
if [ "$COVERAGE" -ge 80 ]; then
70+
echo "🟢 **Excellent Coverage!** Your code coverage is above 80%, which is considered very good practice." >> enhanced-coverage-results.md
71+
elif [ "$COVERAGE" -ge 60 ]; then
72+
echo "🟡 **Good Coverage** Your code coverage is above 60%. Consider adding more tests to reach 80%." >> enhanced-coverage-results.md
73+
else
74+
echo "🔴 **Low Coverage** Your code coverage is below 60%. Please add more tests to improve coverage." >> enhanced-coverage-results.md
75+
fi
76+
77+
echo "" >> enhanced-coverage-results.md
78+
echo "## 🎯 Coverage Goals" >> enhanced-coverage-results.md
79+
echo "- **Target**: 80% line coverage" >> enhanced-coverage-results.md
80+
echo "- **Minimum**: 60% line coverage" >> enhanced-coverage-results.md
81+
echo "- **Current**: ${COVERAGE}% line coverage" >> enhanced-coverage-results.md
82+
echo "" >> enhanced-coverage-results.md
83+
echo "## 📋 What These Numbers Mean" >> enhanced-coverage-results.md
84+
echo "" >> enhanced-coverage-results.md
85+
echo "- **Line Rate**: Percentage of code lines that were executed during tests" >> enhanced-coverage-results.md
86+
echo "- **Branch Rate**: Percentage of code branches (if/else, switch cases) that were tested" >> enhanced-coverage-results.md
87+
echo "- **Health**: Overall assessment combining line and branch coverage" >> enhanced-coverage-results.md
88+
echo "" >> enhanced-coverage-results.md
89+
echo "## 🔗 Detailed Reports" >> enhanced-coverage-results.md
90+
echo "" >> enhanced-coverage-results.md
91+
echo "📋 [Download Full Coverage Report](../actions/runs/${{ github.run_id }}) - Check the 'coverage-report' artifact for detailed HTML coverage report" >> enhanced-coverage-results.md
92+
echo "" >> enhanced-coverage-results.md
93+
echo "---" >> enhanced-coverage-results.md
94+
echo "*Coverage report generated on $(date '+%Y-%m-%d at %H:%M:%S UTC')*" >> enhanced-coverage-results.md
95+
echo "" >> enhanced-coverage-results.md
96+
echo "<!-- Sticky Pull Request Comment -->" >> enhanced-coverage-results.md
97+
98+
- name: Add Enhanced Coverage PR Comment
99+
uses: marocchino/sticky-pull-request-comment@v2
100+
if: github.event_name == 'pull_request'
101+
with:
102+
recreate: true
103+
path: enhanced-coverage-results.md
104+
105+
- name: Upload coverage report
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: coverage-report
109+
path: TestResults/CoverageReport/
26110

27111
build-and-test-windows:
28112

@@ -33,7 +117,7 @@ jobs:
33117
- name: Setup .NET
34118
uses: actions/setup-dotnet@v4
35119
with:
36-
dotnet-version: 9.x.x
37-
- name: Build and test
120+
dotnet-version: 8.x.x
121+
- name: Build and test with coverage
38122
working-directory: ./
39-
run: ./build.cmd runtests
123+
run: ./build.cmd runtestswithcoverage

0 commit comments

Comments
 (0)