Repository navigation
304 lines (297 loc) · 14.9 KB
/
Copy pathlinux.yml
File metadata and controls
304 lines (297 loc) · 14.9 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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: linux
# Linux 版 (linux/、IBus) をビルドして、テスター向けの zip と apt で入れられる .deb、dnf で入れられる .rpm を実行結果 (Artifacts) に置く。
# Actions の画面から手動で実行するか、Linux 版・Mozc のヘルパー・共通部分を変えて push / Pull Request したとき。
# タグ (v*) ならリリースにも添付する。
# Mozc のビルドは初回 30〜40 分かかるので、Bazel の結果をキャッシュして次から速くする。
# pull_request でも流すのは、フォークからの Pull Request では push が起きず、Linux のテストが
# CI で一度も走らないため (build.yml と同じ扱い)。
on:
workflow_dispatch:
pull_request:
paths:
- 'linux/**'
- 'native/mozc/**'
- 'src/Meltype.Core/**'
- 'dictionaries/**'
- 'tools/test-native-boundaries.py'
- '.github/workflows/linux.yml'
push:
branches: ['**']
tags: ['v*']
paths:
- 'linux/**'
- 'native/mozc/**'
- 'src/Meltype.Core/**'
- 'dictionaries/**'
- 'tools/test-native-boundaries.py'
- '.github/workflows/linux.yml'
permissions:
contents: read
concurrency:
group: linux-${{ github.ref }}
cancel-in-progress: true
jobs:
app:
# x64 と arm64 を、それぞれの CPU のランナーでビルドする (Mozc の Bazel のビルドは、ビルドしているマシンの CPU 向けになる)。
# zip の名前の最後 (asset) は、x64 は以前からの linux のまま (web のダウンロードのリンクが linux.zip で探すため)
strategy:
matrix:
include:
- runner: ubuntu-24.04
asset: linux
bazelisk: amd64
bazelisk-sha256: 5a408715e932c0250d28bd84555f12edbf70117de42f9181691c736eacc4a992
- runner: ubuntu-24.04-arm
asset: linux-arm64
bazelisk: arm64
bazelisk-sha256: e20e8b0f4f240091b7a55bf17b9398bd4f40ee70ae0208dff95dd4c445fb4010
runs-on: ${{ matrix.runner }}
timeout-minutes: 90
# タグ時の softprops/action-gh-release 用。permissions は式が使えないため常に write。
permissions:
contents: write
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
with:
persist-credentials: false
# IBus のエンジン (Python) の書き間違いを、時間のかかるビルドの前に見つける
- name: Check Python
run: python3 -c "import ast; ast.parse(open('linux/ibus-engine-meltype', encoding='utf-8').read())"
- uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
with:
dotnet-version: 10.0.x
# Mozc の Linux のビルドと、NativeAOT のリンクに使うもの
- name: Packages
run: |
sudo apt-get update
sudo apt-get install -y clang lld pkg-config zlib1g-dev python3 python3-gi gir1.2-ibus-1.0 \
ibus dbus-x11 xvfb xauth \
libdbus-1-dev libglib2.0-dev libgtk-3-dev libibus-1.0-dev libxcb-xfixes0-dev qt6-base-dev \
cmake fcitx5 fcitx5-modules-dev libfcitx5core-dev libfcitx5utils-dev libfcitx5config-dev
- uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: |
~/bazel-cache
~/mozc/src/third_party_cache
key: mozc-${{ matrix.asset }}-${{ hashFiles('native/mozc/MOZC_COMMIT') }}-${{ hashFiles('native/mozc/*.cc', 'native/mozc/BUILD.fragment') }}
restore-keys: |
mozc-${{ matrix.asset }}-${{ hashFiles('native/mozc/MOZC_COMMIT') }}-
# Bazelisk は版を固定し、ダウンロードしたものが公開されているものと同じか (SHA-256) を確かめる。
- name: Bazelisk
run: |
mkdir -p "$HOME/tools"
curl -fsSL -o "$HOME/tools/bazelisk" https://github.com/bazelbuild/bazelisk/releases/download/v1.29.0/bazelisk-linux-${{ matrix.bazelisk }}
echo "${{ matrix.bazelisk-sha256 }} $HOME/tools/bazelisk" | sha256sum -c -
chmod +x "$HOME/tools/bazelisk"
- name: Build Mozc helper
run: BAZEL="$HOME/tools/bazelisk" native/mozc/build-mozc-helper.sh "$HOME/mozc" "$HOME/bazel-cache"
- name: Build
run: linux/build.sh
# fcitx5 のアドオンを、fcitx5 のテスト用のフロントエンドで動かす。Mozc を外した本体だけで、かなの確定と変換の候補を見る
- name: Test fcitx5 addon
run: |
mkdir -p linux/build/fcitx5-native
cp linux/build/Meltype-linux/libMeltypeNative.so linux/build/fcitx5-native/
cmake -S linux/fcitx5 -B linux/build/fcitx5-test -DBUILD_TESTING=ON
cmake --build linux/build/fcitx5-test
HOME="$RUNNER_TEMP/fcitx5-home" MELTYPE_DIR="$PWD/linux/build/fcitx5-native" ctest --test-dir linux/build/fcitx5-test --output-on-failure
- name: NativeAOT boundary tests
run: python3 tools/test-native-boundaries.py linux/build/Meltype-linux/libMeltypeNative.so
- name: IBus and real Mozc integration tests
run: timeout 120 python3 linux/tests/test_integration.py linux/build/Meltype-linux
- name: Private IBus daemon tests
run: timeout 120 xvfb-run -a dbus-run-session -- python3 linux/tests/test_daemon.py linux/build/Meltype-linux
- name: Package
run: |
# タグ (v1.0.0) なら Meltype-1.0.0-linux.zip (arm64 は Meltype-1.0.0-linux-arm64.zip)、それ以外はテスト版の名前
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then name="Meltype-${GITHUB_REF_NAME#v}-${{ matrix.asset }}.zip"; else name="Meltype-${{ matrix.asset }}-test-$(date +%Y%m%d-%H%M).zip"; fi
(cd linux/build && zip -qr "$name" Meltype-linux)
# apt で入れられる .deb (#863)。中身は install.sh が入れるものと同じ。タグなら版、それ以外は meltype.xml の版 + テスト版の印
- name: Package (.deb)
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then version="${GITHUB_REF_NAME#v}"; else
version="$(sed -n 's|.*<version>\(.*\)</version>.*|\1|p' linux/meltype.xml | head -n 1)~test.$(date +%Y%m%d%H%M)"; fi
linux/build-deb.sh "$version" linux/build/Meltype-linux linux/build
dpkg-deb --info linux/build/meltype_*.deb
dpkg-deb --contents linux/build/meltype_*.deb
ls -la linux/build
# 実際に apt で入れて、決まった場所に置かれるか・外せるかを確かめる
- name: Test .deb
run: |
sudo apt-get install -y ./linux/build/meltype_*.deb
test -x /opt/meltype/ibus-engine-meltype
test -x /opt/meltype/mozc/meltype_mozc_helper
grep -q '<exec>/opt/meltype/ibus-engine-meltype --ibus</exec>' /usr/share/ibus/component/meltype.xml
test -f /usr/share/fcitx5/inputmethod/meltype.conf
test -f "$(dirname "$(find /usr/lib -name libclassicui.so -path '*fcitx5*' | head -n 1)")/meltype.so"
sudo apt-get remove -y meltype
test ! -e /opt/meltype/ibus-engine-meltype
test ! -e /usr/share/ibus/component/meltype.xml
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: meltype-${{ matrix.asset }}
path: |
linux/build/Meltype-*.zip
linux/build/meltype_*.deb
retention-days: 14
- if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@e598afbe1493e6b1bafb1f389cabb956eab91231 # v3.0.3
with:
files: |
linux/build/Meltype-*.zip
linux/build/meltype_*.deb
# dnf で入れられる .rpm (Fedora)。本体と Mozc のヘルパーは app のジョブが Ubuntu でビルドした zip のものを使い、
# fcitx5 のアドオンだけ Fedora の fcitx5 に対してビルドし直す (Ubuntu 24.04 の fcitx5 とは版が違う)
rpm:
needs: app
strategy:
matrix:
include:
- runner: ubuntu-24.04
asset: linux
- runner: ubuntu-24.04-arm
asset: linux-arm64
runs-on: ${{ matrix.runner }}
container: registry.fedoraproject.org/fedora:44
timeout-minutes: 30
permissions:
contents: write
steps:
- name: Packages
run: |
dnf install -y git unzip rpm-build cmake gcc-c++ fcitx5 fcitx5-devel ibus python3 python3-gobject procps-ng
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
with:
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: meltype-${{ matrix.asset }}
path: linux/build/artifact
- name: Build fcitx5 addon
run: |
(cd linux/build && unzip -q artifact/Meltype-*.zip)
cmake -S linux/fcitx5 -B linux/build/fcitx5 -DMELTYPE_DIR=/opt/meltype -DCMAKE_BUILD_TYPE=Release
cmake --build linux/build/fcitx5
cp linux/build/fcitx5/meltype.so linux/build/Meltype-linux/fcitx5/meltype.so
- name: Test fcitx5 addon
run: |
mkdir -p linux/build/fcitx5-native
cp linux/build/Meltype-linux/libMeltypeNative.so linux/build/fcitx5-native/
cmake -S linux/fcitx5 -B linux/build/fcitx5-test -DBUILD_TESTING=ON
cmake --build linux/build/fcitx5-test
HOME="$RUNNER_TEMP/fcitx5-home" MELTYPE_DIR="$PWD/linux/build/fcitx5-native" ctest --test-dir linux/build/fcitx5-test --output-on-failure
# Ubuntu でビルドした本体と Mozc のヘルパーが、Fedora のライブラリで動くか
- name: IBus and real Mozc integration tests
run: timeout 120 python3 linux/tests/test_integration.py linux/build/Meltype-linux
- name: Package (.rpm)
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then version="${GITHUB_REF_NAME#v}"; else
version="$(sed -n 's|.*<version>\(.*\)</version>.*|\1|p' linux/meltype.xml | head -n 1)~test.$(date +%Y%m%d%H%M)"; fi
linux/build-rpm.sh "$version" linux/build/Meltype-linux linux/build
rpm -qpi linux/build/meltype-*.rpm
rpm -qpR linux/build/meltype-*.rpm
rpm -qpl linux/build/meltype-*.rpm
# 実際に dnf で入れて、決まった場所に置かれるか・IBus の一覧に載るか・外せるかを確かめる
- name: Test .rpm
run: |
dnf install -y ./linux/build/meltype-*.rpm
test -x /opt/meltype/ibus-engine-meltype
test -x /opt/meltype/mozc/meltype_mozc_helper
grep -q '<exec>/opt/meltype/ibus-engine-meltype --ibus</exec>' /usr/share/ibus/component/meltype.xml
ibus read-cache --system | grep -q /opt/meltype/ibus-engine-meltype
test -f /usr/share/fcitx5/inputmethod/meltype.conf
test -f /usr/lib64/fcitx5/meltype.so
dnf remove -y meltype
test ! -e /opt/meltype/ibus-engine-meltype
test ! -e /usr/share/ibus/component/meltype.xml
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: meltype-${{ matrix.asset }}-rpm
path: linux/build/meltype-*.rpm
retention-days: 14
- if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@e598afbe1493e6b1bafb1f389cabb956eab91231 # v3.0.3
with:
files: linux/build/meltype-*.rpm
# apt と dnf のリポジトリを同じ鍵で署名して、1 つの GitHub Pages の成果物にする
# (Pages は deploy のたびにサイト全体を置き換えるので、別々のジョブで deploy すると片方が消える)
build-repositories:
if: startsWith(github.ref, 'refs/tags/v')
needs: [app, rpm]
runs-on: ubuntu-24.04
outputs:
ready: ${{ steps.signing.outputs.ready }}
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
with:
persist-credentials: false
- name: Check apt signing key
id: signing
env:
APT_SIGNING_KEY_B64: ${{ secrets.APT_SIGNING_KEY_B64 }}
run: |
if [[ -z "$APT_SIGNING_KEY_B64" ]]; then
echo 'ready=false' >> "$GITHUB_OUTPUT"
echo '::notice::APT_SIGNING_KEY_B64 is not set; skipping apt and dnf repository publication.'
else
echo 'ready=true' >> "$GITHUB_OUTPUT"
fi
- name: Download Linux packages
if: steps.signing.outputs.ready == 'true'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: meltype-linux*
path: ${{ runner.temp }}/meltype-artifacts
merge-multiple: true
- name: Install repository tools
if: steps.signing.outputs.ready == 'true'
run: |
sudo apt-get update
sudo apt-get install -y apt-utils gnupg rpm createrepo-c
- name: Build signed apt repository
if: steps.signing.outputs.ready == 'true'
env:
APT_SIGNING_KEY_B64: ${{ secrets.APT_SIGNING_KEY_B64 }}
APT_SIGNING_KEY_PASSPHRASE: ${{ secrets.APT_SIGNING_KEY_PASSPHRASE }}
run: |
mapfile -d '' -t debs < <(find "$RUNNER_TEMP/meltype-artifacts" -type f -name 'meltype_*.deb' -print0 | sort -z)
if (("${#debs[@]}" != 2)); then
echo "Expected amd64 and arm64 .deb packages; found ${#debs[@]}." >&2
exit 1
fi
bash linux/build-apt-repository.sh "${debs[@]}" "$RUNNER_TEMP/meltype-pages"
- name: Build signed dnf repository
if: steps.signing.outputs.ready == 'true'
env:
APT_SIGNING_KEY_B64: ${{ secrets.APT_SIGNING_KEY_B64 }}
APT_SIGNING_KEY_PASSPHRASE: ${{ secrets.APT_SIGNING_KEY_PASSPHRASE }}
run: |
mapfile -d '' -t rpms < <(find "$RUNNER_TEMP/meltype-artifacts" -type f -name 'meltype-*.rpm' -print0 | sort -z)
if (("${#rpms[@]}" != 2)); then
echo "Expected x86_64 and aarch64 .rpm packages; found ${#rpms[@]}." >&2
exit 1
fi
bash linux/build-rpm-repository.sh "${rpms[@]}" "$RUNNER_TEMP/meltype-pages"
- name: Upload apt and dnf repositories for GitHub Pages
if: steps.signing.outputs.ready == 'true'
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: ${{ runner.temp }}/meltype-pages
publish-repositories:
if: startsWith(github.ref, 'refs/tags/v') && needs.build-repositories.outputs.ready == 'true'
needs: build-repositories
runs-on: ubuntu-24.04
concurrency:
group: meltype-pages
cancel-in-progress: false
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy apt and dnf repositories to GitHub Pages
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1