Skip to content

Run CI on macOS 13 #1206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 21, 2023
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
17 changes: 8 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
name: Build and test
on: [push, pull_request]
env:
IOS_SIMULATOR: iPhone 12
IOS_VERSION: "15.2"
IOS_SIMULATOR: "iPhone 14"
IOS_VERSION: "16.2"
jobs:
build:
runs-on: macos-11
runs-on: macos-13
steps:
- uses: actions/checkout@v2
- name: Install
- name: "Select Xcode"
# Currently only works with Xcode 14.2:
# https://github.com/CocoaPods/CocoaPods/issues/11839
run: |
gem update bundler
gem install xcpretty --no-document
brew update
brew outdated carthage || brew upgrade carthage
brew outdated swiftlint || brew upgrade swiftlint
xcode-select -p
sudo xcode-select -s /Applications/Xcode_14.2.app/Contents/Developer
- name: "Lint"
run: make lint
- name: "Run tests (PACKAGE_MANAGER_COMMAND: test)"
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ DerivedData
# Carthage
/Carthage/

# Makefile
bin/

# Swift Package Manager
.build
Packages/
.swiftpm/
7 changes: 5 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
opt_in_rules:
- shorthand_optional_binding
disabled_rules: # rule identifiers to exclude from running
- todo
- operator_whitespace
- large_tuple
- closure_parameter_position
- inclusive_language # sqlite_master etc.
- blanket_disable_command
included: # paths to include during linting. `--path` is ignored if present. takes precendence over `excluded`.
- Sources
- Tests
Expand All @@ -26,8 +29,8 @@ identifier_name:
- SQLITE_TRANSIENT

type_body_length:
warning: 260
error: 260
warning: 350
error: 350

function_body_length:
warning: 60
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.15.0 (unreleased)
========================================

* New minimum deployment targets: iOS/tvOS 11.0, watchOS 4.0

0.14.1 (01-11-2022), [diff][diff-0.14.1]
========================================

Expand Down
31 changes: 14 additions & 17 deletions Documentation/Index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@

## Installation

