Skip to content

Commit d9dbfeb

Browse files
authored
Merge pull request #35 from getyourguide/unit-tests
Add unit tests for the config
2 parents 13b12db + 36847d1 commit d9dbfeb

File tree

31 files changed

+735
-166
lines changed

31 files changed

+735
-166
lines changed

.github/actions/lint/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ inputs:
3636
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.
3737
3838
A custom build directory that enables CI controlling and caching of the package used to edit and load the SPMGraphConfig.
39+
It defaults to a temporary directory, which works consistently for local runs and CI with clean builds.
40+
41+
- **Note**: Cache this directory in your CI and reuse whenever the `SPMGraphConfig.swift` is stable for reducing the build times.
3942
4043
- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
4144
required: false
@@ -48,7 +51,7 @@ runs:
4851
- id: lint-dependency-graph
4952
name: Run spmgraph lint
5053
run: |
51-
spmgraph lint ${{ inputs.package-directory }} ${{ inputs.verbose == 'true' && '-v' || '' }} ${{ inputs.excluded-suffixes && '--excludedSuffixes ${{ inputs.excluded-suffixes }}' || '' }} ${{ inputs.strict == 'true' && '--strict' || '' }} --output lint_output ${{ inputs.config-build-directory && '--config-build-directory ${{ inputs.config-build-directory }}' || '' }}
54+
spmgraph lint ${{ inputs.package-directory }} ${{ inputs.verbose == 'true' && '-v' || '' }} ${{ inputs.excluded-suffixes && '--excludedSuffixes ${{ inputs.excluded-suffixes }}' || '' }} ${{ inputs.strict == 'true' && '--strict' || '' }} --output lint_output ${{ inputs.config-build-directory != '' && format('--config-build-directory "{0}"', inputs.config-build-directory) || '' }}
5255
5356
# Set boolean output to indicate if lint failed or not
5457
echo "lint-failed=$(cat $GITHUB_WORKSPACE/.spmgraph_lint_result.txt)" >> $GITHUB_OUTPUT

.github/actions/tests/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ inputs:
3333
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.
3434
3535
A custom build directory that enables CI controlling and caching of the package used to edit and load the SPMGraphConfig.
36+
It defaults to a temporary directory, which works consistently for local runs and CI with clean builds.
37+
38+
- **Note**: Cache this directory in your CI and reuse whenever the `SPMGraphConfig.swift` is stable for reducing the build times.
3639
3740
- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
3841
required: false
@@ -55,7 +58,7 @@ runs:
5558
name: Run spmgraph tests
5659
run: |
5760
# note: changed-files takes precedence over baseBranch
58-
spmgraph tests ${{ inputs.package-directory }} ${{ inputs.verbose == 'true' && '-v' || '' }} --baseBranch ${{ github.base_ref || 'main' }} --output ${{ inputs.output-format }} ${{ inputs.excluded-suffixes && '--excludedSuffixes ${{ inputs.excluded-suffixes }}' || '' }} ${{ inputs.changed-files && '--changed-files ${{ inputs.changed-files }}' || '' }} ${{ inputs.config-build-directory && '--config-build-directory ${{ inputs.config-build-directory }}' || '' }} ${{ inputs.experimental-ui-test-targets == 'true' && '--experimentalUITest' || '' }}
61+
spmgraph tests ${{ inputs.package-directory }} ${{ inputs.verbose == 'true' && '-v' || '' }} --baseBranch ${{ github.base_ref || 'main' }} --output ${{ inputs.output-format }} ${{ inputs.excluded-suffixes && '--excludedSuffixes ${{ inputs.excluded-suffixes }}' || '' }} ${{ inputs.changed-files && '--changed-files ${{ inputs.changed-files }}' || '' }} ${{ inputs.config-build-directory != '' && format('--config-build-directory "{0}"', inputs.config-build-directory) || '' }} ${{ inputs.experimental-ui-test-targets == 'true' && '--experimentalUITest' || '' }}
5962
if [ ! -s "$GITHUB_WORKSPACE/output.txt" ]; then
6063
echo "tests_needed=false" >> $GITHUB_OUTPUT
6164
else

.github/actions/visualize/action.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,12 @@ inputs:
2525
description: Minimum vertical spacing between the ranks (levels) of the graph. A double value in inches.
2626
type: number
2727
default: '3'
28-
config-build-directory:
29-
description: >
30-
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.
31-
32-
A custom build directory that enables CI controlling and caching of the package used to edit and load the SPMGraphConfig.
33-
34-
- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
35-
required: false
3628

