|
71 | 71 | description: "Boolean to enable the Windows nightly main Swift version matrix job. Currently has no effect!" # TODO: implement Windows benchmarking |
72 | 72 | default: false |
73 | 73 |
|
| 74 | + macos_xcode_16_3_enabled: |
| 75 | + type: boolean |
| 76 | + description: "Boolean to enable the macOS Xcode 16.3 benchmark job. Defaults to false." |
| 77 | + default: false |
| 78 | + macos_xcode_16_4_enabled: |
| 79 | + type: boolean |
| 80 | + description: "Boolean to enable the macOS Xcode 16.4 benchmark job. Defaults to false." |
| 81 | + default: false |
| 82 | + macos_xcode_26_0_enabled: |
| 83 | + type: boolean |
| 84 | + description: "Boolean to enable the macOS Xcode 26.0 benchmark job. Defaults to false." |
| 85 | + default: false |
| 86 | + macos_xcode_26_1_enabled: |
| 87 | + type: boolean |
| 88 | + description: "Boolean to enable the macOS Xcode 26.1 benchmark job. Defaults to false." |
| 89 | + default: false |
| 90 | + macos_xcode_latest_beta_enabled: |
| 91 | + type: boolean |
| 92 | + description: "Boolean to enable the macOS Xcode latest beta benchmark job. Defaults to false." |
| 93 | + default: false |
| 94 | + |
| 95 | + macos_runner_pool: |
| 96 | + type: string |
| 97 | + description: "The runner pool which will be requested for macOS jobs." |
| 98 | + default: "nightly" |
| 99 | + |
| 100 | + macos_env_vars: |
| 101 | + type: string |
| 102 | + description: "Environment variables for macOS jobs as JSON (e.g., '{\"DEBUG\":\"1\",\"LOG_LEVEL\":\"info\"}')." |
| 103 | + default: "{}" |
| 104 | + |
74 | 105 | linux_env_vars: |
75 | 106 | type: string |
76 | 107 | description: "Environment variables for Linux jobs as JSON (e.g., '{\"DEBUG\":\"1\",\"LOG_LEVEL\":\"info\"}')." |
|
82 | 113 | default: "" |
83 | 114 |
|
84 | 115 | jobs: |
85 | | - construct-matrix: |
86 | | - name: Construct Benchmarks matrix |
| 116 | + construct-matrix-linux: |
| 117 | + name: Construct Linux Benchmarks matrix |
87 | 118 | runs-on: ubuntu-latest |
88 | 119 | outputs: |
89 | 120 | benchmarks-matrix: '${{ steps.generate-matrix.outputs.benchmarks-matrix }}' |
@@ -115,11 +146,121 @@ jobs: |
115 | 146 | MATRIX_LINUX_NIGHTLY_NEXT_ENABLED: ${{ inputs.linux_nightly_6_1_enabled && inputs.linux_nightly_next_enabled }} |
116 | 147 | MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: ${{ inputs.linux_nightly_main_enabled }} |
117 | 148 |
|
118 | | - benchmarks: |
| 149 | + construct-matrix-macos: |
| 150 | + name: Construct macOS Benchmarks matrix |
| 151 | + runs-on: ubuntu-latest |
| 152 | + if: | |
| 153 | + inputs.macos_xcode_16_3_enabled || |
| 154 | + inputs.macos_xcode_16_4_enabled || |
| 155 | + inputs.macos_xcode_26_0_enabled || |
| 156 | + inputs.macos_xcode_26_1_enabled || |
| 157 | + inputs.macos_xcode_latest_beta_enabled |
| 158 | + outputs: |
| 159 | + macos-matrix: '${{ steps.generate-matrix.outputs.macos-matrix }}' |
| 160 | + steps: |
| 161 | + - name: Checkout repository |
| 162 | + uses: actions/checkout@v4 |
| 163 | + with: |
| 164 | + persist-credentials: false |
| 165 | + - id: generate-matrix |
| 166 | + run: | |
| 167 | + # Validate JSON environment variables |
| 168 | + macos_env_vars_json='${{ inputs.macos_env_vars }}' |
| 169 | +
|
| 170 | + if ! echo "$macos_env_vars_json" | jq empty 2>/dev/null; then |
| 171 | + echo "Error: macos_env_vars is not valid JSON" |
| 172 | + exit 1 |
| 173 | + fi |
| 174 | +
|
| 175 | + runner_pool="${MACOS_RUNNER_POOL}" |
| 176 | + xcode_16_3_enabled="${MACOS_XCODE_16_3_ENABLED}" |
| 177 | + xcode_16_4_enabled="${MACOS_XCODE_16_4_ENABLED}" |
| 178 | + xcode_26_0_enabled="${MACOS_XCODE_26_0_ENABLED}" |
| 179 | + xcode_26_1_enabled="${MACOS_XCODE_26_1_ENABLED}" |
| 180 | + xcode_latest_beta_enabled="${MACOS_XCODE_LATEST_BETA_ENABLED}" |
| 181 | +
|
| 182 | + # Create matrix from inputs |
| 183 | + matrix='{"config": []}' |
| 184 | +
|
| 185 | + if [[ "$xcode_16_3_enabled" == "true" ]]; then |
| 186 | + matrix=$(echo "$matrix" | jq -c \ |
| 187 | + --arg runner_pool "$runner_pool" \ |
| 188 | + --argjson env_vars "$macos_env_vars_json" \ |
| 189 | + '.config[.config| length] |= . + { "name": "macOS (Xcode 16.3)", "xcode_version": "16.3", "xcode_app": "Xcode_16.3.app", "os": "sequoia", "arch": "ARM64", "pool": $runner_pool, "env": $env_vars }') |
| 190 | + fi |
| 191 | +
|
| 192 | + if [[ "$xcode_16_4_enabled" == "true" ]]; then |
| 193 | + matrix=$(echo "$matrix" | jq -c \ |
| 194 | + --arg runner_pool "$runner_pool" \ |
| 195 | + --argjson env_vars "$macos_env_vars_json" \ |
| 196 | + '.config[.config| length] |= . + { "name": "macOS (Xcode 16.4)", "xcode_version": "16.4", "xcode_app": "Xcode_16.4.app", "os": "sequoia", "arch": "ARM64", "pool": $runner_pool, "env": $env_vars }') |
| 197 | + fi |
| 198 | +
|
| 199 | + if [[ "$xcode_26_0_enabled" == "true" ]]; then |
| 200 | + matrix=$(echo "$matrix" | jq -c \ |
| 201 | + --arg runner_pool "$runner_pool" \ |
| 202 | + --argjson env_vars "$macos_env_vars_json" \ |
| 203 | + '.config[.config| length] |= . + { "name": "macOS (Xcode 26.0)", "xcode_version": "26.0", "xcode_app": "Xcode_26.0.app", "os": "sequoia", "arch": "ARM64", "pool": $runner_pool, "env": $env_vars }') |
| 204 | + fi |
| 205 | +
|
| 206 | + if [[ "$xcode_26_1_enabled" == "true" ]]; then |
| 207 | + matrix=$(echo "$matrix" | jq -c \ |
| 208 | + --arg runner_pool "$runner_pool" \ |
| 209 | + --argjson env_vars "$macos_env_vars_json" \ |
| 210 | + '.config[.config| length] |= . + { "name": "macOS (Xcode 26.1)", "xcode_version": "26.1", "xcode_app": "Xcode_26.1.app", "os": "sequoia", "arch": "ARM64", "pool": $runner_pool, "env": $env_vars }') |
| 211 | + fi |
| 212 | +
|
| 213 | + if [[ "$xcode_latest_beta_enabled" == "true" ]]; then |
| 214 | + matrix=$(echo "$matrix" | jq -c \ |
| 215 | + --arg runner_pool "$runner_pool" \ |
| 216 | + --argjson env_vars "$macos_env_vars_json" \ |
| 217 | + '.config[.config| length] |= . + { "name": "macOS (Xcode latest beta)", "xcode_version": "latest beta", "xcode_app": "Xcode-latest.app", "os": "sequoia", "arch": "ARM64", "pool": $runner_pool, "env": $env_vars }') |
| 218 | + fi |
| 219 | +
|
| 220 | + echo "macos-matrix=$matrix" >> "$GITHUB_OUTPUT" |
| 221 | + env: |
| 222 | + MACOS_RUNNER_POOL: ${{ inputs.macos_runner_pool }} |
| 223 | + MACOS_XCODE_16_3_ENABLED: ${{ inputs.macos_xcode_16_3_enabled }} |
| 224 | + MACOS_XCODE_16_4_ENABLED: ${{ inputs.macos_xcode_16_4_enabled }} |
| 225 | + MACOS_XCODE_26_0_ENABLED: ${{ inputs.macos_xcode_26_0_enabled }} |
| 226 | + MACOS_XCODE_26_1_ENABLED: ${{ inputs.macos_xcode_26_1_enabled }} |
| 227 | + MACOS_XCODE_LATEST_BETA_ENABLED: ${{ inputs.macos_xcode_latest_beta_enabled }} |
| 228 | + |
| 229 | + benchmarks-linux: |
119 | 230 | name: Benchmarks |
120 | | - needs: construct-matrix |
| 231 | + needs: construct-matrix-linux |
121 | 232 | # Workaround https://github.com/nektos/act/issues/1875 |
122 | 233 | uses: apple/swift-nio/.github/workflows/swift_test_matrix.yml@main |
123 | 234 | with: |
124 | 235 | name: "Benchmarks" |
125 | | - matrix_string: '${{ needs.construct-matrix.outputs.benchmarks-matrix }}' |
| 236 | + matrix_string: '${{ needs.construct-matrix-linux.outputs.benchmarks-matrix }}' |
| 237 | + |
| 238 | + benchmarks-macos: |
| 239 | + name: ${{ matrix.config.name }} |
| 240 | + needs: construct-matrix-macos |
| 241 | + runs-on: [self-hosted, macos, "${{ matrix.config.os }}", "${{ matrix.config.arch }}", "${{ matrix.config.pool }}"] |
| 242 | + timeout-minutes: 30 |
| 243 | + strategy: |
| 244 | + fail-fast: false |
| 245 | + matrix: ${{ fromJson(needs.construct-matrix-macos.outputs.macos-matrix) }} |
| 246 | + steps: |
| 247 | + - name: Checkout repository |
| 248 | + uses: actions/checkout@v4 |
| 249 | + with: |
| 250 | + persist-credentials: false |
| 251 | + submodules: true |
| 252 | + - name: Install jemalloc |
| 253 | + run: | |
| 254 | + brew install jemalloc |
| 255 | + - name: Export environment variables |
| 256 | + if: ${{ matrix.config.env != '' && matrix.config.env != '{}'}} |
| 257 | + run: | |
| 258 | + echo "Exporting environment variables from matrix configuration..." |
| 259 | + echo '${{ toJSON(matrix.config.env) }}' | jq -r 'to_entries[] | "\(.key)=\(.value)"' >> $GITHUB_ENV |
| 260 | + echo '${{ toJSON(matrix.config.env) }}' | jq -r 'to_entries[] | "exporting \(.key)=\(.value)"' |
| 261 | + - name: Run benchmarks script |
| 262 | + run: | |
| 263 | + curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check_benchmark_thresholds.sh | BENCHMARK_PACKAGE_PATH=${{ inputs.benchmark_package_path }} bash -s -- --disable-sandbox --allow-writing-to-package-directory |
| 264 | + env: |
| 265 | + DEVELOPER_DIR: "/Applications/${{ matrix.config.xcode_app }}" |
| 266 | + SWIFT_VERSION: "Xcode ${{ matrix.config.xcode_version }}" |
0 commit comments