Skip to content

Commit ea360d4

Browse files
committed
feat: release 0.1.0 - Swift Testing performance infrastructure
Performance testing infrastructure for Swift Testing framework with statistical analysis, performance budgets, and comprehensive memory tracking capabilities. Core Features: - Declarative .timed() trait for performance testing - Statistical metrics (min, median, mean, p95, p99, max, stddev) - Performance budgets with automatic threshold enforcement - Memory allocation tracking with platform-specific implementations - Memory leak detection powered by swift-memory-allocation - Peak memory tracking and budgets - Trait composition for comprehensive performance testing - Cross-platform support (macOS/iOS/watchOS/tvOS and Linux) Memory Observability: - Integration with swift-memory-allocation 0.1.0 - AllocationTracker for measuring memory allocations - LeakDetector for automatic leak detection - PeakMemoryTracker for memory profiling - Platform-specific implementations (Darwin malloc_statistics_t, Linux mallinfo2) Testing Infrastructure: - 115 comprehensive tests across 12 test suites - README verification tests for all code examples - Cross-platform compatibility testing - Serialized execution to prevent test interference Documentation: - Comprehensive README with usage examples - DocC documentation with guides and tutorials - Best practices for performance testing - Platform-specific considerations and caveats Code Quality: - Swift 6.2 with strict concurrency - Modern upcoming features (ExistentialAny, InternalImportsByDefault, MemberImportVisibility) - Zero SwiftLint errors or warnings - Swift Format compliance - Clean CI/CD with GitHub Actions Architecture: - Trait-based API using Swift Testing's trait system - Manual measurement API for custom scenarios - Performance suite for comparative benchmarking - Regression detection with baseline comparison - Comprehensive error types with detailed messages Breaking Changes from Pre-release: - Removed local CAllocationTracking C code - Now depends on swift-memory-allocation 0.1.0 - Minimum Swift version 6.1 - Minimum platform versions: macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0 All 115 tests passing. CI passing on macOS and Linux.
1 parent 0988a89 commit ea360d4

40 files changed

+2998
-636
lines changed

.github/FUNDING.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# These are supported funding model platforms
2+
3+
github: [coenttb]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12+
polar: # Replace with a single Polar username
13+
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
14+
thanks_dev: # Replace with a single thanks.dev username
15+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/dependabot.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for Swift Package Manager
4+
- package-ecosystem: "swift"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"
8+
day: "monday"
9+
time: "09:00"
10+
timezone: "America/New_York"
11+
open-pull-requests-limit: 5
12+
reviewers:
13+
- "coenttb"
14+
labels:
15+
- "dependencies"
16+
- "swift"
17+
commit-message:
18+
prefix: "deps"
19+
include: "scope"
20+
21+
# Enable version updates for GitHub Actions
22+
- package-ecosystem: "github-actions"
23+
directory: "/"
24+
schedule:
25+
interval: "monthly"
26+
day: "monday"
27+
time: "09:00"
28+
timezone: "America/New_York"
29+
open-pull-requests-limit: 3
30+
reviewers:
31+
- "coenttb"
32+
labels:
33+
- "dependencies"
34+
- "github-actions"
35+
commit-message:
36+
prefix: "ci"
37+
include: "scope"

