CI enhancements (#6)

* Revise CI to prepare for better examples

* I thought I deleted that

* Rename jobs
This commit is contained in:
Aaron Sky 2022-06-06 09:02:18 -04:00 committed by GitHub
parent 2dc98bc628
commit a776055fb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 268 additions and 293 deletions

45
.github/workflows/ci.yml vendored Normal file
View File

@ -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

View File

@ -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

12
.spi.yml Normal file
View File

@ -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]

View File

@ -1,114 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "NO">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Buildkite"
BuildableName = "Buildkite"
BlueprintName = "Buildkite"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "graphql"
BuildableName = "graphql"
BlueprintName = "graphql"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BuildkiteTests"
BuildableName = "BuildkiteTests"
BlueprintName = "BuildkiteTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BuildkiteTests"
BuildableName = "BuildkiteTests"
BlueprintName = "BuildkiteTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "graphql"
BuildableName = "graphql"
BlueprintName = "graphql"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "graphql"
BuildableName = "graphql"
BlueprintName = "graphql"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1140" LastUpgradeVersion = "1340"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"

View File

@ -1,102 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "NO">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "graphql"
BuildableName = "graphql"
BlueprintName = "graphql"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BuildkiteTests"
BuildableName = "BuildkiteTests"
BlueprintName = "BuildkiteTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BuildkiteTests"
BuildableName = "BuildkiteTests"
BlueprintName = "BuildkiteTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "graphql"
BuildableName = "graphql"
BlueprintName = "graphql"
ReferencedContainer = "container:">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "graphql"
BuildableName = "graphql"
BlueprintName = "graphql"
ReferencedContainer = "container:">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:">
</FileRef>
<FileRef
location = "group:Examples">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

51
Examples/Package.swift Normal file
View File

@ -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"
),
]
)

View File

@ -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 {
}
}

View File

@ -1,12 +1,13 @@
// //
// main.swift // Example.swift
// graphql // graphql
// //
// Created by Aaron Sky on 5/5/20. // Created by Aaron Sky on 5/5/20.
// Copyright © 2020 Aaron Sky. All rights reserved.
// //
import Foundation
import Buildkite import Buildkite
import Foundation
struct MyPipeline: Codable { struct MyPipeline: Codable {
var organization: Organization? var organization: Organization?
@ -29,30 +30,32 @@ struct MyPipeline: Codable {
} }
} }
@main struct GraphQLExample { @main struct Example {
static func main() async { static func main() async {
let client = BuildkiteClient(token: "...") let client = BuildkiteClient(token: "...")
let query = """ let query = """
query MyPipelines($first: Int!) { query MyPipelines($first: Int!) {
organization(slug: "buildkite") { organization(slug: "buildkite") {
pipelines(first: $first) { pipelines(first: $first) {
edges { edges {
node { node {
name name
uuid uuid
}
} }
} }
} }
} }
} """
"""
do { do {
let pipelines = try await client.sendQuery(GraphQL<MyPipeline>( let pipelines = try await client.sendQuery(
rawQuery: query, GraphQL<MyPipeline>(
variables: ["first": 30] rawQuery: query,
)) variables: ["first": 30]
)
)
print(pipelines) print(pipelines)
} catch { } catch {
print(error) print(error)

View File

@ -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 {
}
}

View File

@ -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 {
}
}

View File

@ -1,6 +1,75 @@
SWIFT_FORMAT_BIN := swift format # Facts
GIT_REPO_TOPLEVEL := $(shell git rev-parse --show-toplevel) 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 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: format:
$(SWIFT_FORMAT_BIN) \ $(SWIFT_FORMAT_BIN) \
@ -8,23 +77,13 @@ format:
--ignore-unparsable-files \ --ignore-unparsable-files \
--in-place \ --in-place \
--recursive \ --recursive \
$(GIT_REPO_TOPLEVEL)/Package.swift $(GIT_REPO_TOPLEVEL)/Sources $(GIT_REPO_TOPLEVEL)/Tests $(FORMAT_PATHS)
lint: lint:
$(SWIFT_FORMAT_BIN) lint \ $(SWIFT_FORMAT_BIN) lint \
--configuration $(SWIFT_FORMAT_CONFIG_FILE) \ --configuration $(SWIFT_FORMAT_CONFIG_FILE) \
--ignore-unparsable-files \ --ignore-unparsable-files \
--recursive \ --recursive \
$(GIT_REPO_TOPLEVEL)/Package.swift $(GIT_REPO_TOPLEVEL)/Sources $(GIT_REPO_TOPLEVEL)/Tests $(FORMAT_PATHS)
test: .PHONY: format lint test-all test-library test-library-xcode test-examples test-docs
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

View File

@ -21,17 +21,6 @@ let package = Package(
name: "Buildkite", name: "Buildkite",
dependencies: [] dependencies: []
), ),
// Examples
.executableTarget(
name: "graphql",
dependencies: ["Buildkite"],
path: "Examples/graphql"
),
// Tests
.testTarget( .testTarget(
name: "BuildkiteTests", name: "BuildkiteTests",
dependencies: ["Buildkite"] dependencies: ["Buildkite"]

View File

@ -1,6 +1,6 @@
# Buildkite # Buildkite
[![CI](https://github.com/aaronsky/buildkite-swift/actions/workflows/main.yml/badge.svg)](https://github.com/aaronsky/buildkite-swift/actions/workflows/main.yml) [![CI](https://github.com/aaronsky/buildkite-swift/actions/workflows/ci.yml/badge.svg)](https://github.com/aaronsky/buildkite-swift/actions/workflows/ci.yml)
A Swift library and client for the Buildkite REST and GraphQL APIs. A Swift library and client for the Buildkite REST and GraphQL APIs.