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
47 changes: 45 additions & 2 deletions .github/workflows/pr_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ on:
- "BrewUITests/**"
- "Brew.xcodeproj/**"
- "Brew.entitlements"
- "Sources/**"
- "Tests/**"
- "Package.swift"
- "Package.resolved"
- "Tools/BrewUILint/**"
- "scripts/test"
- ".github/workflows/pr_build_test.yml"
Comment thread
Copilot marked this conversation as resolved.
pull_request:
types: [opened, reopened, synchronize]
Expand All @@ -20,7 +25,12 @@ on:
- "BrewUITests/**"
- "Brew.xcodeproj/**"
- "Brew.entitlements"
- "Sources/**"
- "Tests/**"
- "Package.swift"
- "Package.resolved"
- "Tools/BrewUILint/**"
- "scripts/test"
- ".github/workflows/pr_build_test.yml"
Comment thread
graeme marked this conversation as resolved.

permissions:
Expand All @@ -42,7 +52,7 @@ jobs:
- name: Resolve package dependencies
run: xcodebuild -resolvePackageDependencies -project Brew.xcodeproj

- name: Build and test
- name: Build and test (Xcode app target)
run: |
set -o pipefail
xcodebuild test \
Expand All @@ -57,10 +67,43 @@ jobs:
CODE_SIGNING_ALLOWED=NO \
| tee xcodebuild.log

- name: Capture Swift toolchain fingerprint
id: swift-toolchain
run: echo "fingerprint=$(swift --version | shasum -a 256 | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"

- name: Cache BrewKit .build
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: .build
key: ${{ runner.os }}-brewkit-${{ steps.swift-toolchain.outputs.fingerprint }}-${{ hashFiles('Package.swift', 'Package.resolved') }}
restore-keys: |
${{ runner.os }}-brewkit-${{ steps.swift-toolchain.outputs.fingerprint }}-

- name: Run BrewKit package tests
run: |
set -o pipefail
xcrun swift test --package-path . | tee swift-test-brewkit.log

- name: Cache BrewUILint .build
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: Tools/BrewUILint/.build
key: ${{ runner.os }}-brewuilint-${{ steps.swift-toolchain.outputs.fingerprint }}-${{ hashFiles('Tools/BrewUILint/Package.swift', 'Tools/BrewUILint/Package.resolved', 'Tools/BrewUILint/Sources/**', 'Tools/BrewUILint/Tests/**', 'Tools/BrewUILint/Plugins/**') }}
restore-keys: |
${{ runner.os }}-brewuilint-${{ steps.swift-toolchain.outputs.fingerprint }}-

- name: Run BrewUILint package tests
run: |
set -o pipefail
xcrun swift test --package-path Tools/BrewUILint | tee swift-test-brewuilint.log

- name: Upload logs on failure
if: failure() || cancelled()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr-build-test-logs
path: xcodebuild.log
path: |
xcodebuild.log
swift-test-brewkit.log
swift-test-brewuilint.log
retention-days: 7
8 changes: 6 additions & 2 deletions .github/workflows/swift_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@ jobs:
- name: Run SwiftLint (strict)
run: mint run swiftlint lint --strict

- name: Capture Swift toolchain fingerprint
id: swift-toolchain
run: echo "fingerprint=$(swift --version | shasum -a 256 | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"

- name: Cache BrewUILint build
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: Tools/BrewUILint/.build
key: ${{ runner.os }}-brewuilint-${{ hashFiles('Tools/BrewUILint/Package.swift', 'Tools/BrewUILint/Package.resolved', 'Tools/BrewUILint/Sources/**', 'Tools/BrewUILint/Plugins/**') }}
key: ${{ runner.os }}-brewuilint-${{ steps.swift-toolchain.outputs.fingerprint }}-${{ hashFiles('Tools/BrewUILint/Package.swift', 'Tools/BrewUILint/Package.resolved', 'Tools/BrewUILint/Sources/**', 'Tools/BrewUILint/Plugins/**') }}
restore-keys: |
${{ runner.os }}-brewuilint-
${{ runner.os }}-brewuilint-${{ steps.swift-toolchain.outputs.fingerprint }}-

- name: Build BrewUILint
run: swift build --package-path Tools/BrewUILint -c release --enable-experimental-prebuilts
Expand Down
11 changes: 11 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ When you change Swift sources or anything that affects Swift formatting or linti

The pre-commit hook formats and lints **staged** Swift files (SwiftFormat/SwiftLint) and additionally runs **BrewUILint over the whole tree** on every commit; these manual commands validate the whole tree like CI and catch drift in unstaged paths.

### Tests (local parity with CI)

`scripts/test` runs `swift test` for both packages — `BrewKit` (root `Package.swift`) and `BrewUILint` (`Tools/BrewUILint/Package.swift`) — matching what `.github/workflows/pr_build_test.yml` runs in CI.

**Agents must run `scripts/test` and confirm it exits 0 at both of these points:**

1. **Before any `git commit` you make.** Tests are intentionally **not** enforced by the pre-commit git hook (too slow to run on every staged-file commit during interactive work), so the responsibility moves to the agent. If `scripts/test` fails, fix it before committing — do not commit with failures, and do not skip the run.
2. **Before reporting a code-changing turn complete to the user,** when that turn modified Swift sources under `Sources/`, `Tests/`, `Brew/`, or `Tools/BrewUILint/`, *or* changed `Package.swift` / `Package.resolved` / `.github/workflows/pr_build_test.yml`. For turns that only touch docs, YAML unrelated to tests, or other non-Swift files, the run is optional.

If a test failure surfaces a real regression that's out of scope for the current turn, surface it to the user rather than silently skipping it — never paper over a red test with `.disabled` or `--filter` exclusions without flagging.

---

## What Lives Where
Expand Down
19 changes: 19 additions & 0 deletions scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
#
# test — run all Swift Package tests (BrewKit + BrewUILint).
#
# Mirrors what CI runs in .github/workflows/pr_build_test.yml, so green
# locally means green on CI.

set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"

echo "==> BrewKit package tests"
xcrun swift test --package-path .

echo "==> BrewUILint package tests"
xcrun swift test --package-path Tools/BrewUILint

echo "==> All package tests passed."