Skip to content

Commit 36847d1

Browse files
authored
Merge pull request #37 from getyourguide/fix-actions
Improve `config-build-directory`
2 parents ef0431e + 14b0df1 commit 36847d1

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
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

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,17 @@ spmgraph lint <package-path> --strict --warningsCount 3 <other-options>
130130

131131
Custom GitHub actions are [available](./github/actions) for running the different spmgraph commands in CI environments.
132132

133-
**When using multiple runners AND to speed up builds**:
134-
- Pass a custom config build directory via the `--config-build-directory` option
133+
**To speed up builds**:
134+
- Pass a custom config build directory via the `--config-build-directory`/`--build-dir` option
135135
- It allows caching and pre-warming the config package
136-
- It will make loading the config into spmgraph much faster
136+
137+
### Cache warm
138+
- Run `config`, `load` and `lint` passing the `--config-build-directory`/`--build-dir` option
139+
- Cache the directory
140+
141+
### Cache pull
142+
- Skip running `config` and `load`, unless the `SPMGraphConfig.swift` has changed
143+
- Run `lint` the `--config-build-directory`/`--build-dir` option
137144

138145
## Requirements
139146
- [graphviz](https://github.com/graphp/graphviz) (available via `brew install graphviz`)

Sources/SPMGraphExecutable/SPMGraph.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ struct SPMGraphConfigArguments: ParsableArguments {
4646
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.
4747
4848
A custom build directory that enables CI controlling and caching of the package used to edit and load the SPMGraphConfig.
49-
It defaults to a temporary directory, which works consistently for local runs.
49+
It defaults to a temporary directory, which works consistently for local runs and CI with clean builds.
50+
51+
- **Note**: Cache this directory in your CI and reuse whenever the `SPMGraphConfig.swift` is stable for reducing the build times.
5052
5153
- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
5254
"""

0 commit comments

Comments
 (0)