3729
runs:
3830
using: 'composite'
3931
steps:
4032
- name: Run spmgraph visualize
4133
run: |
42-
spmgraph visualize ${{ inputs.package-directory }} ${{ inputs.verbose == 'true' && '-v' || '' }} ${{ inputs.excluded-suffixes && '--excludedSuffixes ${{ inputs.excluded-suffixes }}' || '' }} ${{ inputs.focused-module && '--focusedModule ${{ inputs.focused-module }}' || '' }} ${{ inputs.exclude-third-party-dependencies =='true' && '--excludeThirdPartyDependencies ${{ inputs.exclude-third-party-dependencies }}' || '' }} --outputFilePath ${{ inputs.output-file-path }} --rankSpacing ${{ inputs.rank-spacing }} ${{ inputs.config-build-directory && '--config-build-directory ${{ inputs.config-build-directory }}' || '' }}
34+
spmgraph visualize ${{ inputs.package-directory }} ${{ inputs.verbose == 'true' && '-v' || '' }} ${{ inputs.excluded-suffixes && '--excludedSuffixes ${{ inputs.excluded-suffixes }}' || '' }} ${{ inputs.focused-module && '--focusedModule ${{ inputs.focused-module }}' || '' }} ${{ inputs.exclude-third-party-dependencies =='true' && '--excludeThirdPartyDependencies ${{ inputs.exclude-third-party-dependencies }}' || '' }} --outputFilePath ${{ inputs.output-file-path }} --rankSpacing ${{ inputs.rank-spacing }}
4335
shell: /bin/bash -e {0}
4436

.github/workflows/pull-request.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ concurrency:
1010
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1111

1212
jobs:
13-
build_and_tests:
14-
name: Build and run tests
15-
runs-on: [self-hosted, macOS, ARM64, macstadium, bare-metal] # TODO: Replace with GitHub Action runners once it goes open source
13+
build_xcode_16:
14+
name: Build and run tests on Xcode 16.4
15+
runs-on: [macos-orka-large] # TODO: Replace with GitHub Action runners once it goes open source
1616
permissions:
17-
id-token: write
18-
contents: read
19-
checks: write
17+
id-token: write
18+
contents: read
19+
checks: write
2020
steps:
2121
- name: Check out repository
2222
uses: actions/checkout@v4
@@ -35,15 +35,34 @@ jobs:
3535
- name: Run tests on Xcode 16.4
3636
env:
3737
IS_RUNNING_TESTS: 1
38-
run: swift test
38+
run: swift test --no-parallel
3939
timeout-minutes: 3
4040

41+
build_xcode_26:
42+
name: Build and run tests on Xcode 26.0.1
43+
runs-on: [macos-orka-large] # TODO: Replace with GitHub Action runners once it goes open source
44+
permissions:
45+
id-token: write
46+
contents: read
47+
checks: write
48+
49+
steps:
50+
- name: Check out repository
51+
uses: actions/checkout@v4
52+
timeout-minutes: 2
53+
4154
- name: Select Xcode 26.0 toolchain
4255
uses: ./.github/actions/xcode-version
4356
with:
44-
xcode-version: '26.0'
57+
xcode-version: '26.0.1'
4558
timeout-minutes: 2
4659

4760
- name: Build spmgraph for Xcode 26.0
4861
run: swift build
4962
timeout-minutes: 3
63+
64+
- name: Run tests on Xcode 26.0
65+
env:
66+
IS_RUNNING_TESTS: 1
67+
run: swift test --no-parallel
68+
timeout-minutes: 3

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ xcuserdata/
66
DerivedData/
77
.swiftpm/config/registries.json
88
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
9+
10+
# Fixture packages
11+
**/Fixtures/**/.swiftpm/

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

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,55 @@
124124
buildConfiguration = "Debug"
125125
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
126126
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
127-
shouldUseLaunchSchemeArgsEnv = "YES"
128-
shouldAutocreateTestPlan = "YES">
127+
shouldUseLaunchSchemeArgsEnv = "YES">
128+
<TestPlans>
129+
<TestPlanReference
130+
reference = "container:spmgraph.xctestplan"
131+
default = "YES">
132+
</TestPlanReference>
133+
</TestPlans>
134+
<Testables>
135+
<TestableReference
136+
skipped = "NO">
137+
<BuildableReference
138+
BuildableIdentifier = "primary"
139+
BlueprintIdentifier = "SPMGraphExecutableTests"
140+
BuildableName = "SPMGraphExecutableTests"
141+
BlueprintName = "SPMGraphExecutableTests"
142+
ReferencedContainer = "container:">
143+
</BuildableReference>
144+
</TestableReference>
145+
<TestableReference
146+
skipped = "NO">
147+
<BuildableReference
148+
BuildableIdentifier = "primary"
149+
BlueprintIdentifier = "SPMGraphLintTests"
150+
BuildableName = "SPMGraphLintTests"
151+
BlueprintName = "SPMGraphLintTests"
152+
ReferencedContainer = "container:">
153+
</BuildableReference>
154+
</TestableReference>
155+
<TestableReference
156+
skipped = "NO">
157+
<BuildableReference
158+
BuildableIdentifier = "primary"
159+
BlueprintIdentifier = "SPMGraphDescriptionInterfaceTests"
160+
BuildableName = "SPMGraphDescriptionInterfaceTests"
161+
BlueprintName = "SPMGraphDescriptionInterfaceTests"
162+
ReferencedContainer = "container:">
163+
</BuildableReference>
164+
</TestableReference>
165+
<TestableReference
166+
skipped = "NO">
167+
<BuildableReference
168+
BuildableIdentifier = "primary"
169+
BlueprintIdentifier = "FixtureSupport"
170+
BuildableName = "FixtureSupport"
171+
BlueprintName = "FixtureSupport"
172+
ReferencedContainer = "container:">
173+
</BuildableReference>
174+
</TestableReference>
175+
</Testables>
129176
</TestAction>
130177
<LaunchAction
131178
buildConfiguration = "Debug"

Package.resolved

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

0 commit comments

Comments
 (0)