File tree Expand file tree Collapse file tree 7 files changed +153
-0
lines changed
Sources/WorkflowTestPackage
Tests/WorkflowTestPackageTests Expand file tree Collapse file tree 7 files changed +153
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Lint
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ package_path :
7+ type : string
8+ required : false
9+ default : ' '
10+ description : " Specifies a subpath of the checkout that the package is contained in."
11+
12+ jobs :
13+ format :
14+ name : Format linting
15+ runs-on : ubuntu-latest
16+ steps :
17+ - name : Checkout
18+ uses : actions/checkout@v4
19+ - name : Set up Docker Buildx
20+ uses : docker/setup-buildx-action@v3
21+ - name : Pull formatting docker image
22+ run : docker pull ghcr.io/nicklockwood/swiftformat:latest
23+ - name : Run format linting
24+ run : docker run --rm -v ${{ github.workspace }}:/repo ghcr.io/nicklockwood/swiftformat:latest /repo/${{ inputs.package_path }} --lint
Original file line number Diff line number Diff line change 1+ name : Self-test the CI workflows
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ branches :
9+ - main
10+
11+ jobs :
12+ lint :
13+ uses : ./.github/workflows/lint.yaml
14+ with :
15+ package_path : WorkflowTestPackage
16+ test :
17+ uses : ./.github/workflows/test.yaml
18+ with :
19+ package_path : WorkflowTestPackage
Original file line number Diff line number Diff line change 1+ name : Test
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ package_path :
7+ type : string
8+ required : false
9+ default : ' '
10+ description : " Specifies a subpath of the checkout that the package is contained in."
11+
12+ env :
13+ PACKAGE_PATH : ${{ inputs.package_path != '' && format('--package-path={0}', inputs.package_path) || '' }}
14+
15+ jobs :
16+ macos :
17+ name : Test on macOS
18+ runs-on : macos-latest
19+ steps :
20+ - uses : maxim-lobanov/setup-xcode@v1
21+ with :
22+ xcode-version : latest-stable
23+ - uses : actions/checkout@v4
24+ - name : Build and test
25+ run : |
26+ swift test \
27+ --parallel \
28+ ${{ inputs.package_path != '' && format('--package-path={0}', inputs.package_path) || '' }}
29+
30+ linux :
31+ name : Test on Linux - ${{ matrix.swift-image }}
32+ strategy :
33+ matrix :
34+ swift-image :
35+ - " swift:5.8-jammy"
36+ - " swift:5.9-jammy"
37+ - " swift:5.10-jammy"
38+ - " swift:5.10-noble"
39+ - " swift:6.0-jammy"
40+ - " swift:6.0-noble"
41+ runs-on : ubuntu-latest
42+ container : ${{ matrix.swift-image }}
43+ steps :
44+ - name : Checkout
45+ uses : actions/checkout@v4
46+ - name : Test
47+ run : |
48+ swift test \
49+ --parallel \
50+ ${{ inputs.package_path != '' && format('--package-path={0}', inputs.package_path) || '' }}
51+
52+ android :
53+ name : Test on Android
54+ runs-on : ubuntu-latest
55+ steps :
56+ - uses : actions/checkout@v4
57+ - name : Test
58+ uses : skiptools/swift-android-action@v2
59+ with :
60+ package-path : ${{ inputs.package_path != '' && inputs.package_path || '.' }}
Original file line number Diff line number Diff line change 1+ .DS_Store
2+ /.build
3+ /Packages
4+ xcuserdata /
5+ DerivedData /
6+ .swiftpm /configuration /registries.json
7+ .swiftpm /xcode /package.xcworkspace /contents.xcworkspacedata
8+ .netrc
Original file line number Diff line number Diff line change 1+ // swift-tools-version:5.8
2+
3+ import PackageDescription
4+
5+ let package = Package (
6+ name: " WorkflowTestPackage " ,
7+ products: [
8+ . library(
9+ name: " WorkflowTestPackage " ,
10+ targets: [ " WorkflowTestPackage " ]
11+ ) ,
12+ ] ,
13+ targets: [
14+ // Targets are the basic building blocks of a package, defining a module or a test suite.
15+ // Targets can depend on other targets in this package and products from dependencies.
16+ . target(
17+ name: " WorkflowTestPackage "
18+ ) ,
19+ . testTarget(
20+ name: " WorkflowTestPackageTests " ,
21+ dependencies: [ " WorkflowTestPackage " ]
22+ ) ,
23+ ]
24+ )
Original file line number Diff line number Diff line change 1+ public struct WorkflowTest {
2+ public let foo = " bar "
3+
4+ public init ( ) { }
5+
6+ public func hello( ) -> String {
7+ return " world "
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ @testable import WorkflowTestPackage
2+
3+ import XCTest
4+
5+ class WorkflowTestPackageTests : XCTestCase {
6+ func testHello( ) async throws {
7+ XCTAssertEqual ( WorkflowTest ( ) . hello ( ) , " world " )
8+ }
9+ }
You can’t perform that action at this time.
0 commit comments