Skip to content

Commit

Permalink
rename top matrix workflow object 'swift'->'config'
Browse files Browse the repository at this point in the history
Motivation:

The use of 'swift' here is very arbitrary and adds no value. The object
is only there at all because GitHub Actions seems to require it.

Modifications:

Rename the top-level object from 'swift' to 'config' to maybe add value
to the intent of the object and hopefully be less cryptic.

Result:

Everything should just keep working.
  • Loading branch information
rnro committed Dec 12, 2024
1 parent b2356d9 commit d3b34b9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
unit-tests:
name: Unit tests
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
uses: apple/swift-nio/.github/workflows/unit_tests.yml@rename_matrix_workflow_object # TODO: change to @main
with:
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
Expand Down
32 changes: 16 additions & 16 deletions .github/workflows/swift_test_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ concurrency:

jobs:
execute-matrix:
name: ${{ matrix.swift.platform }} (${{ matrix.swift.name }})
runs-on: ${{ matrix.swift.runner }}
name: ${{ matrix.config.platform }} (${{ matrix.config.name }})
runs-on: ${{ matrix.config.runner }}
strategy:
fail-fast: false
matrix: ${{ fromJson(inputs.matrix_string) }}
Expand All @@ -31,37 +31,37 @@ jobs:
persist-credentials: false
submodules: true
- name: Pull Docker image
run: docker pull ${{ matrix.swift.image }}
run: docker pull ${{ matrix.config.image }}
- name: Run matrix job
if: ${{ matrix.swift.platform != 'Windows' }}
if: ${{ matrix.config.platform != 'Windows' }}
run: |
if [[ -n "${{ matrix.swift.setup_command }}" ]]; then
setup_command_expression="${{ matrix.swift.setup_command }} &&"
if [[ -n "${{ matrix.config.setup_command }}" ]]; then
setup_command_expression="${{ matrix.config.setup_command }} &&"
else
setup_command_expression=""
fi
workspace="/$(basename ${{ github.workspace }})"
docker run -v ${{ github.workspace }}:"$workspace" \
-w "$workspace" \
-e SWIFT_VERSION="${{ matrix.swift.swift_version }}" \
-e SWIFT_VERSION="${{ matrix.config.swift_version }}" \
-e setup_command_expression="$setup_command_expression" \
-e workspace="$workspace" \
${{ matrix.swift.image }} \
bash -c "swift --version && git config --global --add safe.directory \"$workspace\" && $setup_command_expression ${{ matrix.swift.command }} ${{ matrix.swift.command_arguments }}"
${{ matrix.config.image }} \
bash -c "swift --version && git config --global --add safe.directory \"$workspace\" && $setup_command_expression ${{ matrix.config.command }} ${{ matrix.config.command_arguments }}"
- name: Run matrix job (Windows)
if: ${{ matrix.swift.platform == 'Windows' }}
if: ${{ matrix.config.platform == 'Windows' }}
run: |
if (-not [string]::IsNullOrEmpty("${{ matrix.swift.setup_command }}")) {
$setup_command_expression = "${{ matrix.swift.setup_command }} &"
if (-not [string]::IsNullOrEmpty("${{ matrix.config.setup_command }}")) {
$setup_command_expression = "${{ matrix.config.setup_command }} &"
} else {
$setup_command_expression = ""
}
$workspace = "C:\" + (Split-Path ${{ github.workspace }} -Leaf)
docker run -v ${{ github.workspace }}:$($workspace) `
-w $($workspace) `
-e SWIFT_VERSION="${{ matrix.swift.swift_version }}" `
-e SWIFT_VERSION="${{ matrix.config.swift_version }}" `
-e setup_command_expression=%setup_command_expression% `
${{ matrix.swift.image }} `
cmd /s /c "swift --version & powershell Invoke-Expression ""$($setup_command_expression) ${{ matrix.swift.command }} ${{ matrix.swift.command_arguments }}"""
${{ matrix.config.image }} `
cmd /s /c "swift --version & powershell Invoke-Expression ""$($setup_command_expression) ${{ matrix.config.command }} ${{ matrix.config.command_arguments }}"""
env:
SWIFT_VERSION: ${{ matrix.swift.swift_version }}
SWIFT_VERSION: ${{ matrix.config.swift_version }}
4 changes: 2 additions & 2 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
with:
persist-credentials: false
- id: generate-matrix
run: echo "unit-test-matrix=$(curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT"
run: echo "unit-test-matrix=$(curl -s https://raw.githubusercontent.com/apple/swift-nio/rename_matrix_workflow_object/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" # TODO: change to @main
env:
MATRIX_LINUX_COMMAND: "swift test"
MATRIX_LINUX_5_9_ENABLED: ${{ inputs.linux_5_9_enabled }}
Expand All @@ -106,7 +106,7 @@ jobs:
name: Unit tests
needs: construct-matrix
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/swift_test_matrix.yml@main
uses: apple/swift-nio/.github/workflows/swift_test_matrix.yml@rename_matrix_workflow_object # TODO: change to @main
with:
name: "Unit tests"
matrix_string: '${{ needs.construct-matrix.outputs.unit-test-matrix }}'
18 changes: 9 additions & 9 deletions scripts/generate_matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ windows_nightly_main_runner="windows-2019"
windows_nightly_main_container_image="swiftlang/swift:nightly-main-windowsservercore-1809"

# Create matrix from inputs
matrix='{"swift": []}'
matrix='{"config": []}'

## Linux
if [[ "$linux_5_9_enabled" == "true" || "$linux_5_10_enabled" == "true" || "$linux_6_0_enabled" == "true" || \
Expand All @@ -70,7 +70,7 @@ if [[ "$linux_5_9_enabled" == "true" ]]; then
--arg command_arguments "$linux_5_9_command_arguments" \
--arg container_image "$linux_5_9_container_image" \
--arg runner "$linux_runner" \
'.swift[.swift| length] |= . + { "name": "5.9", "image": $container_image, "swift_version": "5.9", "platform": "Linux", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner}')
'.config[.config| length] |= . + { "name": "5.9", "image": $container_image, "swift_version": "5.9", "platform": "Linux", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner}')
fi

if [[ "$linux_5_10_enabled" == "true" ]]; then
Expand All @@ -80,7 +80,7 @@ if [[ "$linux_5_10_enabled" == "true" ]]; then
--arg command_arguments "$linux_5_10_command_arguments" \
--arg container_image "$linux_5_10_container_image" \
--arg runner "$linux_runner" \
'.swift[.swift| length] |= . + { "name": "5.10", "image": $container_image, "swift_version": "5.10", "platform": "Linux", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner}')
'.config[.config| length] |= . + { "name": "5.10", "image": $container_image, "swift_version": "5.10", "platform": "Linux", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner}')
fi

if [[ "$linux_6_0_enabled" == "true" ]]; then
Expand All @@ -90,7 +90,7 @@ if [[ "$linux_6_0_enabled" == "true" ]]; then
--arg command_arguments "$linux_6_0_command_arguments" \
--arg container_image "$linux_6_0_container_image" \
--arg runner "$linux_runner" \
'.swift[.swift| length] |= . + { "name": "6.0", "image": $container_image, "swift_version": "6.0", "platform": "Linux", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner}')
'.config[.config| length] |= . + { "name": "6.0", "image": $container_image, "swift_version": "6.0", "platform": "Linux", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner}')
fi

if [[ "$linux_nightly_6_0_enabled" == "true" ]]; then
Expand All @@ -100,7 +100,7 @@ if [[ "$linux_nightly_6_0_enabled" == "true" ]]; then
--arg command_arguments "$linux_nightly_6_0_command_arguments" \
--arg container_image "$linux_nightly_6_0_container_image" \
--arg runner "$linux_runner" \
'.swift[.swift| length] |= . + { "name": "nightly-6.0", "image": $container_image, "swift_version": "nightly-6.0", "platform": "Linux", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner}')
'.config[.config| length] |= . + { "name": "nightly-6.0", "image": $container_image, "swift_version": "nightly-6.0", "platform": "Linux", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner}')
fi

if [[ "$linux_nightly_main_enabled" == "true" ]]; then
Expand All @@ -110,7 +110,7 @@ if [[ "$linux_nightly_main_enabled" == "true" ]]; then
--arg command_arguments "$linux_nightly_main_command_arguments" \
--arg container_image "$linux_nightly_main_container_image" \
--arg runner "$linux_runner" \
'.swift[.swift| length] |= . + { "name": "nightly-main", "image": $container_image, "swift_version": "nightly-main", "platform": "Linux", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner}')
'.config[.config| length] |= . + { "name": "nightly-main", "image": $container_image, "swift_version": "nightly-main", "platform": "Linux", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner}')
fi

## Windows
Expand All @@ -127,7 +127,7 @@ if [[ "$windows_6_0_enabled" == "true" ]]; then
--arg command_arguments "$windows_6_0_command_arguments" \
--arg container_image "$windows_6_0_container_image" \
--arg runner "$windows_6_0_runner" \
'.swift[.swift| length] |= . + { "name": "6.0", "image": $container_image, "swift_version": "6.0", "platform": "Windows", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner }')
'.config[.config| length] |= . + { "name": "6.0", "image": $container_image, "swift_version": "6.0", "platform": "Windows", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner }')
fi

if [[ "$windows_nightly_6_0_enabled" == "true" ]]; then
Expand All @@ -137,7 +137,7 @@ if [[ "$windows_nightly_6_0_enabled" == "true" ]]; then
--arg command_arguments "$windows_nightly_6_0_command_arguments" \
--arg container_image "$windows_nightly_6_0_container_image" \
--arg runner "$windows_nightly_6_0_runner" \
'.swift[.swift| length] |= . + { "name": "nightly-6.0", "image": $container_image, "swift_version": "nightly-6.0", "platform": "Windows", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner }')
'.config[.config| length] |= . + { "name": "nightly-6.0", "image": $container_image, "swift_version": "nightly-6.0", "platform": "Windows", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner }')
fi

if [[ "$windows_nightly_main_enabled" == "true" ]]; then
Expand All @@ -147,7 +147,7 @@ if [[ "$windows_nightly_main_enabled" == "true" ]]; then
--arg command_arguments "$windows_nightly_main_command_arguments" \
--arg container_image "$windows_nightly_main_container_image" \
--arg runner "$windows_nightly_main_runner" \
'.swift[.swift| length] |= . + { "name": "nightly-main", "image": $container_image, "swift_version": "nightly-main", "platform": "Windows", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner }')
'.config[.config| length] |= . + { "name": "nightly-main", "image": $container_image, "swift_version": "nightly-main", "platform": "Windows", "command": $command, "command_arguments": $command_arguments, "setup_command": $setup_command, "runner": $runner }')
fi

echo "$matrix" | jq -c

0 comments on commit d3b34b9

Please sign in to comment.