Skip to content

Commit 3593433

Browse files
authored
Merge pull request #11 from getyourguide/tests
E2E tests
2 parents bda3a77 + 6d0812c commit 3593433

File tree

20 files changed

+636
-39
lines changed

20 files changed

+636
-39
lines changed

.github/workflows/pull-request.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ jobs:
3030

3131
- name: Build spmgraph for Xcode 16.4
3232
run: swift build
33-
timeout-minutes: 4
33+
timeout-minutes: 3
34+
35+
- name: Run tests on Xcode 16.4
36+
env:
37+
IS_RUNNING_TESTS: 1
38+
run: swift test
39+
timeout-minutes: 3
3440

3541
- name: Select Xcode 26.0 toolchain
3642
uses: ./.github/actions/xcode-version
@@ -40,4 +46,4 @@ jobs:
4046

4147
- name: Build spmgraph for Xcode 26.0
4248
run: swift build
43-
timeout-minutes: 4
49+
timeout-minutes: 3

.swiftpm/xcode/xcshareddata/xcschemes/spmgraph.xcscheme

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
shouldUseLaunchSchemeArgsEnv = "YES"
30-
shouldAutocreateTestPlan = "YES">
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<TestPlans>
31+
<TestPlanReference
32+
reference = "container:spmgraph.xctestplan"
33+
default = "YES">
34+
</TestPlanReference>
35+
</TestPlans>
3136
</TestAction>
3237
<LaunchAction
3338
buildConfiguration = "Debug"
3439
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3540
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
41+
enableAddressSanitizer = "YES"
3642
enableASanStackUseAfterReturn = "YES"
3743
launchStyle = "0"
3844
useCustomWorkingDirectory = "NO"

Package.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,14 @@ let package = Package(
137137
),
138138
]
139139
),
140+
141+
// MARK: - Tests
142+
143+
.testTarget(
144+
name: "SPMGraphExecutableTests",
145+
dependencies: [
146+
.target(name: "SPMGraphExecutable"),
147+
]
148+
)
140149
]
141150
)

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# spmgraph - SwiftPM dependency graph management
22

3+
[![CI status](https://github.com/getyourguide/spmgraph/actions/workflows/pull-request.yml/badge.svg)](https://github.com/getyourguide/spmgraph/actions/workflows/pull-request.yml)
4+
[![Swift Package Manager](https://rawgit.com/jlyonsmith/artwork/master/SwiftPackageManager/swiftpackagemanager-compatible.svg)](https://swift.org/package-manager/)
5+
36
A CLI tool that **unlocks Swift dependency graphs**, giving you extra information and capabilities.
47
<br>
58
With it, you can visualize your dependency graph, run selective testing, and enforce architectural rules for optimal modular setups.
@@ -146,12 +149,11 @@ mint install getyourguide/spmgraph
146149
## Acknowledgments
147150
- Inspired by the work that the [Tuist](https://tuist.dev/) team does for the Apple developers community and their focus on leveraging the dependency graph to provide amazing features for engineers. Also, a source of inspiration for our shell abstraction layer.
148151

149-
## Open roadmap
152+
## Open roadmap
150153
- [ ] Cover the core logic of Lint, Map, and Visualize libs with tests
151154
- [ ] Improve the `unusedDependencies` lint rule to cover products with multiple targets
152155
- [ ] Support macros (to become a GitHub issue)
153-
- [ ] Create Danger plugin for the linter functionality
154156

155157
Ideas
156-
- [ ] Lint - see if it can be improved to cover auto-exported dependencies. For example, usages of `import Dependencies` justify linking `DependenciesExtras` as a dependency.
157158
- [ ] Add fix-it suggestion to lint errors
159+
- [ ] Create Danger plugin for the linter functionality
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
//
3+
// Copyright (c) 2025 GetYourGuide GmbH
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
//
17+
//
18+
19+
import Foundation
20+
21+
public extension ProcessInfo {
22+
static var isRunningTests: Bool {
23+
processInfo.environment["IS_RUNNING_TESTS"] != nil
24+
}
25+
}

Sources/SPMGraphConfigSetup/Resources/Package.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let package = Package(
2020
// TODO: Change it to HTTP when made public
2121
.package(
2222
url: "git@github.com:getyourguide/spmgraph.git",
23-
branch: "main"
23+
revision: "bda3a77facf780f921bab267628ce1c36afaadb1"
2424
),
2525

2626
// TODO: Review which tag / Swift release to use

Sources/SPMGraphConfigSetup/Resources/DoNotEdit_DynamicLoading.txt renamed to Sources/SPMGraphConfigSetup/Resources/_DoNotEdit_DynamicLoading.txt

File renamed without changes.

Sources/SPMGraphConfigSetup/SPMGraphEdit.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ public final class SPMGraphEdit: SPMGraphEditProtocol {
125125

126126
private extension SPMGraphEdit {
127127
func openEditPackage() throws(SPMGraphEditError) {
128+
guard !ProcessInfo.isRunningTests else {
129+
print("Skipped opening the edit package in tests...")
130+
return
131+
}
132+
128133
if verbose {
129134
print("Opening the edit package...")
130135
}

Sources/SPMGraphConfigSetup/SPMGraphLoad.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public final class SPMGraphLoad: SPMGraphLoadProtocol {
7070
editPackageDirectory
7171
.appending(component: "Sources")
7272
.appending(component: "SPMGraphConfig")
73-
.appending(component: "DoNotEdit_DynamicLoading")
73+
.appending(component: "_DoNotEdit_DynamicLoading")
7474
.appending(extension: "swift")
7575

7676
public init(input: SPMGraphLoadInput) throws(SPMGraphLoadError) {
@@ -90,6 +90,8 @@ private extension SPMGraphLoad {
9090
func load(userConfigFile: AbsolutePath) throws(SPMGraphLoadError) {
9191
print("Loading your SPMGraphConfig.swift into spmgraph... please await")
9292

93+
defer { try? removeDynamicLoadingFile() }
94+
9395
try includeDynamicLoadingFile()
9496

9597
do {
@@ -115,16 +117,14 @@ private extension SPMGraphLoad {
115117
)
116118
}
117119

118-
defer { try? removeDynamicLoadingFile() }
119-
120120
print("Finished loading")
121121
}
122122

123123
func includeDynamicLoadingFile() throws(SPMGraphLoadError) {
124124
do {
125125
guard
126126
let dynamicLoadingTemplateURL = Bundle.module.url(
127-
forResource: "Resources/DoNotEdit_DynamicLoading",
127+
forResource: "Resources/_DoNotEdit_DynamicLoading",
128128
withExtension: "txt"
129129
)
130130
else {

Sources/SPMGraphExecutable/Subcommands/Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct TestsArguments: ParsableArguments {
2424

2525
@Option(
2626
name: [.customLong("files"), .customLong("changedFiles")],
27-
help: "Optional list of changed files. Otherwise git versioning is used"
27+
help: "Optional list of changed files. Otherwise git versioning is used. It supports both absolute and relative paths"
2828
)
2929
var changedFiles: [String] = [] // TODO: Change to AbsolutePath
3030

0 commit comments

Comments
 (0)