Skip to content

Commit f3f7a48

Browse files
authored
Add GitHub actions (#1)
* Add GitHub actions * Remove macro compatibility check * Install SQLite on Linux * Don't run tests in release * Update README
1 parent 7375bc7 commit f3f7a48

File tree

8 files changed

+109
-5
lines changed

8 files changed

+109
-5
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- '*'
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
library:
18+
name: macOS
19+
strategy:
20+
matrix:
21+
xcode: ['16.3']
22+
runs-on: macos-15
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Select Xcode ${{ matrix.xcode }}
26+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
27+
- name: Run tests
28+
run: swift test
29+
- name: Build release
30+
run: swift build -c release
31+
32+
linux:
33+
name: Linux
34+
strategy:
35+
matrix:
36+
swift:
37+
- '6.1'
38+
runs-on: ubuntu-latest
39+
container: swift:${{ matrix.swift }}
40+
steps:
41+
- uses: actions/checkout@v4
42+
- name: Install SQLite
43+
run: apt update && apt -y install libsqlite3-dev
44+
- name: Build
45+
run: swift build

.github/workflows/format.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
NB: Compatible swift-format requires Xcode 16.3, not yet available on GitHub
2+
name: Format
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
concurrency:
10+
group: format-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
swift_format:
15+
name: swift-format
16+
runs-on: macos-15
17+
permissions:
18+
contents: write
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Select Xcode 16.3
22+
run: sudo xcode-select -s /Applications/Xcode_16.3.app
23+
- name: Format
24+
run: make format
25+
- uses: stefanzweifel/git-auto-commit-action@v5
26+
with:
27+
commit_message: Run swift-format
28+
branch: 'main'

Package.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@ for index in package.targets.indices {
114114
package.targets[index].swiftSettings = swiftSettings
115115
}
116116

117+
#if !os(Darwin)
118+
package.targets.append(
119+
.systemLibrary(
120+
name: "StructuredQueriesSQLite3",
121+
providers: [.apt(["libsqlite3-dev"])]
122+
)
123+
)
124+
125+
for index in package.targets.indices {
126+
if package.targets[index].name == "StructuredQueriesSQLite" {
127+
package.targets[index].dependencies.append("StructuredQueriesSQLite3")
128+
}
129+
}
130+
#endif
131+
117132
#if !os(Windows)
118133
// Add the documentation compiler plugin if possible
119134
package.dependencies.append(

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# StructuredQueries
22

3-
<!--
43
[![CI](https://github.com/pointfreeco/swift-structured-queries/workflows/CI/badge.svg)](https://github.com/pointfreeco/swift-structured-queries/actions?query=workflow%3ACI)
5-
-->
6-
74
[![Slack](https://img.shields.io/badge/slack-chat-informational.svg?label=Slack&logo=slack)](https://www.pointfree.co/slack-invite)
85
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-structured-queries%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/pointfreeco/swift-structured-queries)
96
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-structured-queries%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/pointfreeco/swift-structured-queries)

Sources/StructuredQueriesSQLite/Database.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import Foundation
2-
import SQLite3
32
import StructuredQueries
43

4+
#if canImport(Darwin)
5+
import SQLite3
6+
#else
7+
import StructuredQueriesSQLite3
8+
#endif
9+
510
public struct Database {
611
@usableFromInline
712
let storage: Storage

Sources/StructuredQueriesSQLite/SQLiteQueryDecoder.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import SQLite3
21
import StructuredQueries
32

3+
#if canImport(Darwin)
4+
import SQLite3
5+
#else
6+
import StructuredQueriesSQLite3
7+
#endif
8+
49
@usableFromInline
510
struct SQLiteQueryDecoder: QueryDecoder {
611
@usableFromInline
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#ifndef StructuredQueriesSQLite3
2+
#define StructuredQueriesSQLite3
3+
#include <sqlite3.h>
4+
#endif
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module StructuredQueriesSQLite3 [system] {
2+
link "sqlite3"
3+
header "StructuredQueriesSQLite3.h"
4+
export *
5+
}

0 commit comments

Comments
 (0)