.github/workflows/ci.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
# Primary development workflow: Latest Swift on macOS with debug build
18+
macos-latest:
19+
name: macOS (Swift 6.2, debug)
20+
runs-on: macos-26
21+
steps:
22+
- uses: actions/checkout@v5
23+
24+
- name: Select Xcode 26.0
25+
run: sudo xcode-select -s /Applications/Xcode_26.0.app
26+
27+
- name: Print Swift version
28+
run: swift --version
29+
30+
- name: Cache Swift packages
31+
uses: actions/cache@v4
32+
with:
33+
path: .build
34+
key: macos-swift62-spm-${{ hashFiles('Package.swift', 'Package@*.swift') }}
35+
restore-keys: |
36+
macos-swift62-spm-
37+
38+
# Note: swift test builds automatically, no separate build step needed
39+
- name: Test
40+
run: swift test -c debug
41+
42+
- name: Validate Package.swift
43+
run: swift package dump-package
44+
45+
- name: Check for API breaking changes
46+
id: api-diff
47+
run: |
48+
echo "## API Breaking Changes Check" >> $GITHUB_STEP_SUMMARY
49+
if swift package diagnose-api-breaking-changes --breakage-allowlist-path .swift-api-breakage-allowlist 2>&1 | tee api-diff.txt; then
50+
echo "✅ No API breaking changes detected" >> $GITHUB_STEP_SUMMARY
51+
else
52+
echo "⚠️ API breaking changes detected:" >> $GITHUB_STEP_SUMMARY
53+
echo '```' >> $GITHUB_STEP_SUMMARY
54+
cat api-diff.txt >> $GITHUB_STEP_SUMMARY
55+
echo '```' >> $GITHUB_STEP_SUMMARY
56+
echo "::warning::API breaking changes detected. Review changes before release."
57+
fi
58+
continue-on-error: true
59+
60+
# Production validation: Latest Swift on Linux with release build
61+
linux-latest:
62+
name: Ubuntu (Swift 6.2, release)
63+
runs-on: ubuntu-latest
64+
container: swift:6.2
65+
steps:
66+
- uses: actions/checkout@v5
67+
68+
- name: Cache Swift packages
69+
uses: actions/cache@v4
70+
with:
71+
path: .build
72+
key: linux-swift62-spm-${{ hashFiles('Package.swift', 'Package@*.swift') }}
73+
restore-keys: linux-swift62-spm-
74+
75+
# Note: swift test builds automatically in release mode
76+
- name: Test (release)
77+
run: swift test -c release
78+
79+
# Compatibility check: Minimum supported Swift version (6.2)
80+
# Update to swift:6.3 when available
81+
linux-compat:
82+
name: Ubuntu (Swift 6.2, compatibility)
83+
runs-on: ubuntu-latest
84+
container: swift:6.2
85+
steps:
86+
- uses: actions/checkout@v5
87+
88+
- name: Cache Swift packages
89+
uses: actions/cache@v4
90+
with:
91+
path: .build
92+
key: linux-swift62-compat-spm-${{ hashFiles('Package.swift', 'Package@*.swift') }}
93+
restore-keys: linux-swift62-compat-spm-
94+
95+
# Note: swift test builds automatically
96+
- name: Test (Swift 6.2)
97+
run: swift test -c release

