Skip to content

Commit 36afd25

Browse files
Prachi Gauriarprachigauriar
authored andcommitted
Update scripts, docs, and scripts to latest and greatest
- Re-enable non-macOS builds - Update lint rules to be slightly more permissive - Update GitHub Actions workflow to be a little more sophisticated - Clean up scripts
1 parent c1007b9 commit 36afd25

File tree

9 files changed

+80
-164
lines changed

9 files changed

+80
-164
lines changed

.claude/settings.local.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(Scripts/lint)"
5+
]
6+
}
7+
}

.github/workflows/VerifyChanges.yaml

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,22 @@ on:
66
push:
77
branches: ["main"]
88

9-
env:
10-
XCODE_VERSION: 26.0.1
11-
129
jobs:
13-
lint:
14-
name: Lint
15-
runs-on: macos-26
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v4
19-
- name: Select Xcode ${{ env.XCODE_VERSION }}
20-
run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app
21-
- name: Lint
22-
run: |
23-
Scripts/lint
24-
2510
build-and-test:
2611
name: Build and Test (${{ matrix.platform }})
27-
needs: lint
2812
runs-on: macos-26
2913
strategy:
3014
fail-fast: false
3115
matrix:
3216
include:
33-
# - platform: iOS
34-
# xcode_destination: "platform=iOS Simulator,name=iPhone 17 Pro"
17+
- platform: iOS
18+
xcode_destination: "platform=iOS Simulator,name=iPhone 17 Pro"
3519
- platform: macOS
3620
xcode_destination: "platform=macOS,arch=arm64"
37-
# - platform: tvOS
38-
# xcode_destination: "platform=tvOS Simulator,name=Apple TV 4K (3rd generation)"
39-
# - platform: watchOS
40-
# xcode_destination: "platform=watchOS Simulator,name=Apple Watch Series 10 (46mm)"
21+
- platform: tvOS
22+
xcode_destination: "platform=tvOS Simulator,name=Apple TV 4K (3rd generation)"
23+
- platform: watchOS
24+
xcode_destination: "platform=watchOS Simulator,name=Apple Watch Series 11 (46mm)"
4125

4226
env:
4327
DEV_BUILDS: DevBuilds/Sources
@@ -47,39 +31,43 @@ jobs:
4731
XCODE_DESTINATION: ${{ matrix.xcode_destination }}
4832
XCODE_TEST_PLAN: DevTesting
4933
XCODE_TEST_PRODUCTS_PATH: .build/DevTesting.xctestproducts
34+
XCODE_VERSION: 26.3
5035

5136
steps:
5237
- name: Select Xcode ${{ env.XCODE_VERSION }}
53-
run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app
38+
run: sudo xcode-select -s /Applications/Xcode_"$XCODE_VERSION".app
5439

5540
- name: Checkout
56-
uses: actions/checkout@v4
41+
uses: actions/checkout@v6
5742

5843
- name: Checkout DevBuilds
59-
uses: actions/checkout@v4
44+
uses: actions/checkout@v6
6045
with:
6146
repository: DevKitOrganization/DevBuilds
6247
path: DevBuilds
6348

6449
- name: Restore XCTestProducts
6550
if: github.event_name != 'push'
6651
id: cache-xctestproducts-restore
67-
uses: actions/cache/restore@v4
52+
uses: actions/cache/restore@v5
6853
with:
6954
path: ${{ env.XCODE_TEST_PRODUCTS_PATH }}
7055
key: cache-xctestproducts-${{ github.workflow }}-${{ matrix.platform }}-${{ github.sha }}
7156

57+
- name: Lint
58+
if: steps.cache-xctestproducts-restore.outputs.cache-hit != 'true'
59+
run: Scripts/lint
60+
7261
- uses: irgaly/xcode-cache@v1
7362
if: steps.cache-xctestproducts-restore.outputs.cache-hit != 'true'
7463
with:
75-
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ matrix.platform }}-${{ github.sha }}
64+
key: xcode-cache-deriveddata-${{ env.XCODE_VERSION }}-${{ github.workflow }}-${{ matrix.platform }}-${{ github.sha }}
7665
restore-keys: |
77-
xcode-cache-deriveddata-${{ github.workflow }}-${{ matrix.platform }}-
78-
xcode-cache-deriveddata-
66+
xcode-cache-deriveddata-${{ env.XCODE_VERSION }}-${{ github.workflow }}-${{ matrix.platform }}-
67+
xcode-cache-deriveddata-${{ env.XCODE_VERSION }}
7968
deriveddata-directory: .build/DerivedData
8069
sourcepackages-directory: .build/DerivedData/SourcePackages
8170
swiftpm-package-resolved-file: Package.resolved
82-
verbose: true
8371

8472
- name: Build for Testing
8573
id: build-for-testing
@@ -92,8 +80,8 @@ jobs:
9280
run: ${{ env.DEV_BUILDS }}/build_and_test.sh --action test-without-building
9381

