diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..d000394
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,45 @@
+name: CI
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ branches:
+ - '*'
+ workflow_dispatch:
+
+jobs:
+ library-apple:
+ runs-on: macos-12
+ strategy:
+ matrix:
+ xcode:
+ - '13.4'
+ env:
+ DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
+ steps:
+ - uses: actions/checkout@v2
+ - name: Run tests
+ run: make test-library-xcode
+ - name: Compile documentation
+ if: ${{ matrix.xcode == '13.4' }}
+ run: make test-docs
+
+ library-linux:
+ runs-on: ubuntu-latest
+ container:
+ image: swift:5.6
+ steps:
+ - uses: actions/checkout@v1.0.0
+ - name: Run tests
+ run: make test-library
+
+ examples:
+ runs-on: macos-12
+ env:
+ DEVELOPER_DIR: /Applications/Xcode_13.4.app/Contents/Developer
+ steps:
+ - uses: actions/checkout@v2
+ - name: Run tests
+ run: make test-examples
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644
index 75514d2..0000000
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-name: CI
-on: push
-
-jobs:
- test-macOS:
- runs-on: macOS-12
- env:
- DEVELOPER_DIR: /Applications/Xcode_13.4.app/Contents/Developer
- steps:
- - uses: actions/checkout@v1.0.0
- - name: SwiftPM Build
- run: swift test
- test-iOS:
- runs-on: macOS-12
- env:
- DEVELOPER_DIR: /Applications/Xcode_13.4.app/Contents/Developer
- steps:
- - uses: actions/checkout@v1.0.0
- - name: xcodebuild
- run: |-
- xcodebuild \
- -scheme Buildkite \
- -destination "platform=iOS Simulator,OS=latest,name=iPhone 13 Pro" \
- -enableCodeCoverage YES \
- -quiet \
- build test
- test-linux:
- runs-on: ubuntu-latest
- container:
- image: swift:5.5
- steps:
- - uses: actions/checkout@v1.0.0
- - name: SwiftPM Build
- run: swift test
diff --git a/.spi.yml b/.spi.yml
new file mode 100644
index 0000000..876d740
--- /dev/null
+++ b/.spi.yml
@@ -0,0 +1,12 @@
+version: 1
+builder:
+ configs:
+ - platform: ios
+ scheme: Buildkite
+ - platform: macos-xcodebuild
+ scheme: Buildkite
+ - platform: tvos
+ scheme: Buildkite
+ - platform: watchos
+ scheme: Buildkite
+ - documentation_targets: [Buildkite]
diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/Buildkite-Package.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/Buildkite-Package.xcscheme
deleted file mode 100644
index a563429..0000000
--- a/.swiftpm/xcode/xcshareddata/xcschemes/Buildkite-Package.xcscheme
+++ /dev/null
@@ -1,114 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/Buildkite.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/Buildkite.xcscheme
index f02fce8..f17499b 100644
--- a/.swiftpm/xcode/xcshareddata/xcschemes/Buildkite.xcscheme
+++ b/.swiftpm/xcode/xcshareddata/xcschemes/Buildkite.xcscheme
@@ -1,6 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Buildkite.xcworkspace/contents.xcworkspacedata b/Buildkite.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..8e3c9a9
--- /dev/null
+++ b/Buildkite.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
diff --git a/Buildkite.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Buildkite.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/Buildkite.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/Examples/Package.swift b/Examples/Package.swift
new file mode 100644
index 0000000..0ab477a
--- /dev/null
+++ b/Examples/Package.swift
@@ -0,0 +1,51 @@
+// swift-tools-version:5.5
+import PackageDescription
+
+let package = Package(
+ name: "Examples",
+ platforms: [
+ .iOS(.v13),
+ .macOS(.v10_15),
+ .tvOS(.v13),
+ .watchOS(.v6),
+ ],
+ products: [
+ .executable(name: "simple", targets: ["simple"]),
+ .executable(name: "graphql", targets: ["graphql"]),
+ .executable(name: "advanced-authorization", targets: ["advanced-authorization"]),
+ .executable(name: "test-analytics", targets: ["test-analytics"]),
+ ],
+ dependencies: [
+ .package(name: "Buildkite", path: "../")
+ ],
+ targets: [
+ .executableTarget(
+ name: "simple",
+ dependencies: [
+ .product(name: "Buildkite", package: "Buildkite")
+ ],
+ path: "simple"
+ ),
+ .executableTarget(
+ name: "graphql",
+ dependencies: [
+ .product(name: "Buildkite", package: "Buildkite")
+ ],
+ path: "graphql"
+ ),
+ .executableTarget(
+ name: "advanced-authorization",
+ dependencies: [
+ .product(name: "Buildkite", package: "Buildkite")
+ ],
+ path: "advanced-authorization"
+ ),
+ .executableTarget(
+ name: "test-analytics",
+ dependencies: [
+ .product(name: "Buildkite", package: "Buildkite")
+ ],
+ path: "test-analytics"
+ ),
+ ]
+)
diff --git a/Examples/advanced-authorization/Example.swift b/Examples/advanced-authorization/Example.swift
new file mode 100644
index 0000000..ccc32bf
--- /dev/null
+++ b/Examples/advanced-authorization/Example.swift
@@ -0,0 +1,16 @@
+//
+// Example.swift
+// advanced-authorization
+//
+// Created by Aaron Sky on 6/6/22.
+// Copyright © 2022 Aaron Sky. All rights reserved.
+//
+
+import Buildkite
+import Foundation
+
+@main struct Example {
+ static func main() async {
+
+ }
+}
diff --git a/Examples/graphql/GraphQLExample.swift b/Examples/graphql/Example.swift
similarity index 57%
rename from Examples/graphql/GraphQLExample.swift
rename to Examples/graphql/Example.swift
index e126d5d..c0ccb4a 100644
--- a/Examples/graphql/GraphQLExample.swift
+++ b/Examples/graphql/Example.swift
@@ -1,12 +1,13 @@
//
-// main.swift
+// Example.swift
// graphql
//
// Created by Aaron Sky on 5/5/20.
+// Copyright © 2020 Aaron Sky. All rights reserved.
//
-import Foundation
import Buildkite
+import Foundation
struct MyPipeline: Codable {
var organization: Organization?
@@ -29,30 +30,32 @@ struct MyPipeline: Codable {
}
}
-@main struct GraphQLExample {
+@main struct Example {
static func main() async {
let client = BuildkiteClient(token: "...")
let query = """
- query MyPipelines($first: Int!) {
- organization(slug: "buildkite") {
- pipelines(first: $first) {
- edges {
- node {
- name
- uuid
+ query MyPipelines($first: Int!) {
+ organization(slug: "buildkite") {
+ pipelines(first: $first) {
+ edges {
+ node {
+ name
+ uuid
+ }
}
}
}
}
- }
- """
+ """
do {
- let pipelines = try await client.sendQuery(GraphQL(
- rawQuery: query,
- variables: ["first": 30]
- ))
+ let pipelines = try await client.sendQuery(
+ GraphQL(
+ rawQuery: query,
+ variables: ["first": 30]
+ )
+ )
print(pipelines)
} catch {
print(error)
diff --git a/Examples/simple/Example.swift b/Examples/simple/Example.swift
new file mode 100644
index 0000000..ee7368c
--- /dev/null
+++ b/Examples/simple/Example.swift
@@ -0,0 +1,16 @@
+//
+// Example.swift
+// simple
+//
+// Created by Aaron Sky on 6/6/22.
+// Copyright © 2022 Aaron Sky. All rights reserved.
+//
+
+import Buildkite
+import Foundation
+
+@main struct Example {
+ static func main() async {
+
+ }
+}
diff --git a/Examples/test-analytics/Example.swift b/Examples/test-analytics/Example.swift
new file mode 100644
index 0000000..69e678a
--- /dev/null
+++ b/Examples/test-analytics/Example.swift
@@ -0,0 +1,16 @@
+//
+// Example.swift
+// test-analytics
+//
+// Created by Aaron Sky on 6/6/22.
+// Copyright © 2022 Aaron Sky. All rights reserved.
+//
+
+import Buildkite
+import Foundation
+
+@main struct Example {
+ static func main() async {
+
+ }
+}
diff --git a/Makefile b/Makefile
index 74c8d27..d69d036 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,75 @@
-SWIFT_FORMAT_BIN := swift format
+# Facts
GIT_REPO_TOPLEVEL := $(shell git rev-parse --show-toplevel)
+
+# Apple Platform Destinations
+DESTINATION_PLATFORM_IOS_SIMULATOR = platform=iOS Simulator,name=iPhone 11 Pro Max
+DESTINATION_PLATFORM_MACOS = platform=macOS
+DESTINATION_PLATFORM_TVOS_SIMULATOR = platform=tvOS Simulator,name=Apple TV
+DESTINATION_PLATFORM_WATCHOS_SIMULATOR = platform=watchOS Simulator,name=Apple Watch Series 5 - 44mm
+
+# Formatting
+SWIFT_FORMAT_BIN := swift format
SWIFT_FORMAT_CONFIG_FILE := $(GIT_REPO_TOPLEVEL)/.swift-format.json
+FORMAT_PATHS := $(GIT_REPO_TOPLEVEL)/Examples $(GIT_REPO_TOPLEVEL)/Package.swift $(GIT_REPO_TOPLEVEL)/Sources $(GIT_REPO_TOPLEVEL)/Tests
+
+# Tasks
+
+default: test-all
+
+test-all: test-library test-library-xcode test-examples
+
+test-library:
+ swift test --parallel
+
+test-library-xcode:
+ xcodebuild test \
+ -scheme Buildkite \
+ -destination "$(DESTINATION_PLATFORM_IOS_SIMULATOR)" \
+ -quiet
+ xcodebuild test \
+ -scheme Buildkite \
+ -destination "$(DESTINATION_PLATFORM_MACOS)" \
+ -quiet
+ xcodebuild test \
+ -scheme Buildkite \
+ -destination "$(DESTINATION_PLATFORM_TVOS_SIMULATOR)" \
+ -quiet
+ xcodebuild \
+ -scheme Buildkite \
+ -destination "$(DESTINATION_PLATFORM_WATCHOS_SIMULATOR)" \
+ -quiet
+
+test-examples:
+ xcodebuild build \
+ -scheme simple \
+ -destination "$(DESTINATION_PLATFORM_MACOS)" \
+ -quiet
+ xcodebuild build \
+ -scheme graphql \
+ -destination "$(DESTINATION_PLATFORM_MACOS)" \
+ -quiet
+ xcodebuild build \
+ -scheme advanced-authorization \
+ -destination "$(DESTINATION_PLATFORM_MACOS)" \
+ -quiet
+ xcodebuild build \
+ -scheme test-analytics \
+ -destination "$(DESTINATION_PLATFORM_MACOS)" \
+ -quiet
+
+
+DOC_WARNINGS := $(shell xcodebuild clean docbuild \
+ -scheme Buildkite \
+ -destination "$(DESTINATION_PLATFORM_MACOS)" \
+ -quiet \
+ 2>&1 \
+ | grep "couldn't be resolved to known documentation" \
+ | sed 's|$(PWD)|.|g' \
+ | tr '\n' '\1')
+test-docs:
+ @test "$(DOC_WARNINGS)" = "" \
+ || (echo "xcodebuild docbuild failed:\n\n$(DOC_WARNINGS)" | tr '\1' '\n' \
+ && exit 1)
format:
$(SWIFT_FORMAT_BIN) \
@@ -8,23 +77,13 @@ format:
--ignore-unparsable-files \
--in-place \
--recursive \
- $(GIT_REPO_TOPLEVEL)/Package.swift $(GIT_REPO_TOPLEVEL)/Sources $(GIT_REPO_TOPLEVEL)/Tests
+ $(FORMAT_PATHS)
lint:
$(SWIFT_FORMAT_BIN) lint \
--configuration $(SWIFT_FORMAT_CONFIG_FILE) \
--ignore-unparsable-files \
--recursive \
- $(GIT_REPO_TOPLEVEL)/Package.swift $(GIT_REPO_TOPLEVEL)/Sources $(GIT_REPO_TOPLEVEL)/Tests
+ $(FORMAT_PATHS)
-test:
- swift test --parallel --enable-code-coverage
-
-coverage: test
- xcrun llvm-cov export \
- -format=lcov \
- -instr-profile=.build/arm64-apple-macosx/debug/codecov/default.profdata \
- .build/arm64-apple-macosx/debug/BuildkitePackageTests.xctest/Contents/MacOS/BuildkitePackageTests \
- > lcov.info
-
-.PHONY: format lint test coverage
+.PHONY: format lint test-all test-library test-library-xcode test-examples test-docs
diff --git a/Package.swift b/Package.swift
index 8b656e2..784ed8c 100644
--- a/Package.swift
+++ b/Package.swift
@@ -21,17 +21,6 @@ let package = Package(
name: "Buildkite",
dependencies: []
),
-
- // Examples
-
- .executableTarget(
- name: "graphql",
- dependencies: ["Buildkite"],
- path: "Examples/graphql"
- ),
-
- // Tests
-
.testTarget(
name: "BuildkiteTests",
dependencies: ["Buildkite"]
diff --git a/README.md b/README.md
index 4738a11..6adcfab 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Buildkite
-[](https://github.com/aaronsky/buildkite-swift/actions/workflows/main.yml)
+[](https://github.com/aaronsky/buildkite-swift/actions/workflows/ci.yml)
A Swift library and client for the Buildkite REST and GraphQL APIs.