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
12 changes: 6 additions & 6 deletions .github/workflows/VerifyChanges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:
fail-fast: false
matrix:
include:
- platform: iOS
xcode_destination: "platform=iOS Simulator,name=iPhone 16 Pro"
# - platform: iOS
# xcode_destination: "platform=iOS Simulator,name=iPhone 16 Pro"
- platform: macOS
xcode_destination: "platform=macOS,arch=arm64"
- platform: tvOS
xcode_destination: "platform=tvOS Simulator,name=Apple TV 4K (3rd generation)"
- platform: watchOS
xcode_destination: "platform=watchOS Simulator,name=Apple Watch Series 10 (46mm)"
# - platform: tvOS
# xcode_destination: "platform=tvOS Simulator,name=Apple TV 4K (3rd generation)"
# - platform: watchOS
# xcode_destination: "platform=watchOS Simulator,name=Apple Watch Series 10 (46mm)"
env:
DEV_BUILDS: DevBuilds/Sources
XCCOV_PRETTY_VERSION: 1.2.0
Expand Down
13 changes: 10 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ repository.
- **Swift format configuration**: Uses `.swift-format` file with 4-space indentation and 120
character line length

### Platform Testing

- **Test all platforms**: `Scripts/test-all-platforms` (runs tests on iOS, macOS, tvOS, and
watchOS simulators using xcodebuild)

### Git Hooks

- **Install git hooks**: `Scripts/install-git-hooks` (installs pre-commit hook that runs lint
check)
- **Install git hooks**: `Scripts/install-git-hooks` (installs both pre-commit and pre-push
hooks)
- **Pre-commit hook**: Automatically runs `Scripts/lint` before each commit
- **Pre-push hook**: Automatically runs `Scripts/test-all-platforms` before each push

### Documentation

Expand Down Expand Up @@ -74,7 +80,8 @@ reproducibility.
- **Test Plans**: Uses `DevTesting.xctestplan` for organized test execution
- **Coverage Target**: Aims for 99%+ test coverage
- **Platform Testing**: Tests run on iOS, macOS, tvOS, and watchOS simulators
- **CI/CD**: GitHub Actions workflow with matrix strategy across platforms
- **CI/CD**: GitHub Actions workflow runs builds on macOS only (iOS, tvOS, and watchOS builds
disabled due to stability/reliability issues)

### Documentation Standards

Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,24 @@ interfaces are fully documented and tested. We aim for overall test coverage ove

To set up the development environment:

1. Run `Scripts/install-git-hooks` to install pre-commit hooks that automatically check code
formatting.
1. Run `Scripts/install-git-hooks` to install git hooks that automatically check code
formatting on commits and run comprehensive tests before pushing.
2. Use `Scripts/lint` to manually check code formatting at any time.
3. Use `Scripts/test-all-platforms` to run tests on all supported platforms locally.


## Continuous Integration

DevTesting uses GitHub Actions for continuous integration. The CI pipeline:

- **Linting**: Automatically checks code formatting on all pull requests using `swift format`
- **Testing**: Runs tests on macOS (iOS, tvOS, and watchOS testing are disabled in CI due to
reliability issues)
- **Coverage**: Generates code coverage reports using xccovPretty

For comprehensive cross-platform testing, developers should run `Scripts/test-all-platforms`
locally or rely on the pre-push git hook which automatically runs all platform tests before
pushing changes.


## Bugs and Feature Requests
Expand Down
33 changes: 33 additions & 0 deletions Scripts/install-git-hooks
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,41 @@ EOF
echo "Pre-commit hook installed successfully!"
}

# Function to install the pre-push hook
install_pre_push_hook() {
local pre_push_hook="$REPO_ROOT/.git/hooks/pre-push"

echo "Installing pre-push hook..."

cat > "$pre_push_hook" << 'EOF'
#!/bin/bash

# Get the directory where this hook is located
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Go to the repository root (two levels up from .git/hooks)
REPO_ROOT="$(dirname "$(dirname "$HOOK_DIR")")"

# Run the test-all-platforms script
echo "Running tests on all platforms..."
if ! "$REPO_ROOT/Scripts/test-all-platforms"; then
echo "Platform tests failed. Please fix issues before pushing."
exit 1
fi

echo "All platform tests passed."
EOF

chmod +x "$pre_push_hook"
echo "Pre-push hook installed successfully!"
}

# Install the pre-commit hook
install_pre_commit_hook

# Install the pre-push hook
install_pre_push_hook

echo "All git hooks installed successfully!"
echo "The pre-commit hook will run 'Scripts/lint' before each commit."
echo "The pre-push hook will run 'Scripts/test-all-platforms' before each push."
59 changes: 59 additions & 0 deletions Scripts/test-all-platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -euo pipefail

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

# Function to print colored output
print_status() {
echo -e "${YELLOW}[$(date +'%H:%M:%S')] $1${NC}"
}

print_success() {
echo -e "${GREEN}✓ $1${NC}"
}

print_error() {
echo -e "${RED}✗ $1${NC}"
}

# Platforms to test
PLATFORMS=(
"iOS Simulator,name=iPhone 16 Pro"
"macOS"
"tvOS Simulator,name=Apple TV 4K"
"watchOS Simulator,name=Apple Watch Series 10"
)

SCHEME="DevTesting"
FAILED_PLATFORMS=()

print_status "Starting tests on all platforms..."
echo

for platform in "${PLATFORMS[@]}"; do
platform_name=$(echo "$platform" | cut -d',' -f1)
print_status "Testing on $platform_name..."

if xcodebuild test -scheme "$SCHEME" -destination "platform=$platform"; then
print_success "$platform_name tests passed"
else
print_error "$platform_name tests failed"
FAILED_PLATFORMS+=("$platform_name")
fi
echo
done

# Summary
echo "=========================="
if [ ${#FAILED_PLATFORMS[@]} -eq 0 ]; then
print_success "All platform tests passed!"
exit 0
else
print_error "Tests failed on: ${FAILED_PLATFORMS[*]}"
exit 1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ struct URLComponents_RandomTests {
let nilFragmentPercentage = Double(nilFragmentCount) / Double(iterationCount)
let nilQueryItemsPercentage = Double(nilQueryItemsCount) / Double(iterationCount)

#expect(nilFragmentPercentage.isApproximatelyEqual(to: 0.5, absoluteTolerance: 0.03))
#expect(nilQueryItemsPercentage.isApproximatelyEqual(to: 0.5, absoluteTolerance: 0.03))
#expect(nilFragmentPercentage.isApproximatelyEqual(to: 0.5, absoluteTolerance: 0.05))
#expect(nilQueryItemsPercentage.isApproximatelyEqual(to: 0.5, absoluteTolerance: 0.05))
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ struct URLQueryItem_RandomTests {
}

let nilValuePercentage = Double(nilValueCount) / Double(iterationCount)
#expect(nilValuePercentage.isApproximatelyEqual(to: 0.1, absoluteTolerance: 0.03))
#expect(nilValuePercentage.isApproximatelyEqual(to: 0.1, absoluteTolerance: 0.05))
}
}