mirror of
https://github.com/apple/swift-nio
synced 2026-11-28 05:14:23 +00:00
Don't generate matrix jobs for Swift versions which aren't supported by the package. ### Motivation: Matrix workflows should not generate jobs for Swift versions < tools version, doing so wastes compute and adds noise. This means that: - New repos don’t need to manually opt-out of old Swift versions - Repos which have dropped an old Swift version (during a migration window) won’t have failing tests until it’s turned off centrally. ### Modifications: - The generate script now looks for `Package.swift` and `Package@swift-*.swift` files and uses the lowest tools version in any found file to determine the minimum supported Swift version - Any Swift version lower than the minimum is disregarded and no jobs are generated for it - A new parameter is added to the workflows which allows the minimum Swift version to be set manually (`minimum_swift_version`) ### Result: By default in this and downstream packages we don't generate matrix jobs for Swift versions which aren't supported by the package. An example of this working: https://github.com/apple/swift-nio/actions/runs/18711362977/job/53360387720?pr=3415
126 lines
5.6 KiB
YAML
126 lines
5.6 KiB
YAML
name: Benchmarks
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
benchmark_package_path:
|
|
type: string
|
|
description: "Path to the directory containing the benchmarking package. Defaults to ."
|
|
default: "."
|
|
swift_package_arguments:
|
|
type: string
|
|
description: "Arguments to the switch package command invocation e.g. `--disable-sandbox`"
|
|
linux_5_9_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the Linux 5.9 Swift version matrix job. Defaults to false."
|
|
default: false
|
|
linux_5_10_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the Linux 5.10 Swift version matrix job. Defaults to true."
|
|
default: true
|
|
linux_6_0_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the Linux 6.0 Swift version matrix job. Defaults to true."
|
|
default: true
|
|
linux_6_1_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the Linux 6.1 Swift version matrix job. Defaults to true."
|
|
default: true
|
|
linux_6_2_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the Linux 6.2 Swift version matrix job. Defaults to true."
|
|
default: true
|
|
linux_nightly_6_0_enabled:
|
|
type: boolean
|
|
description: "⚠️ Deprecated, we no longer run against 6.0 nightly."
|
|
default: false
|
|
linux_nightly_6_1_enabled:
|
|
type: boolean
|
|
description: "⚠️ Deprecated, use linux_nightly_next_enabled."
|
|
default: true
|
|
linux_nightly_next_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the Linux nightly matrix job for the next Swift version. Defaults to true."
|
|
default: true
|
|
linux_nightly_main_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the Linux nightly main Swift version matrix job. Defaults to true."
|
|
default: true
|
|
|
|
windows_6_0_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the Windows 6.0 Swift version matrix job. Currently has no effect!" # TODO: implement Windows benchmarking
|
|
default: false
|
|
windows_6_1_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the Windows 6.1 Swift version matrix job. Currently has no effect!" # TODO: implement Windows benchmarking
|
|
default: false
|
|
windows_6_2_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the Windows 6.2 Swift version matrix job. Currently has no effect!" # TODO: implement Windows benchmarking
|
|
default: false
|
|
windows_nightly_6_0_enabled:
|
|
type: boolean
|
|
description: "⚠️ Deprecated, we no longer run against 6.0 nightly." # TODO: implement Windows benchmarking
|
|
default: false
|
|
windows_nightly_main_enabled:
|
|
type: boolean
|
|
description: "Boolean to enable the Windows nightly main Swift version matrix job. Currently has no effect!" # TODO: implement Windows benchmarking
|
|
default: false
|
|
|
|
linux_env_vars:
|
|
type: string
|
|
description: "Environment variables for Linux jobs as JSON (e.g., '{\"DEBUG\":\"1\",\"LOG_LEVEL\":\"info\"}')."
|
|
default: "{}"
|
|
|
|
minimum_swift_version:
|
|
type: string
|
|
description: "Minimum Swift version to include in the matrix. Leave empty for auto-detection from Package.swift, specify a version like '6.0' to override, or set to 'none' to disable filtering."
|
|
default: ""
|
|
|
|
jobs:
|
|
construct-matrix:
|
|
name: Construct Benchmarks matrix
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
benchmarks-matrix: '${{ steps.generate-matrix.outputs.benchmarks-matrix }}'
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
- id: generate-matrix
|
|
run: |
|
|
# Validate JSON environment variables
|
|
linux_env_vars_json='${{ inputs.linux_env_vars }}'
|
|
|
|
if ! echo "$linux_env_vars_json" | jq empty 2>/dev/null; then
|
|
echo "Error: linux_env_vars is not valid JSON"
|
|
exit 1
|
|
fi
|
|
|
|
echo "benchmarks-matrix=$(curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | MATRIX_LINUX_ENV_VARS_JSON="${linux_env_vars_json}" bash)" >> "$GITHUB_OUTPUT"
|
|
env:
|
|
MATRIX_LINUX_COMMAND: "curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check_benchmark_thresholds.sh | BENCHMARK_PACKAGE_PATH=${{ inputs.benchmark_package_path }} bash"
|
|
MATRIX_LINUX_SETUP_COMMAND: "swift --version && apt-get update -y -q && apt-get install -y -q curl libjemalloc-dev && git config --global --add safe.directory /$(basename ${{ github.workspace }})"
|
|
MATRIX_MIN_SWIFT_VERSION: ${{ inputs.minimum_swift_version }}
|
|
MATRIX_LINUX_5_9_ENABLED: ${{ inputs.linux_5_9_enabled }}
|
|
MATRIX_LINUX_5_10_ENABLED: ${{ inputs.linux_5_10_enabled }}
|
|
MATRIX_LINUX_6_0_ENABLED: ${{ inputs.linux_6_0_enabled }}
|
|
MATRIX_LINUX_6_1_ENABLED: ${{ inputs.linux_6_1_enabled }}
|
|
MATRIX_LINUX_6_2_ENABLED: ${{ inputs.linux_6_2_enabled }}
|
|
MATRIX_LINUX_NIGHTLY_NEXT_ENABLED: ${{ inputs.linux_nightly_6_1_enabled && inputs.linux_nightly_next_enabled }}
|
|
MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: ${{ inputs.linux_nightly_main_enabled }}
|
|
|
|
benchmarks:
|
|
name: Benchmarks
|
|
needs: construct-matrix
|
|
# Workaround https://github.com/nektos/act/issues/1875
|
|
uses: apple/swift-nio/.github/workflows/swift_test_matrix.yml@main
|
|
with:
|
|
name: "Benchmarks"
|
|
matrix_string: '${{ needs.construct-matrix.outputs.benchmarks-matrix }}'
|