forked from apple/swift-nio
-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (63 loc) · 2.83 KB
/
android_swift_sdk.yml
File metadata and controls
69 lines (63 loc) · 2.83 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
name: Android Swift SDK
permissions:
contents: read
on:
workflow_call:
inputs:
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 Android Swift SDK will be specified). Defaults to empty."
default: ""
jobs:
construct-matrix:
name: Construct Android Swift SDK matrix
runs-on: ubuntu-latest
outputs:
android-sdk-matrix: '${{ steps.generate-matrix.outputs.android-sdk-matrix }}'
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- id: generate-matrix
run: |
# Validate and use JSON environment variables directly
env_vars_json="$INPUT_ENV_VARS"
# Validate JSON format
if ! echo "$env_vars_json" | jq empty 2>/dev/null; then
echo "Error: env_vars is not valid JSON"
exit 1
fi
# Generate matrix with parsed environment variables
cat >> "$GITHUB_OUTPUT" << EOM
android-sdk-matrix=$(echo '{
"config":[
{
"name":"main Jammy",
"swift_version":"main",
"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_SWIFT_BRANCH=main INSTALL_SWIFT_ARCH=x86_64 INSTALL_SWIFT_SDK=android-sdk bash && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_android_ndk.sh | bash && hash -r",
"command":"curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/swift-build-with-android-sdk.sh | bash -s --",
"command_arguments":"'"$INPUT_ADDITIONAL_COMMAND_ARGUMENTS"'",
"env":'"$env_vars_json"'
}
]
}' | jq -c)
EOM
env:
INPUT_ENV_VARS: ${{ inputs.env_vars }}
INPUT_ADDITIONAL_COMMAND_ARGUMENTS: ${{ inputs.additional_command_arguments }}
android-swift-sdk:
name: Android 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: "Android Swift SDK"
matrix_string: '${{ needs.construct-matrix.outputs.android-sdk-matrix }}'