Skip to content

Commit 0a9a6c5

Browse files
committed
Initial commit
0 parents  commit 0a9a6c5

66 files changed

Lines changed: 6241 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/config/action.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'spmgraph config'
2+
description: 'Generates a config project and dynamic library based on the SPMGraphConfig.swift file'
3+
inputs:
4+
package-directory:
5+
description: The directory where the Package.swift file is located
6+
required: true
7+
verbose:
8+
description: Show extra logging for troubleshooting purposes.
9+
type: boolean
10+
default: false
11+
config-build-directory:
12+
description: >
13+
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.
14+
15+
A custom build directory that enables CI controlling and caching of the package used to edit and load the SPMGraphConfig.
16+
It defaults to a temporary directory, which works consistently for local runs and CI with clean builds.
17+
18+
- **Note**: Cache this directory in your CI and reuse whenever the `SPMGraphConfig.swift` is stable for reducing the build times.
19+
20+
- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
21+
required: false
22+
23+
runs:
24+
using: 'composite'
25+
steps:
26+
- name: Run spmgraph config
27+
run: spmgraph config ${{ inputs.package-directory }} ${{ inputs.verbose == 'true' && '-v' || '' }} ${{ inputs.config-build-directory != '' && format('--config-build-directory "{0}"', inputs.config-build-directory) || '' }}
28+
shell: /bin/bash -e {0}

.github/actions/lint/action.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: 'spmgraph lint'
2+
description: 'Lints the dependency graph of a local Package.swift'
3+
inputs:
4+
package-directory:
5+
description: The directory where the Package.swift file is located
6+
required: true
7+
verbose:
8+
description: Show extra logging for troubleshooting purposes.
9+
type: boolean
10+
default: false
11+
excluded-suffixes:
12+
description: Comma separated suffixes to exclude from the graph e.g. 'Tests','Live','TestSupport'
13+
required: false
14+
default: ''
15+
strict:
16+
description: Errors out on warnings and fail the check.
17+
type: boolean
18+
default: false
19+
adds-to-summary:
20+
description: Reports the lint errors in the action summary.
21+
type: boolean
22+
default: true
23+
summary-limit:
24+
description: |
25+
The maximum number of characters to include in the summary. Needed for the lint output to appear in the summary.
26+
GitHub Actions summary has a limit of 1mb and around 65k characters.
27+
See https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#step-isolation-and-limits"
28+
type: number
29+
default: 50000
30+
adds-pr-comment:
31+
description: Reports the lint errors in a PR comment.
32+
type: boolean
33+
default: false
34+
config-build-directory:
35+
description: >
36+
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.
37+
38+
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.
42+
43+
- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
44+
required: false
45+
46+
# TODO: Support danger as option for PR comment, requires making it a Danger plugin
47+
48+
runs:
49+
using: 'composite'
50+
steps:
51+
- id: lint-dependency-graph
52+
name: Run spmgraph lint
53+
run: |
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) || '' }}
55+
56+
# Set boolean output to indicate if lint failed or not
57+
echo "lint-failed=$(cat $GITHUB_WORKSPACE/.spmgraph_lint_result.txt)" >> $GITHUB_OUTPUT
58+
shell: /bin/bash -e {0}
59+
60+
- name: Write to workflow job summary
61+
if: ${{ always() && inputs.adds-to-summary == 'true' }}
62+
run: |
63+
lint_summary=$'# spmgraph lint\n## Results\n'
64+
echo "$lint_summary" >> $GITHUB_STEP_SUMMARY
65+
66+
# Limit the output characters so it's more likely that it appears in the summary
67+
cat $GITHUB_WORKSPACE/lint_output.txt | head -c ${{ inputs.summary-limit }} >> $GITHUB_STEP_SUMMARY
68+
69+
output_warning=$'#### The output was truncated so that it does not surpass 1mb.'
70+
echo "$output_warning" >> $GITHUB_STEP_SUMMARY
71+
shell: /bin/bash -e {0}
72+
73+
- name: Report warnings as a PR comment
74+
if: ${{ always() && inputs.adds-pr-comment == 'true' && steps.lint-dependency-graph.outputs.lint-failed == 'true' }}
75+
continue-on-error: true # Do not fail the workflow if the comment fails or if not a PR
76+
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
77+
with:
78+
file-path: /Users/administrator/runner/_work/iOS/iOS/lint_output.txt
79+
comment-tag: lint-report # the same across runs, which updates the comment from previous runs
80+
81+
- name: Report lint passed as a PR comment
82+
if: ${{ always() && inputs.adds-pr-comment == 'true' && steps.lint-dependency-graph.outputs.lint-failed == 'false' }}
83+
continue-on-error: true # Do not fail the workflow if the comment fails or if not a PR
84+
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
85+
with:
86+
message: spmgraph lint found no errors! The dependency graph looks tidy ✨
87+
comment-tag: lint-report # the same across runs, which updates the comment from previous runs

