Skip to content

Commit 207c509

Browse files
committed
WIP
1 parent 33b8a48 commit 207c509

File tree

6 files changed

+386
-55
lines changed

6 files changed

+386
-55
lines changed

.github/workflows/benchmarks.yml

+25-11
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,32 @@ on:
4545
default: false
4646

4747
jobs:
48+
construct-matrix:
49+
name: Construct Benchmarks matrix
50+
runs-on: ubuntu-latest
51+
outputs:
52+
benchmarks-matrix: '${{ steps.generate-matrix.outputs.benchmarks-matrix }}'
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v4
56+
with:
57+
persist-credentials: false
58+
- id: generate-matrix
59+
run: echo "benchmarks-matrix=$(./scripts/generate_matrix.sh)" >> "$GITHUB_OUTPUT"
60+
env:
61+
MATRIX_LINUX_COMMAND: "swift package --package-path ${{ inputs.benchmark_package_path }} ${{ inputs.swift_package_arguments }} benchmark baseline check --check-absolute-path ${{ inputs.benchmark_package_path }}/Thresholds/${SWIFT_VERSION}/"
62+
MATRIX_LINUX_SETUP_COMMAND: "apt-get update -y -q && apt-get install -y -q libjemalloc-dev"
63+
MATRIX_LINUX_5_9_ENABLED: ${{ inputs.linux_5_9_enabled }}
64+
MATRIX_LINUX_5_10_ENABLED: ${{ inputs.linux_5_10_enabled }}
65+
MATRIX_LINUX_6_0_ENABLED: ${{ inputs.linux_6_0_enabled }}
66+
MATRIX_LINUX_NIGHTLY_6_0_ENABLED: ${{ inputs.linux_nightly_6_0_enabled }}
67+
MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: ${{ inputs.linux_nightly_main_enabled }}
68+
4869
benchmarks:
4970
name: Benchmarks
50-
# Workaround https://github.com/nektos/act/issues/1875
51-
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
71+
needs: construct-matrix
72+
# TODO: use global reference
73+
uses: ./.github/workflows/swift_test_matrix.yml
5274
with:
5375
name: "Benchmarks"
54-
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q libjemalloc-dev && swift package --package-path ${{ inputs.benchmark_package_path }} ${{ inputs.swift_package_arguments }} benchmark baseline check --check-absolute-path ${{ inputs.benchmark_package_path }}/Thresholds/${SWIFT_VERSION}/"
55-
matrix_linux_5_9_enabled: ${{ inputs.linux_5_9_enabled }}
56-
matrix_linux_5_10_enabled: ${{ inputs.linux_5_10_enabled }}
57-
matrix_linux_6_0_enabled: ${{ inputs.linux_6_0_enabled }}
58-
matrix_linux_nightly_6_0_enabled: ${{ inputs.linux_nightly_6_0_enabled }}
59-
matrix_linux_nightly_main_enabled: ${{ inputs.linux_nightly_main_enabled }}
60-
matrix_windows_6_0_enabled: ${{ inputs.windows_6_0_enabled }}
61-
matrix_windows_nightly_6_0_enabled: ${{ inputs.windows_nightly_6_0_enabled }}
62-
matrix_windows_nightly_main_enabled: ${{ inputs.windows_nightly_main_enabled }}
76+
matrix_string: '${{ needs.construct-matrix.outputs.benchmarks-matrix }}'

.github/workflows/cxx_interop.yml

+28-14
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,44 @@ on:
2626

2727
windows_6_0_enabled:
2828
type: boolean
29-
description: "Boolean to enable the Windows 6.0 Swift version matrix job. Defaults to true."
29+
description: "Boolean to enable the Windows 6.0 Swift version matrix job. Defaults to false. Currently has no effect!" # TODO: implement Windows Cxx compat checking
3030
default: false
3131
windows_nightly_6_0_enabled:
3232
type: boolean
33-
description: "Boolean to enable the Windows nightly 6.0 Swift version matrix job. Defaults to true."
33+
description: "Boolean to enable the Windows nightly 6.0 Swift version matrix job. Defaults to false. Currently has no effect!" # TODO: implement Windows Cxx compat checking
3434
default: false
3535
windows_nightly_main_enabled:
3636
type: boolean
37-
description: "Boolean to enable the Windows nightly main Swift version matrix job. Defaults to true."
37+
description: "Boolean to enable the Windows nightly main Swift version matrix job. Defaults to false. Currently has no effect!" # TODO: implement Windows Cxx compat checking
3838
default: false
3939

