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
128 changes: 128 additions & 0 deletions .github/workflows/VerifyChanges.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Verify Changes

on:
merge_group:
pull_request:
branches: "**"
push:
branches: ["main"]

jobs:
lint:
name: Lint
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode 16.4
run: |
sudo xcode-select -s /Applications/Xcode_16.4.0.app
- name: Lint
run: |
Scripts/lint
build-and-test:
name: Build and Test (${{ matrix.platform }})
needs: lint
runs-on: macos-15
strategy:
fail-fast: false
matrix:
include:
- 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)"
env:
DEV_BUILDS: DevBuilds/Sources
XCCOV_PRETTY_VERSION: 1.2.0
XCODE_SCHEME: DevConfiguration
XCODE_DESTINATION: ${{ matrix.xcode_destination }}
XCODE_TEST_PLAN: DevConfiguration
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout DevBuilds
uses: actions/checkout@v4
with:
repository: DevKitOrganization/DevBuilds
path: DevBuilds
- name: Download xccovPretty
if: github.event_name != 'push'
run: |
gh release download ${{ env.XCCOV_PRETTY_VERSION }} \
--repo DevKitOrganization/xccovPretty \
--pattern "xccovPretty-macos.tar.gz" \
-O - | tar -xz
chmod +x xccovPretty
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: irgaly/xcode-cache@v1
with:
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ matrix.platform }}-${{ github.sha }}
restore-keys: |
xcode-cache-deriveddata-${{ github.workflow }}-${{ matrix.platform }}-
xcode-cache-deriveddata-
deriveddata-directory: .build/DerivedData
sourcepackages-directory: .build/DerivedData/SourcePackages
swiftpm-package-resolved-file: |
**/*.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Package.resolved
verbose: true
- name: Select Xcode 16.4
run: |
sudo xcode-select -s /Applications/Xcode_16.4.0.app
- name: Build for Testing
run: |
"$DEV_BUILDS"/build_and_test.sh --action build-for-testing
- name: Test
if: github.event_name != 'push'
run: |
"$DEV_BUILDS"/build_and_test.sh --action test
- name: Log Code Coverage
if: github.event_name != 'push'
run: |
xcrun xccov view --report .build/DevConfiguration_test.xcresult --json \
| ./xccovPretty --github-comment \
> .build/xccovPretty-${{ matrix.platform }}.output
- name: Upload Logs
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: Logs-${{ matrix.platform }}
path: .build/*.log
include-hidden-files: true
- name: Upload XCResults
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: XCResults-${{ matrix.platform }}
path: .build/*.xcresult
include-hidden-files: true
- name: Upload xccovPretty output
if: github.event_name != 'push'
uses: actions/upload-artifact@v4
with:
name: xccovPrettyOutput-${{ matrix.platform }}
path: .build/xccovPretty-${{ matrix.platform }}.output
include-hidden-files: true
post-pr-comments:
name: Post PR Comments
needs: build-and-test
permissions:
pull-requests: write
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Download xccovPretty output
uses: actions/download-artifact@v4
with:
name: xccovPrettyOutput-iOS
- name: Post Code Coverage Comment
uses: thollander/actions-comment-pull-request@v3
with:
file-path: xccovPretty-iOS.output
comment-tag: codeCoverage-iOS
75 changes: 75 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"indentConditionalCompilationBlocks": false,
"indentSwitchCaseLabels": false,
"indentation": {
"spaces": 4
},
"lineBreakAroundMultilineExpressionChainComponents": false,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": false,
"lineBreakBeforeEachGenericRequirement": false,
"lineBreakBetweenDeclarationAttributes": false,
"lineLength": 120,
"maximumBlankLines": 2,
"multiElementCollectionTrailingCommas": true,
"noAssignmentInExpressions": {
"allowedFunctions": []
},
"prioritizeKeepingFunctionOutputTogether": true,
"reflowMultilineStringLiterals": {
"never": {}
},
"respectsExistingLineBreaks": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLiteralForEmptyCollectionInit": true,
"AlwaysUseLowerCamelCase": true,
"AmbiguousTrailingClosureOverload": true,
"AvoidRetroactiveConformances": false,
"BeginDocumentationCommentWithOneLineSummary": true,
"DoNotUseSemicolons": true,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": false,
"NeverUseImplicitlyUnwrappedOptionals": false,
"NoAccessLevelOnExtensionDeclaration": true,
"NoAssignmentInExpressions": true,
"NoBlockComments": true,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyLinesOpeningClosingBraces": false,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoParensAroundConditions": true,
"NoPlaygroundLiterals": true,
"NoVoidReturnOnFunctionSignature": true,
"OmitExplicitReturns": false,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReplaceForEachWithForLoop": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"TypeNamesShouldBeCapitalized": true,
"UseEarlyExits": true,
"UseExplicitNilCheckInConditions": true,
"UseLetInEveryBoundCaseVariable": true,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": true,
"UseSynthesizedInitializer": true,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": true,
"ValidateDocumentationComments": false
},
"spacesAroundRangeFormationOperators": true,
"spacesBeforeEndOfLineComments": 4,
"tabWidth": 4,
"version": 1
}
84 changes: 84 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/DevConfiguration.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1640"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DevConfiguration"
BuildableName = "DevConfiguration"
BlueprintName = "DevConfiguration"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:Build Support/Test Plans/DevConfiguration.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DevConfigurationTests"
BuildableName = "DevConfigurationTests"
BlueprintName = "DevConfigurationTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DevConfiguration"
BuildableName = "DevConfiguration"
BlueprintName = "DevConfiguration"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
34 changes: 34 additions & 0 deletions Build Support/Test Plans/DevConfiguration.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"configurations" : [
{
"id" : "D4211755-E8F7-47FF-8191-92A8AE4F1284",
"name" : "Test Scheme Action",
"options" : {

}
}
],
"defaultOptions" : {
"codeCoverage" : {
"targets" : [
{
"containerPath" : "container:",
"identifier" : "DevConfiguration",
"name" : "DevConfiguration"
}
]
},
"defaultTestExecutionTimeAllowance" : 60,
"testTimeoutsEnabled" : true
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:",
"identifier" : "DevConfigurationTests",
"name" : "DevConfigurationTests"
}
}
],
"version" : 1
}
50 changes: 50 additions & 0 deletions Scripts/install-git-hooks
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

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

# Go to the repository root (one level up from Scripts)
REPO_ROOT="$(dirname "$SCRIPT_DIR")"

# Check if we're in a git repository
if [ ! -d "$REPO_ROOT/.git" ]; then
echo "Error: Not in a git repository"
exit 1
fi

mkdir -p "$REPO_ROOT/.git/hooks"

# Function to install the pre-commit hook
install_pre_commit_hook() {
local pre_commit_hook="$REPO_ROOT/.git/hooks/pre-commit"

echo "Installing pre-commit hook..."

cat > "$pre_commit_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 lint script
echo "Running lint check..."
if ! "$REPO_ROOT/Scripts/lint"; then
echo "Lint check failed. Please fix formatting issues before committing."
exit 1
fi

echo "Lint check passed."
EOF

chmod +x "$pre_commit_hook"
echo "Pre-commit hook installed successfully!"
}

# Install the pre-commit hook
install_pre_commit_hook

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

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

# Go to the repository root (one level up from Scripts)
REPO_ROOT="$(dirname "$SCRIPT_DIR")"

# Run swift format lint with full paths to preserve user's PWD
swift format lint --recursive --strict "$REPO_ROOT/Sources/" "$REPO_ROOT/Tests/"
Loading
Loading