.github/actions/load/action.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'spmgraph load'
2+
description: 'Loads the user config into spmgraph through a dynamic library'
3+
inputs:
4+
package-directory:
5+
description: The directory where the Package.swift file is located
6+
required: true
7+
verbose:
8+
description: Show extra logging for troubleshooting purposes.
9+
type: boolean
10+
default: false
11+
config-build-directory:
12+
description: >
13+
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.
14+
15+
A custom build directory that enables CI controlling and caching of the package used to edit and load the SPMGraphConfig.
16+
It defaults to a temporary directory, which works consistently for local runs and CI with clean builds.
17+
18+
- **Note**: Cache this directory in your CI and reuse whenever the `SPMGraphConfig.swift` is stable for reducing the build times.
19+
20+
- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
21+
required: false
22+
23+
runs:
24+
using: 'composite'
25+
steps:
26+
- name: Run spmgraph load
27+
run: spmgraph load ${{ inputs.package-directory }} ${{ inputs.verbose == 'true' && '-v' || '' }} ${{ inputs.config-build-directory != '' && format('--config-build-directory "{0}"', inputs.config-build-directory) || '' }}
28+
shell: /bin/bash -e {0}

.github/actions/tests/action.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: 'spmgraph tests'
2+
description: 'Map tests to run based on changed files of a given dependency graph'
3+
inputs:
4+
package-directory:
5+
description: The directory where the Package.swift file is located
6+
required: true
7+
verbose:
8+
description: Show extra logging for troubleshooting purposes.
9+
type: boolean
10+
default: false
11+
excluded-suffixes:
12+
description: Comma separated suffixes to exclude from the graph e.g. 'Tests','Live','TestSupport'
13+
required: false
14+
default: ''
15+
base-branch:
16+
description: Base branch to compare the changes against
17+
required: false
18+
default: 'main'
19+
changed-files:
20+
description: Optional list of changed files. Otherwise git versioning is used
21+
required: false
22+
default: ''
23+
output-format:
24+
description: "The output mode. Options are: textDump, textFile. The first dumps the list of test modules to run in a single line, while the latter Saves the list of test modules into an `output.txt` file in the `current dir`. Both follow the following the xcodebuild/fastlane scan expected format."
25+
required: false
26+
default: 'textDump'
27+
adds-to-summary:
28+
description: List the filtered tests in the action summary.
29+
type: boolean
30+
default: false
31+
config-build-directory:
32+
description: >
33+
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.
34+
35+
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.
39+
40+
- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
41+
required: false
42+
experimental-ui-test-targets:
43+
description: "Warning: This is an experimental flag, use it with caution! Enables support for including UITest targets on selecting testing. It looks for a `uiTestsDependencies.json` in the temporary directory, reads it, and checks if any of the UITest targets dependencies are affected, if so, it includes them in the list of test targets to run."
44+
type: boolean
45+
default: false
46+
outputs:
47+
test_targets:
48+
description: A comma separated list of test targets to run. It can be passed as is to xcodebuild or fastlane scan.
49+
value: ${{ steps.spmgraph_test.outputs.test_targets }}
50+
tests_needed:
51+
description: Whether running tests is needed or not.
52+
value: ${{ steps.spmgraph_test.outputs.tests_needed }}
53+
54+
runs:
55+
using: 'composite'
56+
steps:
57+
- id: spmgraph_test
58+
name: Run spmgraph tests
59+
run: |
60+
# note: changed-files takes precedence over baseBranch
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' || '' }}
62+
if [ ! -s "$GITHUB_WORKSPACE/output.txt" ]; then
63+
echo "tests_needed=false" >> $GITHUB_OUTPUT
64+
else
65+
echo "tests_needed=true" >> $GITHUB_OUTPUT
66+
echo "test_targets=$(cat $GITHUB_WORKSPACE/output.txt)" >> $GITHUB_OUTPUT
67+
fi
68+
shell: /bin/bash -e {0}
69+
70+
- name: Write to workflow job summary
71+
if: ${{ inputs.adds-to-summary == 'true' }}
72+
run: |
73+
tests_summary=$'# spmgraph tests\n## Tests to run\n'
74+
echo "$tests_summary" >> $GITHUB_STEP_SUMMARY
75+
76+
if [ "${{ steps.spmgraph_test.outputs.tests_needed }}" != "false" ]; then
77+
cat $GITHUB_WORKSPACE/output.txt | tr ',' '\n' | sort >> $GITHUB_STEP_SUMMARY
78+
else
79+
echo "No tests to run" >> $GITHUB_STEP_SUMMARY
80+
fi
81+
shell: /bin/bash -e {0}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: 'spmgraph visualize'
2+
description: 'Generates an visual representation of the dependency graph of a local Package.swift'
3+
inputs:
4+
package-directory:
5+
description: The directory where the Package.swift file is located
6+
required: true
7+
verbose:
8+
description: Show extra logging for troubleshooting purposes.
9+
type: boolean
10+
default: false
11+
excluded-suffixes:
12+
description: Comma separated suffixes to exclude from the graph e.g. 'Tests','Live','TestSupport'
13+
required: false
14+
default: ''
15+
focused-module:
16+
description: Focus on a specific module by highlighting its edges (arrows) in a different color. Provide the module name.
17+
exclude-third-party-dependencies:
18+
description: "Exclude third-party dependencies from the graph declared in the `Package.swift`"
19+
type: boolean
20+
default: false
21+
output-file-path:
22+
description: Custom output file path for the generated PNG file. Default will generate a 'graph.png' file in the current directory.
23+
default: './graph.png'
24+
rank-spacing:
25+
description: Minimum vertical spacing between the ranks (levels) of the graph. A double value in inches.
26+
type: number
27+
default: '3'
28+
29+
runs:
30+
using: 'composite'
31+
steps:
32+
- name: Run spmgraph visualize
33+
run: |
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 }}
35+
shell: /bin/bash -e {0}
36+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'Selects the Xcode toolchain'
2+
description: 'Switches to the toolchain defined in the `xcode-version`. Note: It requires Xcodes to be installed on the runner and it follows the `.xcode-version` syntax defined here: https://github.com/XcodesOrg/xcodes/blob/main/XCODE_VERSION.md.'
3+
inputs:
4+
xcode-version:
5+
description: 'The Xcode version to select'
6+
required: true
7+
default: '16.4'
8+
runs:
9+
using: 'composite'
10+
steps:
11+
- name: Switch to .xcode-version
12+
run: xcodes select ${{ inputs.xcode-version }}
13+
id: version_switch
14+
shell: /bin/bash -e {0}
15+
16+
- name: Sets the XCODE_VERSION env var
17+
run: echo "XCODE_VERSION=$(cat ${{ inputs.xcode-version }})" >> $GITHUB_ENV
18+
shell: /bin/bash -e {0}

.github/dependabot.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
day: monday
8+
time: "07:15"
9+
timezone: Europe/Berlin
10+
commit-message:
11+
prefix: CI (dependabot)
12+
ignore:
13+
- dependency-name: '*'
14+
update-types:
15+
- version-update:semver-major
16+
groups:
17+
01_gha-minor-patch:
18+
patterns:
19+
- '*'
20+
update-types:
21+
- minor
22+
- patch
23+
labels:
24+
- dependencies
25+
- github-actions
26+
cooldown:
27+
default-days: 10
28+
exclude:
29+
- getyourguide/*
30+
- package-ecosystem: swift
31+
directory: /
32+
schedule:
33+
interval: weekly
34+
day: monday
35+
time: "07:00"
36+
timezone: Europe/Berlin
37+
commit-message:
38+
prefix: CI (dependabot)
39+
ignore:
40+
- dependency-name: '*'
41+
update-types:
42+
- version-update:semver-major
43+
groups:
44+
01_swift-minor-patch:
45+
patterns:
46+
- '*'
47+
update-types:
48+
- minor
49+
- patch
50+
labels:
51+
- dependencies
52+
- swiftpm

0 commit comments

Comments
 (0)