4040
jobs:
41+
construct-matrix:
42+
name: Construct Cxx interop matrix
43+
runs-on: ubuntu-latest
44+
outputs:
45+
cxx-interop-matrix: '${{ steps.generate-matrix.outputs.cxx-interop-matrix }}'
46+
steps:
47+
- name: Checkout repository
48+
uses: actions/checkout@v4
49+
with:
50+
persist-credentials: false
51+
- id: generate-matrix
52+
run: echo "cxx-interop-matrix=$(./scripts/generate_matrix.sh)" >> "$GITHUB_OUTPUT"
53+
env:
54+
MATRIX_LINUX_COMMAND: "curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-cxx-interop-compatibility.sh | bash"
55+
MATRIX_LINUX_SETUP_COMMAND: "apt-get update -y -q && apt-get install -y -q curl jq"
56+
MATRIX_LINUX_5_9_ENABLED: ${{ inputs.linux_5_9_enabled }}
57+
MATRIX_LINUX_5_10_ENABLED: ${{ inputs.linux_5_10_enabled }}
58+
MATRIX_LINUX_6_0_ENABLED: ${{ inputs.linux_6_0_enabled }}
59+
MATRIX_LINUX_NIGHTLY_6_0_ENABLED: ${{ inputs.linux_nightly_6_0_enabled }}
60+
MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: ${{ inputs.linux_nightly_main_enabled }}
61+
4162
cxx-interop:
4263
name: Cxx interop
43-
# Workaround https://github.com/nektos/act/issues/1875
44-
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
64+
needs: construct-matrix
65+
# TODO: use global reference
66+
uses: ./.github/workflows/swift_test_matrix.yml
4567
with:
4668
name: "Cxx interop"
47-
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q jq && curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-cxx-interop-compatibility.sh | bash"
48-
matrix_linux_5_9_enabled: ${{ inputs.linux_5_9_enabled }}
49-
matrix_linux_5_10_enabled: ${{ inputs.linux_5_10_enabled }}
50-
matrix_linux_6_0_enabled: ${{ inputs.linux_6_0_enabled }}
51-
matrix_linux_nightly_6_0_enabled: ${{ inputs.linux_nightly_6_0_enabled }}
52-
matrix_linux_nightly_main_enabled: ${{ inputs.linux_nightly_main_enabled }}
53-
matrix_windows_6_0_enabled: ${{ inputs.windows_6_0_enabled }}
54-
matrix_windows_nightly_6_0_enabled: ${{ inputs.windows_nightly_6_0_enabled }}
55-
matrix_windows_nightly_main_enabled: ${{ inputs.windows_nightly_main_enabled }}
69+
matrix_string: '${{ needs.construct-matrix.outputs.cxx-interop-matrix }}'

.github/workflows/pull_request.yml

+27-10
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313

1414
unit-tests:
1515
name: Unit tests
16-
# Workaround https://github.com/nektos/act/issues/1875
17-
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
16+
# TODO: revert
17+
uses: ./.github/workflows/unit_tests.yml
1818
with:
1919
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
2020
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
@@ -24,23 +24,40 @@ jobs:
2424

2525
benchmarks:
2626
name: Benchmarks
27-
# Workaround https://github.com/nektos/act/issues/1875
28-
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
27+
# TODO: use global reference
28+
uses: ./.github/workflows/benchmarks.yml
2929
with:
3030
benchmark_package_path: "Benchmarks"
3131

3232
cxx-interop:
3333
name: Cxx interop
34-
# Workaround https://github.com/nektos/act/issues/1875
35-
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
34+
# TODO: use global reference
35+
uses: ./.github/workflows/cxx_interop.yml
36+
37+
construct-integration-test-matrix:
38+
name: Construct integration test matrix
39+
runs-on: ubuntu-latest
40+
outputs:
41+
integration-test-matrix: '${{ steps.generate-matrix.outputs.integration-test-matrix }}'
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
with:
46+
persist-credentials: false
47+
- id: generate-matrix
48+
run: echo "integration-test-matrix=$(./scripts/generate_matrix.sh)" >> "$GITHUB_OUTPUT"
49+
env:
50+
MATRIX_LINUX_SETUP_COMMAND: "apt-get update -y -q && apt-get install -y -q lsof dnsutils netcat-openbsd net-tools curl jq"
51+
MATRIX_LINUX_COMMAND: "./scripts/integration_tests.sh"
3652

3753
integration-tests:
38-
name: Integration Tests
39-
# Workaround https://github.com/nektos/act/issues/1875
40-
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
54+
name: Integration tests
55+
needs: construct-integration-test-matrix
56+
# TODO: use global reference
57+
uses: ./.github/workflows/swift_test_matrix.yml
4158
with:
4259
name: "Integration tests"
43-
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q lsof dnsutils netcat-openbsd net-tools curl jq && ./scripts/integration_tests.sh"
60+
matrix_string: '${{ needs.construct-integration-test-matrix.outputs.integration-test-matrix }}'
4461