.github/workflows/release.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Tag to release'
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
validate:
18+
name: Validate Release
19+
runs-on: macos-15
20+
steps:
21+
- uses: actions/checkout@v5
22+
23+
- name: Select Xcode
24+
run: sudo xcode-select -s /Applications/Xcode_16.0.app
25+
26+
- name: Validate tag format
27+
run: |
28+
TAG="${{ github.event.release.tag_name || github.event.inputs.tag }}"
29+
if [[ ! "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
30+
echo "❌ Invalid tag format: $TAG"
31+
echo "Tag must follow semantic versioning (e.g., 0.1.0)"
32+
exit 1
33+
fi
34+
echo "✅ Valid tag format: $TAG"
35+
36+
- name: Build in release mode
37+
run: swift build -c release
38+
39+
- name: Run all tests
40+
run: swift test -c release
41+
42+
- name: Check for API breaking changes
43+
id: api-diff
44+
run: |
45+
echo "## API Breaking Changes" > api-changes.md
46+
if swift package diagnose-api-breaking-changes --breakage-allowlist-path .swift-api-breakage-allowlist 2>&1 | tee api-diff.txt; then
47+
echo "✅ No API breaking changes detected" >> api-changes.md
48+
else
49+
echo "⚠️ **Breaking changes detected:**" >> api-changes.md
50+
echo '```' >> api-changes.md
51+
cat api-diff.txt >> api-changes.md
52+
echo '```' >> api-changes.md
53+
echo "::warning::API breaking changes detected in this release"
54+
fi
55+
continue-on-error: true
56+
57+
create-release-artifacts:
58+
name: Create Release Artifacts
59+
needs: validate
60+
runs-on: macos-15
61+
steps:
62+
- uses: actions/checkout@v5
63+
64+
- name: Select Xcode
65+
run: sudo xcode-select -s /Applications/Xcode_16.0.app
66+
67+
- name: Generate documentation archive
68+
run: |
69+
swift package \
70+
--allow-writing-to-directory ./docs \
71+
generate-documentation \
72+
--target TestingPerformance \
73+
--output-path ./docs \
74+
--transform-for-static-hosting \
75+
--hosting-base-path swift-testing-performance
76+
77+
# Create documentation archive for download
78+
zip -r documentation.zip docs/
79+
echo "✅ Created documentation archive"
80+
continue-on-error: true
81+
82+
- name: Upload documentation to release
83+
if: github.event_name == 'release'
84+
uses: softprops/action-gh-release@v2
85+
with:
86+
files: documentation.zip
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
90+
publish-documentation:
91+
name: Publish Documentation
92+
needs: validate
93+
runs-on: macos-15
94+
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
95+
permissions:
96+
contents: read
97+
pages: write
98+
id-token: write
99+
environment:
100+
name: github-pages
101+
url: ${{ steps.deployment.outputs.page_url }}
102+
steps:
103+
- uses: actions/checkout@v5
104+
105+
- name: Select Xcode
106+
run: sudo xcode-select -s /Applications/Xcode_16.0.app
107+
108+
- name: Build documentation
109+
run: |
110+
# Generate documentation for main target
111+
swift package \
112+
--allow-writing-to-directory ./docs \
113+
generate-documentation \
114+
--target TestingPerformance \
115+
--output-path ./docs \
116+
--transform-for-static-hosting \
117+
--hosting-base-path swift-testing-performance
118+
119+
# Create root index.html redirect
120+
cat > ./docs/index.html << 'EOF'
121+
<!DOCTYPE html>
122+
<html>
123+
<head>
124+
<meta charset="utf-8">
125+
<title>Redirecting to swift-testing-performance documentation</title>
126+
<meta http-equiv="refresh" content="0; url=./documentation/testingperformance/">
127+
<link rel="canonical" href="./documentation/testingperformance/">
128+
</head>
129+
<body>
130+
<p>Redirecting to <a href="./documentation/testingperformance/">swift-testing-performance documentation</a>...</p>
131+
</body>
132+
</html>
133+
EOF
134+
135+
- name: Setup Pages
136+
uses: actions/configure-pages@v5
137+
138+
- name: Upload artifact
139+
uses: actions/upload-pages-artifact@v4
140+
with:
141+
path: ./docs
142+
143+
- name: Deploy to GitHub Pages
144+
id: deployment
145+
uses: actions/deploy-pages@v4

.github/workflows/swift-format.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Swift Format
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: format-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
swift_format:
14+
name: swift-format
15+
runs-on: ubuntu-latest
16+
container: swift:6.2
17+
permissions:
18+
contents: write
19+
steps:
20+
- uses: actions/checkout@v5
21+
with:
22+
ref: ${{ github.head_ref || github.ref_name }}
23+
24+
- name: Configure git safe directory
25+
run: git config --global --add safe.directory /__w/swift-testing-performance/swift-testing-performance
26+
27+
- name: Restore swift-format cache
28+
id: cache-swift-format-restore
29+
uses: actions/cache/restore@v4
30+
with:
31+
path: /usr/local/bin/swift-format
32+
key: ${{ runner.os }}-swift-format-602.0.0-v1
33+
34+
- name: Install swift-format
35+
if: steps.cache-swift-format-restore.outputs.cache-hit != 'true'
36+
run: |
37+
# Build from stable release tag instead of main
38+
# Update version: https://github.com/apple/swift-format/releases
39+
git clone --depth 1 --branch 602.0.0 https://github.com/apple/swift-format.git
40+
cd swift-format
41+
swift build -c release
42+
cp .build/release/swift-format /usr/local/bin/
43+
cd ..
44+
rm -rf swift-format
45+
46+
- name: Format
47+
run: swift-format format --recursive --in-place --ignore-unparsable-files Sources Tests
48+
49+
- uses: stefanzweifel/git-auto-commit-action@v7
50+
with:
51+
commit_message: Run swift-format
52+
branch: 'main'
53+
54+
- name: Save swift-format cache
55+
uses: actions/cache/save@v4
56+
if: steps.cache-swift-format-restore.outputs.cache-hit != 'true'
57+
with:
58+
path: /usr/local/bin/swift-format
59+
key: ${{ runner.os }}-swift-format-602.0.0-v1

0 commit comments

Comments
 (0)