-
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.
- Loading branch information
Showing
6 changed files
with
386 additions
and
55 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
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,117 @@ | ||
name: Matrix | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
name: | ||
type: string | ||
description: "The name of the workflow used for the concurrency group." | ||
required: true | ||
matrix_path: | ||
type: string | ||
description: "The path of the test matrix definition." | ||
default: "" | ||
matrix_string: | ||
type: string | ||
description: "The test matrix definition." | ||
default: "" | ||
|
||
# We will cancel previously triggered workflow runs | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
generate-matrix: | ||
name: Prepare matrices | ||
runs-on: ubuntu-latest | ||
outputs: | ||
linux-matrix: ${{ steps.load-matrix.outputs.linux-matrix }} | ||
windows-matrix: ${{ steps.load-matrix.outputs.windows-matrix }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- name: Mark the workspace as safe | ||
# https://github.com/actions/checkout/issues/766 | ||
run: git config --global --add safe.directory ${GITHUB_WORKSPACE} | ||
- id: file_check | ||
run: | | ||
if [ ! -z '${{ inputs.matrix_string }}' ]; then | ||
echo "matrix_string_populated=true" >> $GITHUB_ENV | ||
else | ||
echo "matrix_string_populated=false" >> $GITHUB_ENV | ||
fi | ||
- id: cat-matrix | ||
if: ${{ env.matrix_string_populated == 'false' }} | ||
run: | | ||
jq -c '{linux: .linux}' ${{ inputs.matrix_path }} >| __linux_coverage_matrix.json | ||
jq -c '{windows: .windows}' ${{ inputs.matrix_path }} >| __windows_coverage_matrix.json | ||
- id: write-matrix | ||
if: ${{ env.matrix_string_populated == 'true' }} | ||
run: | | ||
echo '${{ inputs.matrix_string }}' | jq -c '{linux: .linux}' >| __linux_coverage_matrix.json | ||
echo '${{ inputs.matrix_string }}' | jq -c '{windows: .windows}' >| __windows_coverage_matrix.json | ||
- id: load-matrix | ||
run: | | ||
{ | ||
echo 'linux-matrix<<EOF' | ||
echo "$(cat __linux_coverage_matrix.json)" | ||
echo EOF | ||
} >> "$GITHUB_OUTPUT" | ||
{ | ||
echo 'windows-matrix<<EOF' | ||
echo "$(cat __windows_coverage_matrix.json)" | ||
echo EOF | ||
} >> "$GITHUB_OUTPUT" | ||
linux: | ||
name: Linux (${{ matrix.linux.name }}) | ||
needs: generate-matrix | ||
runs-on: ${{ matrix.linux.runner }} | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJson(needs.generate-matrix.outputs.linux-matrix) }} | ||
container: | ||
image: ${{ matrix.linux.image }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- name: Mark the workspace as safe | ||
# https://github.com/actions/checkout/issues/766 | ||
run: git config --global --add safe.directory ${GITHUB_WORKSPACE} | ||
- name: Pre-build | ||
if: ${{ matrix.linux.setup_command }} | ||
run: | | ||
${{ matrix.linux.setup_command }} | ||
- name: Run matrix job | ||
run: | | ||
${{ matrix.linux.command }} ${{ matrix.linux.command_arguments }} | ||
windows: | ||
name: Windows (${{ matrix.windows.name }}) | ||
needs: generate-matrix | ||
runs-on: ${{ matrix.windows.runner }} | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJson(needs.generate-matrix.outputs.windows-matrix) }} | ||
steps: | ||
- name: Pull Docker image | ||
run: docker pull ${{ matrix.windows.image }} | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
submodules: true | ||
- name: Run matrix job | ||
run: | | ||
if (-not [string]::IsNullOrEmpty("${{ matrix.windows.setup_command }}")) { | ||
$setup_command_expression = "${{ matrix.windows.setup_command }};" | ||
} else { | ||
$setup_command_expression = "" | ||
} | ||
docker run -v ${{ github.workspace }}:C:\source ${{ matrix.windows.image }} cmd /s /c "swift --version & cd C:\source\ & powershell Invoke-Expression ""$($setup_command_expression) ${{ matrix.windows.command }} ${{ matrix.windows.command_arguments }}""" |
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
Oops, something went wrong.