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-linux: name: Construct Linux Benchmarks matrix runs-on: ubuntu-latest outputs: benchmarks-matrix: '${{ steps.generate-matrix.outputs.benchmarks-matrix }}' steps: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 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-linux: name: Benchmarks needs: construct-matrix-linux # 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-linux.outputs.benchmarks-matrix }}'