4562
vsock-tests:
4663
name: Vsock tests
+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Matrix
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
name:
7+
type: string
8+
description: "The name of the workflow used for the concurrency group."
9+
required: true
10+
matrix_path:
11+
type: string
12+
description: "The path of the test matrix definition."
13+
default: ""
14+
matrix_string:
15+
type: string
16+
description: "The test matrix definition."
17+
default: ""
18+
19+
# We will cancel previously triggered workflow runs
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
generate-matrix:
26+
name: Prepare matrices
27+
runs-on: ubuntu-latest
28+
outputs:
29+
linux-matrix: ${{ steps.load-matrix.outputs.linux-matrix }}
30+
windows-matrix: ${{ steps.load-matrix.outputs.windows-matrix }}
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
with:
35+
persist-credentials: false
36+
- name: Mark the workspace as safe
37+
# https://github.com/actions/checkout/issues/766
38+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
39+
- id: file_check
40+
run: |
41+
if [ ! -z '${{ inputs.matrix_string }}' ]; then
42+
echo "matrix_string_populated=true" >> $GITHUB_ENV
43+
else
44+
echo "matrix_string_populated=false" >> $GITHUB_ENV
45+
fi
46+
- id: cat-matrix
47+
if: ${{ env.matrix_string_populated == 'false' }}
48+
run: |
49+
jq -c '{linux: .linux}' ${{ inputs.matrix_path }} >| __linux_coverage_matrix.json
50+
jq -c '{windows: .windows}' ${{ inputs.matrix_path }} >| __windows_coverage_matrix.json
51+
- id: write-matrix
52+
if: ${{ env.matrix_string_populated == 'true' }}
53+
run: |
54+
echo '${{ inputs.matrix_string }}' | jq -c '{linux: .linux}' >| __linux_coverage_matrix.json
55+
echo '${{ inputs.matrix_string }}' | jq -c '{windows: .windows}' >| __windows_coverage_matrix.json
56+
- id: load-matrix
57+
run: |
58+
{
59+
echo 'linux-matrix<<EOF'
60+
echo "$(cat __linux_coverage_matrix.json)"
61+
echo EOF
62+
} >> "$GITHUB_OUTPUT"
63+
64+
{
65+
echo 'windows-matrix<<EOF'
66+
echo "$(cat __windows_coverage_matrix.json)"
67+
echo EOF
68+
} >> "$GITHUB_OUTPUT"
69+
70+
linux:
71+
name: Linux (${{ matrix.linux.name }})
72+
needs: generate-matrix
73+
runs-on: ${{ matrix.linux.runner }}
74+
strategy:
75+
fail-fast: false
76+
matrix: ${{ fromJson(needs.generate-matrix.outputs.linux-matrix) }}
77+
container:
78+
image: ${{ matrix.linux.image }}
79+
steps:
80+
- name: Checkout repository
81+
uses: actions/checkout@v4
82+
with:
83+
persist-credentials: false
84+
- name: Mark the workspace as safe
85+
# https://github.com/actions/checkout/issues/766
86+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
87+
- name: Pre-build
88+
if: ${{ matrix.linux.setup_command }}
89+
run: |
90+
${{ matrix.linux.setup_command }}
91+
- name: Run matrix job
92+
run: |
93+
${{ matrix.linux.command }} ${{ matrix.linux.command_arguments }}
94+
95+
windows:
96+
name: Windows (${{ matrix.windows.name }})
97+
needs: generate-matrix
98+
runs-on: ${{ matrix.windows.runner }}
99+
strategy:
100+
fail-fast: false
101+
matrix: ${{ fromJson(needs.generate-matrix.outputs.windows-matrix) }}
102+
steps:
103+
- name: Pull Docker image
104+
run: docker pull ${{ matrix.windows.image }}
105+
- name: Checkout repository
106+
uses: actions/checkout@v4
107+
with:
108+
persist-credentials: false
109+
submodules: true
110+
- name: Run matrix job
111+
run: |
112+
if (-not [string]::IsNullOrEmpty("${{ matrix.windows.setup_command }}")) {
113+
$setup_command_expression = "${{ matrix.windows.setup_command }};"
114+
} else {
115+
$setup_command_expression = ""
116+
}
117+
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 }}"""

.github/workflows/unit_tests.yml

+36-20
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,43 @@ on:
7070
default: ""
7171

7272
jobs:
73+
construct-matrix:
74+
name: Construct unit test matrix
75+
runs-on: ubuntu-latest
76+
outputs:
77+
unit-test-matrix: '${{ steps.generate-matrix.outputs.unit-test-matrix }}'
78+
steps:
79+
- name: Checkout repository
80+
uses: actions/checkout@v4
81+
with:
82+
persist-credentials: false
83+
- id: generate-matrix
84+
run: echo "unit-test-matrix=$(./scripts/generate_matrix.sh)" >> "$GITHUB_OUTPUT"
85+
env:
86+
MATRIX_LINUX_COMMAND: "swift test"
87+
MATRIX_LINUX_5_9_ENABLED: ${{ inputs.linux_5_9_enabled }}
88+
MATRIX_LINUX_5_9_COMMAND_ARGUMENTS: ${{ inputs.linux_5_9_arguments_override }}
89+
MATRIX_LINUX_5_10_ENABLED: ${{ inputs.linux_5_10_enabled }}
90+
MATRIX_LINUX_5_10_COMMAND_ARGUMENTS: ${{ inputs.linux_5_10_arguments_override }}
91+
MATRIX_LINUX_6_0_ENABLED: ${{ inputs.linux_6_0_enabled }}
92+
MATRIX_LINUX_6_0_COMMAND_ARGUMENTS: ${{ inputs.linux_6_0_arguments_override }}
93+
MATRIX_LINUX_NIGHTLY_6_0_ENABLED: ${{ inputs.linux_nightly_6_0_enabled }}
94+
MATRIX_LINUX_NIGHTLY_6_0_COMMAND_ARGUMENTS: ${{ inputs.linux_nightly_6_0_arguments_override }}
95+
MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: ${{ inputs.linux_nightly_main_enabled }}
96+
MATRIX_LINUX_NIGHTLY_MAIN_COMMAND_ARGUMENTS: ${{ inputs.linux_nightly_main_arguments_override }}
97+
MATRIX_WINDOWS_COMMAND: "swift test"
98+
MATRIX_WINDOWS_6_0_ENABLED: ${{ inputs.windows_6_0_enabled }}
99+
MATRIX_WINDOWS_6_0_COMMAND_ARGUMENTS: ${{ inputs.windows_6_0_arguments_override }}
100+
MATRIX_WINDOWS_NIGHTLY_6_0_ENABLED: ${{ inputs.windows_nightly_6_0_enabled }}
101+
MATRIX_WINDOWS_NIGHTLY_6_0_COMMAND_ARGUMENTS: ${{ inputs.windows_nightly_6_0_arguments_override }}
102+
MATRIX_WINDOWS_NIGHTLY_MAIN_ENABLED: ${{ inputs.windows_nightly_main_enabled }}
103+
MATRIX_WINDOWS_NIGHTLY_MAIN_COMMAND_ARGUMENTS: ${{ inputs.windows_nightly_main_arguments_override }}
104+
73105
unit-tests:
74106
name: Unit tests
75-
# Workaround https://github.com/nektos/act/issues/1875
76-
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
107+
needs: construct-matrix
108+
# TODO: use global reference
109+
uses: ./.github/workflows/swift_test_matrix.yml
77110
with:
78111
name: "Unit tests"
79-
matrix_linux_command: "swift test"
80-
matrix_linux_5_9_enabled: ${{ inputs.linux_5_9_enabled }}
81-
matrix_linux_5_9_command_override: "swift test ${{ inputs.linux_5_9_arguments_override }}"
82-
matrix_linux_5_10_enabled: ${{ inputs.linux_5_10_enabled }}
83-
matrix_linux_5_10_command_override: "swift test ${{ inputs.linux_5_10_arguments_override }}"
84-
matrix_linux_6_0_enabled: ${{ inputs.linux_6_0_enabled }}
85-
matrix_linux_6_0_command_override: "swift test ${{ inputs.linux_6_0_arguments_override }}"
86-
matrix_linux_nightly_6_0_enabled: ${{ inputs.linux_nightly_6_0_enabled }}
87-
matrix_linux_nightly_6_0_command_override: "swift test ${{ inputs.linux_nightly_6_0_arguments_override }}"
88-
matrix_linux_nightly_main_enabled: ${{ inputs.linux_nightly_main_enabled }}
89-
matrix_linux_nightly_main_command_override: "swift test ${{ inputs.linux_nightly_main_arguments_override }}"
90-
matrix_windows_command: "swift test"
91-
matrix_windows_6_0_enabled: ${{ inputs.windows_6_0_enabled }}
92-
matrix_windows_6_0_command_override: "swift test ${{ inputs.windows_6_0_arguments_override }}"
93-
matrix_windows_nightly_6_0_enabled: ${{ inputs.windows_nightly_6_0_enabled }}
94-
matrix_windows_nightly_6_0_command_override: "swift test ${{ inputs.windows_nightly_6_0_arguments_override }}"
95-
matrix_windows_nightly_main_enabled: ${{ inputs.windows_nightly_main_enabled }}
96-
matrix_windows_nightly_main_command_override: "swift test ${{ inputs.windows_nightly_main_arguments_override }}"
112+
matrix_string: '${{ needs.construct-matrix.outputs.unit-test-matrix }}'

0 commit comments

Comments
 (0)