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
16 changes: 8 additions & 8 deletions .github/workflows/VerifyChanges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ on:
push:
branches: ["main"]

env:
XCODE_VERSION: 26.0.1

jobs:
lint:
name: Lint
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode 26.0.0
run: |
sudo xcode-select -s /Applications/Xcode_26.0.0.app
- name: Select Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app
- name: Lint
run: |
Scripts/lint
run: Scripts/lint
build-and-test:
name: Build and Test (${{ matrix.platform }})
needs: lint
Expand Down Expand Up @@ -68,9 +69,8 @@ jobs:
sourcepackages-directory: .build/DerivedData/SourcePackages
swiftpm-package-resolved-file: Package.resolved
verbose: true
- name: Select Xcode 26.0
run: |
sudo xcode-select -s /Applications/Xcode_26.0.0.app
- name: Select Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app
- name: Build for Testing
run: |
"$DEV_BUILDS"/build_and_test.sh --action build-for-testing
Expand Down
13 changes: 13 additions & 0 deletions Scripts/format
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/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 with --in-place to fix formatting issues
swift format --in-place --recursive \
"$REPO_ROOT/Packages/" \
"$REPO_ROOT/Sources/" \
"$REPO_ROOT/Tests/"
2 changes: 1 addition & 1 deletion Scripts/test-all-platforms
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ print_error() {

# Platforms to test
PLATFORMS=(
"iOS Simulator,name=iPhone 16 Pro"
"iOS Simulator,name=iPhone 17 Pro"
"macOS"
"tvOS Simulator,name=Apple TV 4K"
)
Expand Down
14 changes: 7 additions & 7 deletions Sources/DevColorExtraction/MostCommonColors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension CGImage {
public func mostCommonColors(
count: Int,
passes: Int = 5,
edges: EdgeSet = .none
edges: EdgeSet = .none,
) -> [(color: CGColor, weight: CGFloat)]? {
// Create a CIImage from which to extract the most common colors
let ciImage: CIImage
Expand Down Expand Up @@ -128,7 +128,7 @@ extension CGContext {
bitsPerComponent: 8,
bytesPerRow: width * 4,
space: CGColorSpace(name: CGColorSpace.sRGB)!,
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue,
)
}
}
Expand All @@ -148,7 +148,7 @@ extension CIImage {
fileprivate func mostCommonColors(
count: Int,
extent: CGRect,
passes: Int
passes: Int,
) -> [(color: CGColor, weight: CGFloat)]? {
// Run the k-means filter.
let filter = CIFilter.kMeans()
Expand Down Expand Up @@ -182,7 +182,7 @@ extension CIImage {
let bitmapSize = count * 4
let bitmap = UnsafeMutableRawPointer.allocate(
byteCount: bitmapSize,
alignment: MemoryLayout<UInt8>.alignment
alignment: MemoryLayout<UInt8>.alignment,
)
defer { bitmap.deallocate() }

Expand All @@ -194,7 +194,7 @@ extension CIImage {
rowBytes: bitmapSize,
bounds: CGRect(x: 0, y: 0, width: count, height: 1),
format: .RGBA8,
colorSpace: CGColorSpace(name: CGColorSpace.sRGB)
colorSpace: CGColorSpace(name: CGColorSpace.sRGB),
)

// Extract the RGBA values, with weight corresponding to the alpha value.
Expand All @@ -205,9 +205,9 @@ extension CIImage {
srgbRed: CGFloat(rgbaBuffer[4 * i + 0]) / 255.0,
green: CGFloat(rgbaBuffer[4 * i + 1]) / 255.0,
blue: CGFloat(rgbaBuffer[4 * i + 2]) / 255.0,
alpha: 1.0
alpha: 1.0,
),
weight: CGFloat(rgbaBuffer[4 * i + 3]) / 255.0
weight: CGFloat(rgbaBuffer[4 * i + 3]) / 255.0,
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/DevColorExtractionTests/MostCommonColorsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct MostCommonColorsTests {
expectEqualColors(
result[0].color,
CGColor(srgbRed: red, green: green, blue: blue, alpha: 1.0),
tolerance: 0.15
tolerance: 0.15,
)
}

Expand Down Expand Up @@ -359,7 +359,7 @@ struct MostCommonColorsTests {
fileID: String = #fileID,
filePath: String = #filePath,
line: Int = #line,
column: Int = #column
column: Int = #column,
) {
let sourceLocation = SourceLocation(fileID: fileID, filePath: filePath, line: line, column: column)

Expand All @@ -375,7 +375,7 @@ struct MostCommonColorsTests {
#expect(
actualComponent.isApproximatelyEqual(to: expectedComponent, absoluteTolerance: tolerance),
"Color component \(actualComponent) not within tolerance \(tolerance) of \(expectedComponent)",
sourceLocation: sourceLocation
sourceLocation: sourceLocation,
)
}
}
Expand Down
Loading