9482
- name: Save XCTestProducts
95-
if: failure() && steps.cache-xctestproducts-restore.outputs.cache-hit != 'true'
96-
uses: actions/cache/save@v4
83+
if: (cancelled() || failure()) && steps.cache-xctestproducts-restore.outputs.cache-hit != 'true'
84+
uses: actions/cache/save@v5
9785
with:
9886
path: ${{ env.XCODE_TEST_PRODUCTS_PATH }}
9987
key: ${{ steps.cache-xctestproducts-restore.outputs.cache-primary-key }}
@@ -116,7 +104,7 @@ jobs:
116104
117105
- name: Upload Logs and XCResults
118106
if: success() || failure()
119-
uses: actions/upload-artifact@v4
107+
uses: actions/upload-artifact@v7
120108
with:
121109
name: Logs_and_XCResults-${{ matrix.platform }}
122110
path: |
@@ -126,7 +114,7 @@ jobs:
126114

127115
- name: Upload xccovPretty output
128116
if: github.event_name != 'push'
129-
uses: actions/upload-artifact@v4
117+
uses: actions/upload-artifact@v7
130118
with:
131119
name: xccovPrettyOutput-${{ matrix.platform }}
132120
path: .build/xccovPretty-${{ matrix.platform }}.output
@@ -142,7 +130,7 @@ jobs:
142130

143131
steps:
144132
- name: Download xccovPretty output
145-
uses: actions/download-artifact@v4
133+
uses: actions/download-artifact@v8
146134
with:
147135
name: xccovPrettyOutput-macOS
148136

.swift-format

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@
5959
"ReplaceForEachWithForLoop": true,
6060
"ReturnVoidInsteadOfEmptyTuple": true,
6161
"TypeNamesShouldBeCapitalized": true,
62-
"UseEarlyExits": true,
62+
"UseEarlyExits": false,
6363
"UseExplicitNilCheckInConditions": true,
6464
"UseLetInEveryBoundCaseVariable": true,
6565
"UseShorthandTypeNames": true,
6666
"UseSingleLinePropertyGetter": true,
6767
"UseSynthesizedInitializer": true,
6868
"UseTripleSlashForDocumentationComments": true,
69-
"UseWhereClausesInForLoops": true,
69+
"UseWhereClausesInForLoops": false,
7070
"ValidateDocumentationComments": false
7171
},
7272
"spacesAroundRangeFormationOperators": true,

CLAUDE.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,11 @@ repository.
2323
- **Swift format configuration**: Uses `.swift-format` file with 4-space indentation and 120
2424
character line length
2525

26-
### Platform Testing
27-
28-
- **Test all platforms**: `Scripts/test-all-platforms` (runs tests on iOS, macOS, tvOS, and
29-
watchOS simulators using xcodebuild)
30-
3126
### Git Hooks
3227

33-
- **Install git hooks**: `Scripts/install-git-hooks` (installs both pre-commit and pre-push
34-
hooks)
35-
- **Pre-commit hook**: Automatically runs `Scripts/lint` before each commit
36-
- **Pre-push hook**: Automatically runs `Scripts/test-all-platforms` before each push
28+
- **Install git hooks**: `Scripts/install-git-hooks` (installs pre-push hook; supports git
29+
worktrees)
30+
- **Pre-push hook**: Automatically runs `Scripts/lint` before each push
3731

3832
### Documentation
3933

