Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ inputs:
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.

A custom build directory that enables CI controlling and caching of the package used to edit and load the SPMGraphConfig.
It defaults to a temporary directory, which works consistently for local runs and CI with clean builds.

- **Note**: Cache this directory in your CI and reuse whenever the `SPMGraphConfig.swift` is stable for reducing the build times.

- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
required: false
Expand All @@ -48,7 +51,7 @@ runs:
- id: lint-dependency-graph
name: Run spmgraph lint
run: |
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 }}' || '' }}
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) || '' }}

# Set boolean output to indicate if lint failed or not
echo "lint-failed=$(cat $GITHUB_WORKSPACE/.spmgraph_lint_result.txt)" >> $GITHUB_OUTPUT
Expand Down
5 changes: 4 additions & 1 deletion .github/actions/tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ inputs:
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.

A custom build directory that enables CI controlling and caching of the package used to edit and load the SPMGraphConfig.
It defaults to a temporary directory, which works consistently for local runs and CI with clean builds.

- **Note**: Cache this directory in your CI and reuse whenever the `SPMGraphConfig.swift` is stable for reducing the build times.

- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
required: false
Expand All @@ -55,7 +58,7 @@ runs:
name: Run spmgraph tests
run: |
# note: changed-files takes precedence over baseBranch
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' || '' }}
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' || '' }}
if [ ! -s "$GITHUB_WORKSPACE/output.txt" ]; then
echo "tests_needed=false" >> $GITHUB_OUTPUT
else
Expand Down
10 changes: 1 addition & 9 deletions .github/actions/visualize/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,12 @@ inputs:
description: Minimum vertical spacing between the ranks (levels) of the graph. A double value in inches.
type: number
default: '3'
config-build-directory:
description: >
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.

A custom build directory that enables CI controlling and caching of the package used to edit and load the SPMGraphConfig.

- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
required: false

runs:
using: 'composite'
steps:
- name: Run spmgraph visualize
run: |
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 }}' || '' }}
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 }}
shell: /bin/bash -e {0}

13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,17 @@ spmgraph lint <package-path> --strict --warningsCount 3 <other-options>

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

**When using multiple runners AND to speed up builds**:
- Pass a custom config build directory via the `--config-build-directory` option
**To speed up builds**:
- Pass a custom config build directory via the `--config-build-directory`/`--build-dir` option
- It allows caching and pre-warming the config package
- It will make loading the config into spmgraph much faster

### Cache warm
- Run `config`, `load` and `lint` passing the `--config-build-directory`/`--build-dir` option
- Cache the directory

### Cache pull
- Skip running `config` and `load`, unless the `SPMGraphConfig.swift` has changed
- Run `lint` the `--config-build-directory`/`--build-dir` option

## Requirements
- [graphviz](https://github.com/graphp/graphviz) (available via `brew install graphviz`)
Expand Down
4 changes: 3 additions & 1 deletion Sources/SPMGraphExecutable/SPMGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ struct SPMGraphConfigArguments: ParsableArguments {
**For users that leverage the lint capability and rely on the `SPMGraphConfig.swift` file**.

A custom build directory that enables CI controlling and caching of the package used to edit and load the SPMGraphConfig.
It defaults to a temporary directory, which works consistently for local runs.
It defaults to a temporary directory, which works consistently for local runs and CI with clean builds.

- **Note**: Cache this directory in your CI and reuse whenever the `SPMGraphConfig.swift` is stable for reducing the build times.

- **Warning**: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
"""
Expand Down
Loading