-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GHA] Introduce reusable matrix workflow
# Motivation We have a few checks that we want to run across all supported Swift versions e.g. unit tests and benchmarks. Right now we already added two matrix based jobs to the reusable workflow. This leads to a lot of duplication and harder maintenance. # Modification This PR splits off the current reusable workflow to only contain soundness related checks and introduces a new reusable matrix based workflow which can be customized to execute different commands. # Result It is now easy to setup multiple matrix based workflows.
- Loading branch information
1 parent
7b03cb2
commit d53439c
Showing
3 changed files
with
99 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: Pull Request | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
matrix_linux_name: | ||
type: string | ||
description: "The name of the linux matrix job." | ||
required: true | ||
matrix_linux_command: | ||
type: string | ||
description: "The command of the current Swift version linux matrix job to execute." | ||
required: true | ||
matrix_linux_5_8_enabled: | ||
type: string | ||
description: "The command of the 5.8 Swift version linux matrix job to execute." | ||
matrix_linux_5_8_command_override: | ||
type: string | ||
description: "The command of the 5.8 Swift version linux matrix job to execute." | ||
matrix_linux_5_9_enabled: | ||
type: string | ||
description: "The command of the 5.9 Swift version linux matrix job to execute." | ||
matrix_linux_5_9_command_override: | ||
type: string | ||
description: "The command of the 5.9 Swift version linux matrix job to execute." | ||
matrix_linux_5_10_enabled: | ||
type: string | ||
description: "The command of the 5.10 Swift version linux matrix job to execute." | ||
matrix_linux_5_10_command_override: | ||
type: string | ||
description: "The command of the 5.10 Swift version linux matrix job to execute." | ||
matrix_linux_nightly_next_enabled: | ||
type: string | ||
description: "The command of the nightly next Swift version linux matrix job to execute." | ||
matrix_linux_nightly_next_command_override: | ||
type: string | ||
description: "The command of the nightly next Swift version linux matrix job to execute." | ||
matrix_linux_nightly_main_enabled: | ||
type: string | ||
description: "The command of the nightly main Swift version linux matrix job to execute." | ||
matrix_linux_nightly_main_command_override: | ||
type: string | ||
description: "The command of the nightly main Swift version linux matrix job to execute." | ||
|
||
## We are cancelling previously triggered workflow runs | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.matrix_linux_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
matrix-linux: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
swift: | ||
- image: swift:5.8-jammy | ||
swift_version: "5.8" | ||
- image: swift:5.9-jammy | ||
swift_version: "5.9" | ||
- image: swift:5.10-jammy | ||
swift_version: "5.10" | ||
- image: swiftlang/swift:nightly-6.0-jammy | ||
swift_version: "nightly-next" | ||
- image: swiftlang/swift:nightly-main-jammy | ||
swift_version: "nightly-main" | ||
name: ${{ inputs.matrix_linux_name }} (${{ matrix.swift.swift_version }}) | ||
container: | ||
image: ${{ matrix.swift.image }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Run matrix job | ||
env: | ||
SWIFT_VERSION: ${{ matrix.swift.swift_version }} | ||
run: | | ||
if [ "$SWIFT_VERSION" == "5.8" ] && [ -n "${{ inputs.matrix_linux_5_8_command_override }}" ]; then | ||
${{ inputs.matrix_linux_5_8_command_override }} | ||
elfi [ "$SWIFT_VERSION" == "5.9" ] && [ -n "${{ inputs.matrix_linux_5_9_command_override }}" ]; then | ||
${{ inputs.matrix_linux_5_9_command_override }} | ||
elfi [ "$SWIFT_VERSION" == "5.10" ] && [ -n "${{ inputs.matrix_linux_5_10_command_override }}" ]; then | ||
${{ inputs.matrix_linux_5_10_command_override }} | ||
elfi [ "$SWIFT_VERSION" == "nightly-next" ] && [ -n "${{ inputs.matrix_linux_nightly_next_command_override }}" ]; then | ||
${{ inputs.matrix_linux_nightly_next_command_override }} | ||
elfi [ "$SWIFT_VERSION" == "nightly-main" ] && [ -n "${{ inputs.matrix_linux_nightly_main_command_override }}" ]; then | ||
${{ inputs.matrix_linux_nightly_main_command_override }} | ||
else | ||
${{ inputs.matrix_linux_command }} | ||
fi |