forked from apple/swift-nio
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (100 loc) · 4.52 KB
/
wasm_swift_sdk.yml
File metadata and controls
111 lines (100 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: WebAssembly Swift SDK
permissions:
contents: read
on:
workflow_call:
inputs:
nightly_main_enabled:
type: boolean
description: "Boolean to enable the nightly-main WASM Swift SDK matrix job. Defaults to true."
default: true
nightly_next_enabled:
type: boolean
description: "Boolean to enable the nightly-next WASM Swift SDK matrix job. Defaults to true."
default: true
release_6_3_enabled:
type: boolean
description: "Boolean to enable the 6.3 release WASM Swift SDK matrix job. Defaults to true."
default: true
env_vars:
type: string
description: "Environment variables for jobs as JSON (e.g., '{\"DEBUG\":\"1\",\"LOG_LEVEL\":\"info\"}')."
default: "{}"
additional_command_arguments:
type: string
description: "Additional arguments passed to swift build (the Wasm Swift SDK will be specified). Defaults to empty."
default: ""
jobs:
construct-matrix:
name: Construct WebAssembly Swift SDK matrix
runs-on: ubuntu-latest
outputs:
wasm-swift-sdk-matrix: '${{ steps.generate-matrix.outputs.wasm-swift-sdk-matrix }}'
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- id: generate-matrix
run: |
# Validate JSON inputs
if ! echo "$INPUT_ENV_VARS" | jq empty 2>/dev/null; then
echo "Error: env_vars is not valid JSON"
exit 1
fi
env_vars_json="$INPUT_ENV_VARS"
entries=""
make_entry() {
local swift_version="$1"
local install_env="$2"
jq -n \
--arg name "${swift_version} Jammy" \
--arg swift_version "$swift_version" \
--arg install_env "$install_env" \
--arg command_arguments "$INPUT_ADDITIONAL_COMMAND_ARGUMENTS" \
--argjson env "$env_vars_json" \
'{
"name": $name,
"swift_version": $swift_version,
"platform": "Linux",
"runner": "ubuntu-latest",
"image": "ubuntu:jammy",
"setup_command": ("apt update -q && apt install -y -q curl jq tar && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_swift_prerequisites.sh | bash && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_swift_sdk.sh | " + $install_env + " INSTALL_SWIFT_ARCH=x86_64 INSTALL_SWIFT_SDK=wasm-sdk bash && hash -r"),
"command": "curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/swift-build-with-wasm-sdk.sh | bash -s --",
"command_arguments": $command_arguments,
"env": $env
}'
}
if [[ "$INPUT_NIGHTLY_MAIN_ENABLED" == "true" ]]; then
entry=$(make_entry "nightly-main" "INSTALL_SWIFT_BRANCH=main")
entries="${entries:+${entries},}${entry}"
fi
if [[ "$INPUT_NIGHTLY_NEXT_ENABLED" == "true" ]]; then
entry=$(make_entry "$NIGHTLY_NEXT_VERSION" "INSTALL_SWIFT_BRANCH=$NIGHTLY_NEXT_BRANCH")
entries="${entries:+${entries},}${entry}"
fi
if [[ "$INPUT_RELEASE_6_3_ENABLED" == "true" ]]; then
entry=$(make_entry "6.3" "INSTALL_SWIFT_VERSION=6.3")
entries="${entries:+${entries},}${entry}"
fi
if [[ -z "$entries" ]]; then
echo "Error: No WASM Swift SDK matrix jobs enabled"
exit 1
fi
echo "wasm-swift-sdk-matrix=$(echo "{\"config\":[${entries}]}" | jq -c)" >> "$GITHUB_OUTPUT"
env:
INPUT_NIGHTLY_MAIN_ENABLED: ${{ inputs.nightly_main_enabled }}
INPUT_NIGHTLY_NEXT_ENABLED: ${{ inputs.nightly_next_enabled }}
INPUT_RELEASE_6_3_ENABLED: ${{ inputs.release_6_3_enabled }}
INPUT_ENV_VARS: ${{ inputs.env_vars }}
INPUT_ADDITIONAL_COMMAND_ARGUMENTS: ${{ inputs.additional_command_arguments }}
NIGHTLY_NEXT_VERSION: nightly-6.3
NIGHTLY_NEXT_BRANCH: swift-6.3-branch
wasm-swift-sdk:
name: WebAssembly Swift SDK
needs: construct-matrix
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/swift_test_matrix.yml@main
with:
name: "WebAssembly Swift SDK"
matrix_string: '${{ needs.construct-matrix.outputs.wasm-swift-sdk-matrix }}'