Skip to content

Commit 6a533a3

Browse files
committed
test: Update GHA jobs to support new Swift Testing
Split job into macOS and Ubuntu specific jobs Add concurrency setting to GHA so only one per branch will run at a time Update GH actions to their latest versions Replace setup-swift action with xcode-select-version-action and update     to Xcode 16 on macOS Build tests when building package Use --skip testGetPullRequestsPerformance to not run long running tests Set TEST_GITHUB_TOKEN environment variable at the swift test level Update test-reporting path to new swift-testing results file path Add workaround for test-reporting     issue [1169](actions/checkout#1169) Switch swift-testing package to use newly released v0.12.0 Update missed Swift Testing migration of XCTSkip to @suite(.disabled())     in EndpointTests Change testGetPullRequestsPerformance timeout to 3 minutes TODO: Collapse macOS and Ubuntu jobs back into one
1 parent ae58b51 commit 6a533a3

File tree

4 files changed

+62
-30
lines changed

4 files changed

+62
-30
lines changed

.github/workflows/swift.yml

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,76 @@ on:
1313
pull_request:
1414
branches: [ "main" ]
1515

16+
concurrency:
17+
group: ci-${{ github.ref }}
18+
cancel-in-progress: true
19+
1620
jobs:
17-
build:
18-
name: Build and test on ${{ matrix.os }}
19-
runs-on: ${{ matrix.os }}
21+
macos:
2022
strategy:
23+
fail-fast: true
2124
matrix:
22-
os: [macos-13, ubuntu-latest]
25+
os: [macos-14]
2326

27+
name: Build and test on ${{ matrix.os }}
28+
runs-on: ${{ matrix.os }}
2429
steps:
25-
- uses: swift-actions/setup-swift@v1
26-
- uses: actions/checkout@v3
30+
- uses: actions/checkout@v4
31+
- name: Xcode Select Version
32+
uses: mobiledevops/xcode-select-version-action@v1
33+
with:
34+
xcode-select-version: 16_beta_6
35+
- name: Get xcodebuild version
36+
run: xcodebuild -version
2737
- name: Get swift version
28-
run: swift --version # Swift 5.9
38+
run: swift --version
2939
- name: Get macOS version
3040
run: sw_vers
31-
if: startsWith( matrix.os, 'macos' )
32-
- name: Set TEST_GITHUB_TOKEN env variable
33-
shell: bash
41+
- name: Build
42+
run: swift build --build-tests
43+
- name: Run tests
44+
run: swift test --skip testGetPullRequestsPerformance --parallel --xunit-output=results.xml
45+
env:
46+
TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
47+
- name: Report test results
48+
uses: phoenix-actions/test-reporting@v15
49+
id: test-report
50+
if: success() || failure() # run this step even if previous step failed
51+
with:
52+
name: Swift tests on ${{ matrix.os }}
53+
path: results-swift-testing.xml
54+
reporter: java-junit
55+
56+
ubuntu:
57+
strategy:
58+
matrix:
59+
os: [ubuntu-latest]
60+
61+
name: Build and test on ${{ matrix.os }}
62+
runs-on: ${{ matrix.os }}
63+
container:
64+
image: swiftlang/swift:nightly-6.0-jammy
3465
env:
3566
TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
36-
run: |
37-
echo "$TEST_GITHUB_TOKEN" > $HOME/.env
67+
steps:
68+
- uses: actions/checkout@v4
69+
- name: Get swift version
70+
run: swift --version
71+
- name: Get Linux version
72+
run: uname -a
3873
- name: Build
39-
run: swift build
74+
run: swift build --build-tests
4075
- name: Run tests
41-
run: swift test --parallel --xunit-output=results.xml
76+
run: swift test --skip testGetPullRequestsPerformance --parallel --xunit-output=results.xml
77+
- name: Workaround for test-reporting issue 1169
78+
run: git config --system --add safe.directory /__w/github-stats/github-stats
79+
if: success() || failure() # run this step even if previous step failed
4280
- name: Report test results
43-
uses: phoenix-actions/test-reporting@v8
81+
uses: phoenix-actions/test-reporting@v15
4482
id: test-report
4583
if: success() || failure() # run this step even if previous step failed
4684
with:
4785
name: Swift tests on ${{ matrix.os }}
48-
path: results.xml
49-
reporter: java-junit
86+
path: results-swift-testing.xml
87+
reporter: java-junit
88+

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ let dependencies: [Package.Dependency]
88
dependencies = [
99
// Dependencies declare other packages that this package depends on.
1010
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.4.0"),
11-
.package(url: "https://github.com/apple/swift-testing.git", branch: "main")
11+
.package(url: "https://github.com/apple/swift-testing.git", from: "0.12.0")
1212
]
1313
#else
1414
dependencies = [
1515
// Dependencies declare other packages that this package depends on.
1616
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.4.0"),
17-
.package(url: "https://github.com/apple/swift-testing.git", branch: "main"),
17+
.package(url: "https://github.com/apple/swift-testing.git", from: "0.12.0"),
1818
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins.git", from: "0.55.1")
1919
]
2020
#endif

Tests/GitHubStatsCoreTests/EndpointTests.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,12 @@ import Testing
1010
import Foundation
1111
@testable import GitHubStatsCore
1212

13-
@Suite("EndpointTests tests")
13+
@Suite("EndpointTests tests", .disabled(if: ProcessInfo.processInfo.environment[GitHubConstants.gitHubTokenEnvironmentVariable] == nil, "GitHub API token not found in environment variables"))
1414
internal struct EndpointTests {
1515
private let organization = "apple"
1616
private let repo = "swift.git"
1717
private let author = "DougGregor"
1818

19-
init() throws {
20-
let token = ProcessInfo.processInfo.environment[GitHubConstants.gitHubTokenEnvironmentVariable]
21-
guard token != nil else {
22-
throw XCTSkip("GitHub API token not found in environment variables")
23-
}
24-
}
25-
2619
@Test("Test getPullRequests with an invalid repo")
2720
func testInvalidRepoPullRequests() async throws {
2821
// Arrange
@@ -179,7 +172,7 @@ internal final class EndpointPerformanceTests: XCTestCase {
179172
expectation.fulfill()
180173
}
181174

182-
self.wait(for: [expectation], timeout: 120)
175+
self.wait(for: [expectation], timeout: 3 * 60)
183176
}
184177

185178
#if os(Linux)

0 commit comments

Comments
 (0)