-
-
Notifications
You must be signed in to change notification settings - Fork 8
165 lines (155 loc) · 6.68 KB
/
swift.yml
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
name: Swift Build and Test
on:
push:
pull_request:
jobs:
macos-build:
name: Swift ${{ matrix.swift-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
swift-version: ["5.9", "5.10"]
steps:
- uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift-version }}
- uses: actions/checkout@v4
with:
submodules: true
- name: Build
run: swift build -Xswiftc -strict-concurrency=complete -Xcxx -xobjective-c++ -v
- name: Run tests
run: swift test -c release -Xswiftc -strict-concurrency=complete -Xcxx -xobjective-c++ -v
ubuntu-build:
name: Swift ${{ matrix.swift-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
swift-version: ["5.9", "5.10"]
steps:
- uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift-version }}
- uses: actions/checkout@v4
with:
submodules: true
- name: Build
run: swift build -Xswiftc -strict-concurrency=complete -v
- name: Run tests
run: swift test -c release -Xswiftc -strict-concurrency=complete -v
windows-build:
name: Swift ${{ matrix.swift-version.tag }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
swift-version:
[{
branch: "swift-6.0.1-release",
tag: "6.0.1-RELEASE"
}]
steps:
- uses: compnerd/gha-setup-swift@main
with:
branch: ${{ matrix.swift-version.branch }}
tag: ${{ matrix.swift-version.tag }}
- uses: actions/checkout@v4
with:
submodules: true
- name: Clone llama.cpp
run: git clone -b ku-nlp/gpt2-japanese-char https://github.com/ensan-hcl/llama.cpp.git
- name: Build llama.cpp
run: |
cmake -B build -DBUILD_SHARED_LIBS=ON
cmake --build build --config Release
working-directory: ./llama.cpp
- name: Copy built files
run: |
cp ./build/bin/Release/llama.dll ../
cp ./build/Release/llama.lib ../
working-directory: ./llama.cpp
- name: Build
run: swift build -Xswiftc -strict-concurrency=complete -v
- name: Run tests
run: swift test -c release -Xswiftc -strict-concurrency=complete -v
android-build:
# from: finagolfin/swift-android-sdk
name: Swift on android
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
arch: [x86_64, aarch64, armv7]
os: [ubuntu-latest]
swift-version:
[{
version: "6.0.2",
android: "24",
checksum: "d75615eac3e614131133c7cc2076b0b8fb4327d89dce802c25cd53e75e1881f4"
}]
steps:
- name: Setup Swift toolchain
run: |
curl -sL https://download.swift.org/swift-${{ matrix.swift-version.version }}-release/ubuntu2204/swift-${{ matrix.swift-version.version }}-RELEASE/swift-${{ matrix.swift-version.version }}-RELEASE-ubuntu22.04.tar.gz -o swift-toolchain.tar.gz
tar xf swift-toolchain.tar.gz
TOOLCHAIN=${PWD}/swift-${{ matrix.swift-version.version }}-RELEASE-ubuntu22.04/usr
echo "TOOLCHAIN=${TOOLCHAIN}" >> $GITHUB_ENV
${TOOLCHAIN}/bin/swift --version
- name: Setup Swift release Android SDK
run: ${TOOLCHAIN}/bin/swift sdk install https://github.com/finagolfin/swift-android-sdk/releases/download/${{ matrix.swift-version.version }}/swift-${{ matrix.swift-version.version }}-RELEASE-android-${{ matrix.swift-version.android }}-0.1.artifactbundle.tar.gz --checksum ${{ matrix.swift-version.checksum }}
- uses: actions/checkout@v4
with:
path: AzooKeyKanaKanjiConverter
submodules: true
- name: Build
run: |
cd AzooKeyKanaKanjiConverter
ARCH_TARGET="${{ matrix.arch }}-unknown-linux-android${{ matrix.swift-version.android }}"
if ${{ matrix.arch == 'armv7' }}; then
ARCH_TARGET="armv7-unknown-linux-androideabi${{ matrix.swift-version.android }}"
fi
LLAMA_MOCK=1 ${TOOLCHAIN}/bin/swift build --build-tests --swift-sdk $ARCH_TARGET
- name: Get cached Termux app
if: ${{ matrix.arch == 'x86_64' }}
id: cache-termux
uses: actions/cache@v4
with:
path: ~/termux-debug.apk
key: termux-app
- name: Get Termux debug app if not cached
if: ${{ (matrix.arch == 'x86_64') && (steps.cache-termux.outputs.cache-hit != 'true') }}
run: wget -O ~/termux-debug.apk https://github.com/termux/termux-app/releases/download/v0.118.0/termux-app_v0.118.0+github-debug_x86_64.apk
- name: Prepare Android emulator
if: ${{ matrix.arch == 'x86_64' }}
run: |
set -x
# create the test runner script
cat > ~/test-toolchain.sh << EOF
adb install ~/termux-debug.apk
adb push pack /data/local/tmp
EOF
mkdir -p pack/lib/swift/android
TARGET="x86_64-unknown-linux-android${{ matrix.swift-version.android }}"
cp AzooKeyKanaKanjiConverter/.build/$TARGET/debug/AzooKeyKanakanjiConverterPackageTests.xctest pack
echo 'adb shell /data/local/tmp/pack/AzooKeyKanakanjiConverterPackageTests.xctest' >> ~/test-toolchain.sh
cp -r AzooKeyKanaKanjiConverter/.build/$TARGET/debug/AzooKeyKanakanjiConverter_KanaKanjiConverterModuleTests.resources pack
cp -r AzooKeyKanaKanjiConverter/.build/$TARGET/debug/AzooKeyKanakanjiConverter_KanaKanjiConverterModuleWithDefaultDictionary.resources pack
cp ~/.config/swiftpm/swift-sdks/swift-${{ matrix.swift-version.version }}-RELEASE-android-${{ matrix.swift-version.android }}-*.artifactbundle/swift*sdk/android*sysroot/usr/lib/$(echo ${{ matrix.arch }} | sed "s/v7//")-linux-android*/${{ matrix.swift-version.android }}/lib*so pack
rm pack/lib{c,dl,log,m}.so
chmod +x ~/test-toolchain.sh
echo "TEST SCRIPT:"
cat ~/test-toolchain.sh
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run tests
if: ${{ matrix.arch == 'x86_64' }}
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
arch: x86_64
script: ~/test-toolchain.sh