Skip to content

Commit

Permalink
use Mint for formatting since it broke with SPM
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrence-forooghian committed Aug 2, 2024
1 parent 6521756 commit 4459f38
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 10 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,25 @@ jobs:
lint:
runs-on: macos-latest

# From actions/cache documentation linked to below
env:
MINT_PATH: .mint/lib
MINT_LINK_PATH: .mint/bin

steps:
- uses: actions/checkout@v4

# https://github.com/actions/cache/blob/40c3b67b2955d93d83b27ed164edd0756bc24049/examples.md#swift---mint
- uses: actions/cache@v3
with:
path: .mint
key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }}
restore-keys: |
${{ runner.os }}-mint-
- run: npm ci
- run: brew install mint
- run: mint bootstrap

- run: script/format/check
- run: script/lint/check
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Contributing

## Requirements

- Mint TODO link then run `mint bootstrap`

TODO

- shellcheck
Expand Down
2 changes: 2 additions & 0 deletions Mintfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
realm/[email protected]
nicklockwood/[email protected]
4 changes: 2 additions & 2 deletions Sources/BuildTool/BuildTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ struct BuildTool: ParsableCommand {
let runtimeIdentifier = "com.apple.CoreSimulator.SimRuntime.\(destinationPredicate.runtime)"
let deviceTypeIdentifier = "com.apple.CoreSimulator.SimDeviceType.\(destinationPredicate.deviceType)"

let matchingDevices = (simctlOutput.devices[runtimeIdentifier] ?? []).filter({ $0.deviceTypeIdentifier == deviceTypeIdentifier })
let matchingDevices = (simctlOutput.devices[runtimeIdentifier] ?? []).filter { $0.deviceTypeIdentifier == deviceTypeIdentifier }

guard matchingDevices.count > 0 else {
guard !matchingDevices.isEmpty else {
throw Error.simulatorLookupFailed(message: "Couldn’t find a simulator with runtime \(runtimeIdentifier) and device type \(deviceTypeIdentifier); available devices are \(simctlOutput.devices)")
}

Expand Down
4 changes: 1 addition & 3 deletions script/format/check
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ set -e
# - SwiftFormat for formatting Swift code
# - Prettier for formatting everything else (e.g. YAML, JSON, Markdown)

# Without specifying --cache we get a warning of "Failed to write cache file at /Users/lawrence/Library/Caches/com.charcoaldesign.swiftformat/swiftformat.cache."; presumably this is to do with sandboxing restrictions imposed on Swift package scripts.
swift package plugin --allow-writing-to-package-directory swiftformat --cache .swiftformat-cache --lint .

mint run swiftformat --lint .
npm run format:check
4 changes: 1 addition & 3 deletions script/format/fix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@

set -e

# (See the `check` script for why we specify --cache. The repetition is because, according to https://github.com/nicklockwood/SwiftFormat/issues/1651#issuecomment-2009943414, you can’t use a .swiftformat file to specify the --cache option.)
swift package plugin --allow-writing-to-package-directory swiftformat --cache .swiftformat-cache .

mint run swiftformat .
npm run format:fix
2 changes: 1 addition & 1 deletion script/lint/check
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -e

swift package plugin swiftlint
mint run swiftlint
2 changes: 1 addition & 1 deletion script/lint/fix
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -e

swift package plugin --allow-writing-to-package-directory swiftlint --fix
mint run swiftlint --fix

0 comments on commit 4459f38

Please sign in to comment.