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
15 changes: 7 additions & 8 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ inputs:
description: Reports the lint errors in a PR comment.
type: boolean
default: false
build-directory:
config-build-directory:
description: >
A custom build directory used to store the package used to edit and load the SPMGraphConfig.
It defaults to a temporary directory and it must be set in CI.

- Note: It enables controlling and caching the artifact that is generated from the user's `SPMGraphConfig` file.

- Warning: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
**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: true

# TODO: Support danger as option for PR comment, requires making it a Danger plugin
Expand All @@ -49,7 +48,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 --build-directory ${{ inputs.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 --config-build-directory ${{ inputs.config-build-directory }}
shell: /bin/bash -e {0}

- name: Write to workflow job summary
Expand Down
74 changes: 74 additions & 0 deletions .github/actions/tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: 'spmgraph tests'
description: 'Map tests to run based on changed files of a given dependency graph'
inputs:
package_directory:
description: The directory where the Package.swift file is located
required: true
verbose:
description: Show extra logging for troubleshooting purposes.
type: boolean
default: false
excluded_suffixes:
description: Comma separated suffixes to exclude from the graph e.g. 'Tests','Live','TestSupport'
required: false
default: ''
base_branch:
description: Base branch to compare the changes against
required: false
default: 'main'
changed_files:
description: Optional list of changed files. Otherwise git versioning is used
required: false
default: ''
output_format:
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."
required: false
default: 'textDump'
adds_to_summary:
description: List the filtered tests in the action summary.
type: boolean
default: false
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
outputs:
test_targets:
description: A comma separated list of test targets to run. It can be passed as is to xcodebuild or fastlane scan.
value: ${{ steps.spmgraph_test.outputs.test_targets }}
tests_needed:
description: Whether running tests is needed or not.
value: ${{ steps.spmgraph_test.outputs.tests_needed }}

runs:
using: 'composite'
steps:
- id: spmgraph_test
name: Run spmgraph tests
run: |
# note: changed_files take 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 }}' || '' }}
if [ ! -s "$GITHUB_WORKSPACE/output.txt" ]; then
echo "tests_needed=false" >> $GITHUB_OUTPUT
else
echo "tests_needed=true" >> $GITHUB_OUTPUT
echo "test_targets=$(cat $GITHUB_WORKSPACE/output.txt)" >> $GITHUB_OUTPUT
fi
shell: /bin/bash -e {0}

- name: Write to workflow job summary
if: ${{ inputs.adds_to_summary == 'true' }}
run: |
tests_summary=$'# spmgraph tests\n## Tests to run\n'
echo "$tests_summary" >> $GITHUB_STEP_SUMMARY

if [ "${{ steps.spmgraph_test.outputs.tests_needed }}" != "false" ]; then
cat $GITHUB_WORKSPACE/output.txt | tr ',' '\n' | sort >> $GITHUB_STEP_SUMMARY
else
echo "No tests to run" >> $GITHUB_STEP_SUMMARY
fi
shell: /bin/bash -e {0}
17 changes: 8 additions & 9 deletions .github/actions/visualize/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,20 @@ inputs:
description: Minimum vertical spacing between the ranks (levels) of the graph. A double value in inches.
type: number
default: '3'
build-directory:
config-build-directory:
description: >
A custom build directory used to store the package used to edit and load the SPMGraphConfig.
It defaults to a temporary directory and it must be set in CI.

- Note: It enables controlling and caching the artifact that is generated from the user's `SPMGraphConfig` file.

- Warning: Ensure this is consistent across commands, otherwise your configuration won't be correctly loaded!
required: true
**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 }} --build-directory ${{ inputs.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 }} ${{ inputs.config-build-directory && '--config-build-directory ${{ inputs.config-build-directory }}' || '' }}
shell: /bin/bash -e {0}

4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Pull Request

description: Run the pull request checks, such as building spmgraph for different toolchains and running tests.
on:
pull_request:
types: [synchronize, opened, reopened, edited] # The first three are defaults, with 'edited' included the builds will be triggered on things like the base of the branch changing
Expand All @@ -12,7 +12,7 @@ concurrency:
jobs:
build_and_tests:
name: Build and run tests
runs-on: [self-hosted, macOS, ARM64, macstadium, bare-metal]
runs-on: [self-hosted, macOS, ARM64, macstadium, bare-metal] # TODO: Replace with GitHub Action runners once it goes open source
permissions:
id-token: write
contents: read
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release
description: Release a new version of spmgraph. It's inpired by the internal https://github.com/getyourguide/actions/tree/main/semver-release.
on:
workflow_dispatch:
inputs:
updateType:
description: 'Semver release type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major

concurrency:
group: '${{ github.workflow }}-${{ github.head_ref || github.run_id }}'
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build_and_tests:
name: Build and run tests
runs-on: [self-hosted, java-small] # TODO: Replace with GitHub Action runners once it goes open source
permissions:
id-token: write
contents: write
actions: write
checks: write

steps:
- name: Check out repository
uses: actions/checkout@v4
timeout-minutes: 2

- name: Get the latest release tag
run: |
git fetch --prune --prune-tags
latest_tag=$(git tag --sort=committerdate | tail -1)
echo "latest_tag=$latest_tag" >> $GITHUB_ENV

- name: Bump version
run: |
# Read the latest tag from the GITHUB_ENV and extract the values from it
latest_tag=${{ env.latest_tag }}
if [[ $latest_tag =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
else
echo "Invalid version format. Expected 'X.X.X'."
exit 1
fi

# Bumps the version based on the input argument
case ${{ github.event.inputs.updateType }} in
major)
major=$((major + 1))
minor=0
patch=0
;;
minor)
minor=$((minor + 1))
patch=0
;;
patch)
patch=$((patch + 1))
;;
*)
echo "Usage: $0 [--major|--minor|--patch]"
echo " --major: Bump the major version."
echo " --minor: Bump the minor version."
echo " --patch: Bump the patch version."
exit 1
;;
esac

# Defines the updated tag and adds it to the GITHUB_ENV
new_tag="${major}.${minor}.${patch}"
echo "new_tag=$new_tag" >> $GITHUB_ENV

- name: Create the release
run: |
gh release create "$new_tag" --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 9 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Release process

Once the main branch has the fixes and features that should be shipped:
1. Start the `release.yml`
- Fill in the `updateType` argument, which follows [semver](https://semver.org/)
2. Sit and wait :)! The automation will
- Bump the version follow the update type
- create a tag and the release
- auto generate release notes