> _Note:_ SQLite.swift requires Swift 5 (and
> [Xcode 10.2](https://developer.apple.com/xcode/downloads/)) or greater.

### Swift Package Manager

The [Swift Package Manager][] is a tool for managing the distribution of
Expand Down Expand Up @@ -1142,11 +1139,11 @@ let query = managers
chain.with(chain, recursive: true, as: query)
// WITH RECURSIVE
// "chain" AS (
// SELECT * FROM "managers" WHERE "id" = 8
// UNION
// SELECT * from "chain"
// SELECT * FROM "managers" WHERE "id" = 8
// UNION
// SELECT * from "chain"
// JOIN "managers" ON "chain"."manager_id" = "managers"."id"
// )
// )
// SELECT * FROM "chain"
```

Expand All @@ -1156,7 +1153,7 @@ Column names and a materialization hint can optionally be provided.
// Add a "level" column to the query representing manager's position in the chain
let level = Expression<Int64>("level")

let queryWithLevel =
let queryWithLevel =
managers
.select(id, managerId, 0)
.where(id == 8)
Expand All @@ -1166,18 +1163,18 @@ let queryWithLevel =
.join(managers, on: chain[managerId] == managers[id])
)

chain.with(chain,
columns: [id, managerId, level],
chain.with(chain,
columns: [id, managerId, level],
recursive: true,
hint: .materialize,
as: queryWithLevel)
// WITH RECURSIVE
// "chain" ("id", "manager_id", "level") AS MATERIALIZED (
// SELECT ("id", "manager_id", 0) FROM "managers" WHERE "id" = 8
// UNION
// SELECT ("manager"."id", "manager"."manager_id", "level" + 1) FROM "chain"
// SELECT ("id", "manager_id", 0) FROM "managers" WHERE "id" = 8
// UNION
// SELECT ("manager"."id", "manager"."manager_id", "level" + 1) FROM "chain"
// JOIN "managers" ON "chain"."manager_id" = "managers"."id"
// )
// )
// SELECT * FROM "chain"
```

Expand Down Expand Up @@ -1266,7 +1263,7 @@ let count = try db.scalar(users.filter(name != nil).count)
We can upsert rows into a table by calling a [query’s](#queries) `upsert`
function with a list of [setters](#setters)—typically [typed column
expressions](#expressions) and values (which can also be expressions)—each
joined by the `<-` operator. Upserting is like inserting, except if there is a
joined by the `<-` operator. Upserting is like inserting, except if there is a
conflict on the specified column value, SQLite will perform an update on the row instead.

```swift
Expand Down Expand Up @@ -1957,7 +1954,7 @@ for row in stmt.bind(kUTTypeImage) { /* ... */ }
```

> _Note:_ Prepared queries can be reused, and long lived prepared queries should be `reset()` after each use. Otherwise, the transaction (either [implicit or explicit](https://www.sqlite.org/lang_transaction.html#implicit_versus_explicit_transactions)) will be held open until the query is reset or finalized. This can affect performance. Statements are reset automatically during `deinit`.
>
>
> ```swift
> someObj.statement = try db.prepare("SELECT * FROM attachments WHERE typeConformsTo(UTI, ?)")
> for row in someObj.statement.bind(kUTTypeImage) { /* ... */ }
Expand Down Expand Up @@ -2134,7 +2131,7 @@ using the following functions.
}
}
```

- `run` prepares a single `Statement` object from a SQL string, optionally
binds values to it (using the statement’s `bind` function), executes,
and returns the statement.
Expand Down
81 changes: 58 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,76 @@
BUILD_TOOL = xcodebuild
XCODEBUILD = xcodebuild
BUILD_SCHEME = SQLite Mac
IOS_SIMULATOR = iPhone 12
IOS_VERSION = 15.0
IOS_SIMULATOR = iPhone 14
IOS_VERSION = 16.4

# tool settings
SWIFTLINT_VERSION=0.52.2
SWIFTLINT=bin/swiftlint-$(SWIFTLINT_VERSION)
SWIFTLINT_URL=https://github.com/realm/SwiftLint/releases/download/$(SWIFTLINT_VERSION)/portable_swiftlint.zip
XCBEAUTIFY_VERSION=0.20.0
XCBEAUTIFY=bin/xcbeautify-$(XCBEAUTIFY_VERSION)
ifeq ($(shell uname), Linux)
XCBEAUTIFY_PLATFORM=x86_64-unknown-linux-gnu.tar.xz
else
XCBEAUTIFY_PLATFORM=universal-apple-macosx.zip
endif
XCBEAUTIFY_URL=https://github.com/tuist/xcbeautify/releases/download/$(XCBEAUTIFY_VERSION)/xcbeautify-$(XCBEAUTIFY_VERSION)-$(XCBEAUTIFY_PLATFORM)
CURL_OPTS=--fail --silent -L --retry 3

ifeq ($(BUILD_SCHEME),SQLite iOS)
BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" -destination "platform=iOS Simulator,name=$(IOS_SIMULATOR),OS=$(IOS_VERSION)"
else
BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)"
endif

XCPRETTY := $(shell command -v xcpretty)
TEST_ACTIONS := clean build build-for-testing test-without-building
test: $(XCBEAUTIFY)
set -o pipefail; \
$(XCODEBUILD) $(BUILD_ARGUMENTS) test | $(XCBEAUTIFY)

default: test
build: $(XCBEAUTIFY)
set -o pipefail; \
$(XCODEBUILD) $(BUILD_ARGUMENTS) | $(XCBEAUTIFY)

build:
$(BUILD_TOOL) $(BUILD_ARGUMENTS)
lint: $(SWIFTLINT)
$< --strict

lint:
swiftlint --strict
lint-fix:
swiftlint lint fix

test:
ifdef XCPRETTY
@set -o pipefail && $(BUILD_TOOL) $(BUILD_ARGUMENTS) $(TEST_ACTIONS) | $(XCPRETTY) -c
else
$(BUILD_TOOL) $(BUILD_ARGUMENTS) $(TEST_ACTIONS)
endif
lint-fix: $(SWIFTLINT)
$< lint fix

clean:
$(BUILD_TOOL) $(BUILD_ARGUMENTS) clean
$(XCODEBUILD) $(BUILD_ARGUMENTS) clean

repl:
@$(BUILD_TOOL) $(BUILD_ARGUMENTS) -derivedDataPath $(TMPDIR)/SQLite.swift > /dev/null && \
swift -F '$(TMPDIR)/SQLite.swift/Build/Products/Debug'
@$(XCODEBUILD) $(BUILD_ARGUMENTS) -derivedDataPath $(TMPDIR)/SQLite.swift > /dev/null && \
swift repl -F '$(TMPDIR)/SQLite.swift/Build/Products/Debug'

sloc:
@zsh -c "grep -vE '^ *//|^$$' Sources/**/*.{swift,h,m} | wc -l"
@zsh -c "grep -vE '^ *//|^$$' Sources/**/*.{swift,h} | wc -l"

$(SWIFTLINT):
set -e ; \
curl $(CURL_OPTS) $(SWIFTLINT_URL) -o swiftlint.zip; \
unzip -o swiftlint.zip swiftlint; \
mkdir -p bin; \
mv swiftlint $@ && rm -f swiftlint.zip

$(XCBEAUTIFY):
set -e; \
FILE=$(XCBEAUTIFY_PLATFORM); \
curl $(CURL_OPTS) $(XCBEAUTIFY_URL) -o $$FILE; \
case "$${FILE#*.}" in \
"zip") \
unzip -o $$FILE xcbeautify; \
;; \
"tar.xz") \
tar -xvf $$FILE xcbeautify; \
;; \
*) \
echo "unknown extension $${FILE#*.}!"; \
exit 1; \
;; \
esac; \
mkdir -p bin; \
mv xcbeautify $@ && rm -f $$FILE;

.PHONY: test clean repl sloc
10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// swift-tools-version:5.3
// swift-tools-version:5.7
import PackageDescription

let package = Package(
name: "SQLite.swift",
platforms: [
.iOS(.v9),
.macOS(.v10_10),
.watchOS(.v3),
.tvOS(.v9)
.iOS(.v11),
.macOS(.v10_13),
.watchOS(.v4),
.tvOS(.v11)
],
products: [
.library(
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ API.
// Wrap everything in a do...catch to handle errors
do {
// ...

let stmt = try db.prepare("INSERT INTO users (email) VALUES (?)")
for email in ["betty@icloud.com", "cathy@icloud.com"] {
try stmt.run(email)
Expand Down Expand Up @@ -119,9 +119,6 @@ interactively, from the Xcode project’s playground.

## Installation

> _Note:_ Version 0.11.6 and later requires Swift 5 (and [Xcode](https://developer.apple.com/xcode/downloads/) 10.2) or greater.
> Version 0.11.5 requires Swift 4.2 (and [Xcode](https://developer.apple.com/xcode/downloads/) 10.1) or greater.

### Swift Package Manager

The [Swift Package Manager][] is a tool for managing the distribution of
Expand Down
8 changes: 4 additions & 4 deletions SQLite.swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Pod::Spec.new do |s|
s.default_subspec = 'standard'
s.swift_versions = ['5']

ios_deployment_target = '9.0'
tvos_deployment_target = '9.1'
osx_deployment_target = '10.10'
watchos_deployment_target = '3.0'
ios_deployment_target = '11.0'
tvos_deployment_target = '11.0'
osx_deployment_target = '10.13'
watchos_deployment_target = '4.0'

s.ios.deployment_target = ios_deployment_target
s.tvos.deployment_target = tvos_deployment_target
Expand Down
Loading