Skip to content
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
24 changes: 24 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint

on:
workflow_call:
inputs:
package_path:
type: string
required: false
default: ''
description: "Specifies a subpath of the checkout that the package is contained in."

jobs:
format:
name: Format linting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Pull formatting docker image
run: docker pull ghcr.io/nicklockwood/swiftformat:latest
- name: Run format linting
run: docker run --rm -v ${{ github.workspace }}:/repo ghcr.io/nicklockwood/swiftformat:latest /repo/${{ inputs.package_path }} --lint
19 changes: 19 additions & 0 deletions .github/workflows/self-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Self-test the CI workflows

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
uses: ./.github/workflows/lint.yaml
with:
package_path: WorkflowTestPackage
test:
uses: ./.github/workflows/test.yaml
with:
package_path: WorkflowTestPackage
60 changes: 60 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test

on:
workflow_call:
inputs:
package_path:
type: string
required: false
default: ''
description: "Specifies a subpath of the checkout that the package is contained in."

env:
PACKAGE_PATH: ${{ inputs.package_path != '' && format('--package-path={0}', inputs.package_path) || '' }}

jobs:
macos:
name: Test on macOS
runs-on: macos-latest
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- uses: actions/checkout@v4
- name: Build and test
run: |
swift test \
--parallel \
${{ inputs.package_path != '' && format('--package-path={0}', inputs.package_path) || '' }}

linux:
name: Test on Linux - ${{ matrix.swift-image }}
strategy:
matrix:
swift-image:
- "swift:5.8-jammy"
- "swift:5.9-jammy"
- "swift:5.10-jammy"
- "swift:5.10-noble"
- "swift:6.0-jammy"
- "swift:6.0-noble"
runs-on: ubuntu-latest
container: ${{ matrix.swift-image }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Test
run: |
swift test \
--parallel \
${{ inputs.package_path != '' && format('--package-path={0}', inputs.package_path) || '' }}

android:
name: Test on Android
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test
uses: skiptools/swift-android-action@v2
with:
package-path: ${{ inputs.package_path != '' && inputs.package_path || '.' }}
8 changes: 8 additions & 0 deletions WorkflowTestPackage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
24 changes: 24 additions & 0 deletions WorkflowTestPackage/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// swift-tools-version:5.8

import PackageDescription

let package = Package(
name: "WorkflowTestPackage",
products: [
.library(
name: "WorkflowTestPackage",
targets: ["WorkflowTestPackage"]
),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "WorkflowTestPackage"
),
.testTarget(
name: "WorkflowTestPackageTests",
dependencies: ["WorkflowTestPackage"]
),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public struct WorkflowTest {
public let foo = "bar"

public init() {}

public func hello() -> String {
return "world"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@testable import WorkflowTestPackage

import XCTest

class WorkflowTestPackageTests: XCTestCase {
func testHello() async throws {
XCTAssertEqual(WorkflowTest().hello(), "world")
}
}