@@ -80,8 +74,28 @@ reproducibility.
8074
- **Test Plans**: Uses `DevTesting.xctestplan` for organized test execution
8175
- **Coverage Target**: Aims for 99%+ test coverage
8276
- **Platform Testing**: Tests run on iOS, macOS, tvOS, and watchOS simulators
83-
- **CI/CD**: GitHub Actions workflow runs builds on macOS only (iOS, tvOS, and watchOS builds
84-
disabled due to stability/reliability issues)
77+
- **CI/CD**: GitHub Actions workflow runs builds on iOS, macOS, tvOS, and watchOS
78+
79+
### Code Style Conventions
80+
81+
- Always use `where` clauses to declare constraints on generic parameters
82+
- Prefer `Float64` over `Double` and `Float32` over `Float`
83+
- Always attribute files to the current user, not Claude (e.g., "Created by <current user>
84+
on mm/dd/yyyy")
85+
86+
#### Code Formatting and Spacing
87+
88+
- **2 blank lines between major sections** including:
89+
- Between the last property declaration and first function declaration
90+
- Between all function/computed property implementations at the same scope level
91+
- Between top-level type declarations (class, struct, enum, protocol, extension)
92+
- Before MARK comments that separate major sections
93+
- **1 blank line** for minor separations:
94+
- Between property declarations and nested type definitions
95+
- Between all function definitions in protocols
96+
- After headers in documentation
97+
- After MARK comments that separate major sections
98+
- **File endings**: All Swift files must end with exactly one blank line
8599

86100
### Documentation Standards
87101

Documentation/MarkdownStyleGuide.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Markdown Style Guide
22

3-
This document defines the Markdown formatting standards for documentation in the Shopper iOS
4-
codebase.
3+
This document defines the Markdown formatting standards for documentation in this codebase.
54

65

76
## General Formatting

README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,20 @@ interfaces are fully documented and tested. We aim for overall test coverage ove
3838

3939
To set up the development environment:
4040

41-
1. Run `Scripts/install-git-hooks` to install git hooks that automatically check code
42-
formatting on commits and run comprehensive tests before pushing.
41+
1. Run `Scripts/install-git-hooks` to install the pre-push hook that automatically checks
42+
code formatting before pushing.
4343
2. Use `Scripts/lint` to manually check code formatting at any time.
44-
3. Use `Scripts/test-all-platforms` to run tests on all supported platforms locally.
44+
3. Use `Scripts/format` to auto-fix code formatting issues.
4545

4646

4747
## Continuous Integration
4848

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

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

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

6156
## Bugs and Feature Requests
6257

Scripts/format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ REPO_ROOT="$(dirname "$SCRIPT_DIR")"
88

99
# Run swift format with --in-place to fix formatting issues
1010
swift format --in-place --recursive \
11-
"$REPO_ROOT/Packages/" \
1211
"$REPO_ROOT/Sources/" \
1312
"$REPO_ROOT/Tests/"

Scripts/install-git-hooks

Lines changed: 18 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,78 +6,51 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66
# Go to the repository root (one level up from Scripts)
77
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
88

9-
# Check if we're in a git repository
10-
if [ ! -d "$REPO_ROOT/.git" ]; then
9+
# Check if we're in a git repository and get the git directory
10+
# This works for both regular repos and worktrees
11+
cd "$REPO_ROOT"
12+
if ! git rev-parse --git-dir > /dev/null 2>&1; then
1113
echo "Error: Not in a git repository"
1214
exit 1
1315
fi
1416

15-
mkdir -p "$REPO_ROOT/.git/hooks"
16-
17-
# Function to install the pre-commit hook
18-
install_pre_commit_hook() {
19-
local pre_commit_hook="$REPO_ROOT/.git/hooks/pre-commit"
20-
21-
echo "Installing pre-commit hook..."
22-
23-
cat > "$pre_commit_hook" << 'EOF'
24-
#!/bin/bash
25-
26-
# Get the directory where this hook is located
27-
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
28-
29-
# Go to the repository root (two levels up from .git/hooks)
30-
REPO_ROOT="$(dirname "$(dirname "$HOOK_DIR")")"
31-
32-
# Run the lint script
33-
echo "Running lint check..."
34-
if ! "$REPO_ROOT/Scripts/lint"; then
35-
echo "Lint check failed. Please fix formatting issues before committing."
17+
# Get the common git directory (shared across all worktrees)
18+
GIT_COMMON_DIR="$(git rev-parse --git-common-dir)"
19+
if [ ! -d "$GIT_COMMON_DIR" ]; then
20+
echo "Error: Could not find git directory"
3621
exit 1
3722
fi
3823

39-
echo "Lint check passed."
40-
EOF
41-
42-
chmod +x "$pre_commit_hook"
43-
echo "Pre-commit hook installed successfully!"
44-
}
24+
mkdir -p "$GIT_COMMON_DIR/hooks"
4525

4626
# Function to install the pre-push hook
4727
install_pre_push_hook() {
48-
local pre_push_hook="$REPO_ROOT/.git/hooks/pre-push"
28+
local pre_push_hook="$GIT_COMMON_DIR/hooks/pre-push"
4929

5030
echo "Installing pre-push hook..."
5131

5232
cat > "$pre_push_hook" << 'EOF'
5333
#!/bin/bash
5434
55-
# Get the directory where this hook is located
56-
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
57-
58-
# Go to the repository root (two levels up from .git/hooks)
59-
REPO_ROOT="$(dirname "$(dirname "$HOOK_DIR")")"
35+
# Resolve the repository root using git, which correctly handles worktrees
36+
REPO_ROOT="$(git rev-parse --show-toplevel)"
6037
61-
# Run the test-all-platforms script
62-
echo "Running tests on all platforms..."
63-
if ! "$REPO_ROOT/Scripts/test-all-platforms"; then
64-
echo "Platform tests failed. Please fix issues before pushing."
38+
# Run the lint script
39+
echo "Running lint check..."
40+
if ! "$REPO_ROOT/Scripts/lint"; then
41+
echo "Lint check failed. Please fix formatting issues before pushing."
6542
exit 1
6643
fi
6744
68-
echo "All platform tests passed."
45+
echo "Lint check passed."
6946
EOF
7047

7148
chmod +x "$pre_push_hook"
7249
echo "Pre-push hook installed successfully!"
7350
}
7451

75-
# Install the pre-commit hook
76-
install_pre_commit_hook
77-
7852
# Install the pre-push hook
7953
install_pre_push_hook
8054

8155
echo "All git hooks installed successfully!"
82-
echo "The pre-commit hook will run 'Scripts/lint' before each commit."
83-
echo "The pre-push hook will run 'Scripts/test-all-platforms' before each push."
56+
echo "The pre-push hook will run 'Scripts/lint' before each push."

0 commit comments

Comments
 (0)