Skip to content

Commit ef572bd

Browse files
committed
Fixes
1 parent 5cf3001 commit ef572bd

File tree

9 files changed

+602
-9
lines changed

9 files changed

+602
-9
lines changed

.github/workflows/dart.yml

Lines changed: 344 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,344 @@
1+
name: package:icu4x
2+
permissions:
3+
pull-requests: read # Changed to read, as we are only reading labels
4+
contents: read # Added for checkout action
5+
6+
on:
7+
pull_request:
8+
branches: [main]
9+
types: [opened, synchronize, reopened, labeled, unlabeled]
10+
paths:
11+
- ".github/workflows/dart.yml"
12+
- "ffi/dart/**"
13+
- "ffi/capi/bindings/dart/**"
14+
push:
15+
branches: [main]
16+
paths:
17+
- ".github/workflows/dart.yml"
18+
- "ffi/dart/**"
19+
- "ffi/capi/bindings/dart/**"
20+
schedule:
21+
- cron: "0 0 * * 0" # weekly
22+
23+
jobs:
24+
# This job will determine if the 'skip-fetch' tag is present
25+
check_skip_fetch:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
skip_fetch: ${{ steps.get-labels.outputs.skip_fetch }}
29+
permissions:
30+
pull-requests: read
31+
if: github.event_name == 'pull_request'
32+
steps:
33+
- name: Get PR Labels
34+
id: get-labels
35+
run: |
36+
labels="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')"
37+
echo "Found labels: $labels"
38+
if echo "$labels" | grep -q "skip-fetch"; then
39+
echo "skip_fetch=true" >> "$GITHUB_OUTPUT"
40+
else
41+
echo "skip_fetch=false" >> "$GITHUB_OUTPUT"
42+
fi
43+
shell: bash
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
OWNER: ${{ github.repository_owner }}
47+
REPO_NAME: ${{ github.event.repository.name }}
48+
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
49+
50+
build_checkout:
51+
runs-on: ${{ matrix.os }}
52+
53+
defaults:
54+
run:
55+
working-directory: ffi/dart
56+
strategy:
57+
matrix:
58+
os: [ubuntu-latest, macos-latest, windows-latest]
59+
steps:
60+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
61+
with:
62+
submodules: true
63+
64+
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
65+
with:
66+
sdk: main
67+
68+
- name: Install Rust toolchains
69+
run: |
70+
rustup toolchain install stable
71+
rustup toolchain install nightly
72+
73+
- name: Show the selected Rust toolchain
74+
run: rustup show
75+
76+
- name: Set up toolchain for Linux
77+
if: matrix.os == 'ubuntu-latest'
78+
run: |
79+
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
80+
81+
- name: Set up toolchain for Mac
82+
if: matrix.os == 'macos-latest'
83+
run: |
84+
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin
85+
86+
- name: Set up toolchain for Windows
87+
if: matrix.os == 'windows-latest'
88+
run: |
89+
rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc
90+
91+
- run: dart pub get
92+
93+
- run: dart tool/write_option_file.dart pubspec.yaml checkout $(realpath ${{ github.workspace }})
94+
if: matrix.os == 'ubuntu-latest'
95+
96+
- run: dart tool/write_option_file.dart pubspec.yaml checkout $(realpath ${{ github.workspace }})
97+
if: matrix.os == 'macos-latest'
98+
99+
- run: dart tool/write_option_file.dart pubspec.yaml checkout (Get-Item ${{ github.workspace }}).FullName -replace '/', '\'
100+
if: matrix.os == 'windows-latest'
101+
102+
- run: dart analyze --fatal-infos
103+
104+
- run: dart format --output=none --set-exit-if-changed .
105+
106+
- run: dart test
107+
108+
- run: dart test -p chrome
109+
110+
- run: dart pub get
111+
working-directory: ffi/dart/example
112+
113+
- run: dart tool/write_option_file.dart example/pubspec.yaml checkout $(realpath ${{ github.workspace }})
114+
if: matrix.os == 'ubuntu-latest'
115+
116+
- run: dart tool/write_option_file.dart example/pubspec.yaml checkout $(realpath ${{ github.workspace }})
117+
if: matrix.os == 'macos-latest'
118+
119+
- run: dart tool/write_option_file.dart example/pubspec.yaml checkout (Get-Item ${{ github.workspace }}).FullName -replace '/', '\'
120+
if: matrix.os == 'windows-latest'
121+
122+
- run: dart --enable-experiment=record-use build cli bin/example.dart
123+
working-directory: ffi/dart/example
124+
125+
- run: tree . -a
126+
if: matrix.os == 'ubuntu-latest'
127+
128+
- name: Run example (Linux)
129+
working-directory: ffi/dart/example
130+
if: matrix.os == 'ubuntu-latest'
131+
run: ./build/cli/linux_x64/bundle/bin/example
132+
133+
- name: Print file size and check limit for example (Linux)
134+
working-directory: ffi/dart/example
135+
if: matrix.os == 'ubuntu-latest'
136+
run: |
137+
FILE_PATH="build/cli/linux_x64/bundle/lib/libicu4x.so"
138+
FILE_SIZE=$(stat -c %s "$FILE_PATH")
139+
echo "Linux executable size: $FILE_SIZE bytes"
140+
if [ "$FILE_SIZE" -gt 10485760 ]; then
141+
echo "Error: Linux executable size ($FILE_SIZE bytes) exceeds 10MB limit (10485760 bytes)."
142+
exit 1
143+
fi
144+
145+
- name: Run example (Mac)
146+
working-directory: ffi/dart/example
147+
if: matrix.os == 'macos-latest'
148+
run: ./build/cli/macos_arm64/bundle/bin/example
149+
- name: Print file size and check limit for example (Mac)
150+
working-directory: ffi/dart/example
151+
# skip until https://github.com/dart-lang/i18n/issues/989 issue is resolved
152+
if: matrix.os == 'macos-latest' && false
153+
run: |
154+
FILE_PATH="build/cli/macos_arm64/bundle/lib/libicu4x.dylib"
155+
FILE_SIZE=$(stat -f %z "$FILE_PATH")
156+
echo "macOS executable size: $FILE_SIZE bytes"
157+
if [ "$FILE_SIZE" -gt 10485760 ]; then
158+
echo "Error: macOS executable size ($FILE_SIZE bytes) exceeds 10MB limit (10485760 bytes)."
159+
exit 1
160+
fi
161+
162+
- name: Run example (Windows)
163+
working-directory: ffi/dart/example
164+
if: matrix.os == 'windows-latest'
165+
run: .\build\cli\windows_x64\bundle\bin\example.exe
166+
- name: Print file size and check limit for example (Windows)
167+
working-directory: ffi/dart/example
168+
if: matrix.os == 'windows-latest'
169+
run: |
170+
$filePath = ".\build\cli\windows_x64\bundle\lib\icu4x.dll"
171+
$fileSize = (Get-Item $filePath).Length
172+
Write-Host "Windows executable size: $fileSize bytes"
173+
if ($fileSize -gt 10485760) {
174+
Write-Host "Error: Windows executable size ($fileSize bytes) exceeds 10MB limit (10485760 bytes)."
175+
exit 1
176+
}
177+
178+
build_fetch:
179+
runs-on: ${{ matrix.os }}
180+
needs: [check_skip_fetch]
181+
# Only run if not PR, or if PR and skip_fetch is false
182+
if: github.event_name != 'pull_request' || needs.check_skip_fetch.outputs.skip_fetch == 'false'
183+
184+
strategy:
185+
matrix:
186+
os: [ubuntu-latest, macos-latest, windows-latest]
187+
188+
defaults:
189+
run:
190+
working-directory: ffi/dart
191+
192+
steps:
193+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
194+
with:
195+
submodules: true
196+
197+
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
198+
with:
199+
sdk: main
200+
201+
- run: dart pub get
202+
203+
- run: |
204+
dart tool/write_option_file.dart pubspec.yaml fetch
205+
dart tool/write_option_file.dart example/pubspec.yaml fetch
206+
207+
- run: dart test
208+
209+
- run: dart pub get
210+
working-directory: ffi/dart/example
211+
212+
- run: dart --enable-experiment=record-use build cli bin/example.dart
213+
working-directory: ffi/dart/example
214+
215+
- name: Run example (Linux)
216+
working-directory: ffi/dart/example
217+
if: matrix.os == 'ubuntu-latest'
218+
run: ./build/cli/linux_x64/bundle/bin/example
219+
220+
- name: Print file size and check limit for example (Linux)
221+
working-directory: ffi/dart/example
222+
if: matrix.os == 'ubuntu-latest'
223+
run: |
224+
FILE_PATH="build/cli/linux_x64/bundle/lib/libicu4x.so"
225+
FILE_SIZE=$(stat -c %s "$FILE_PATH")
226+
echo "Linux executable size: $FILE_SIZE bytes"
227+
if [ "$FILE_SIZE" -gt 10485760 ]; then
228+
echo "Error: Linux executable size ($FILE_SIZE bytes) exceeds 10MB limit (10485760 bytes)."
229+
exit 1
230+
fi
231+
232+
- name: Run example (Mac)
233+
working-directory: ffi/dart/example
234+
if: matrix.os == 'macos-latest'
235+
run: ./build/cli/macos_arm64/bundle/bin/example
236+
237+
- name: Print file size and check limit for example (Mac)
238+
working-directory: ffi/dart/example
239+
# skip until https://github.com/dart-lang/i18n/issues/989 issue is resolved
240+
if: matrix.os == 'macos-latest' && false
241+
run: |
242+
FILE_PATH="build/cli/macos_arm64/bundle/lib/example"
243+
FILE_SIZE=$(stat -f %z "$FILE_PATH")
244+
echo "macOS executable size: $FILE_SIZE bytes"
245+
if [ "$FILE_SIZE" -gt 10485760 ]; then
246+
echo "Error: macOS executable size ($FILE_SIZE bytes) exceeds 10MB limit (10485760 bytes)."
247+
exit 1
248+
fi
249+
250+
- name: Run example (Windows)
251+
working-directory: ffi/dart/example
252+
if: matrix.os == 'windows-latest'
253+
run: .\build\cli\windows_x64\bundle\bin\example.exe
254+
255+
- name: Print file size and check limit for example (Windows)
256+
working-directory: ffi/dart/example
257+
if: matrix.os == 'windows-latest'
258+
run: |
259+
$filePath = ".\build\cli\windows_x64\bundle\lib\icu4x.dll"
260+
$fileSize = (Get-Item $filePath).Length
261+
Write-Host "Windows executable size: $fileSize bytes"
262+
if ($fileSize -gt 10485760) {
263+
Write-Host "Error: Windows executable size ($fileSize bytes) exceeds 10MB limit (10485760 bytes)."
264+
exit 1
265+
}
266+
267+
build_local:
268+
strategy:
269+
fail-fast: false
270+
matrix:
271+
os: [ubuntu-latest, macos-latest, windows-latest]
272+
runs-on: ${{ matrix.os }}
273+
274+
steps:
275+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
276+
with:
277+
submodules: true
278+
279+
- name: Install Rust toolchains
280+
run: |
281+
rustup toolchain install stable
282+
rustup toolchain install nightly
283+
284+
- name: Show the selected Rust toolchain
285+
run: rustup show
286+
287+
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
288+
with:
289+
sdk: main
290+
291+
- name: Prep build
292+
run: |
293+
(cd ffi/dart && dart pub get)
294+
295+
- name: Build Linux
296+
if: matrix.os == 'ubuntu-latest'
297+
run: |
298+
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
299+
300+
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/linux_x64 --os linux --architecture x64 --compile_type dynamic --cargo_features collator,datetime,list,decimal,plurals,casemap,experimental,compiled_data
301+
302+
- name: Build Mac
303+
if: matrix.os == 'macos-latest'
304+
run: |
305+
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin
306+
307+
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/macos_arm64 --os macos --architecture arm64 --compile_type dynamic --cargo_features collator,datetime,list,decimal,plurals,casemap,experimental,compiled_data
308+
309+
- name: Build Windows
310+
if: matrix.os == 'windows-latest'
311+
run: |
312+
rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc
313+
314+
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/windows_x64 --os windows --architecture x64 --compile_type dynamic --cargo_features collator,datetime,list,decimal,plurals,casemap,experimental,compiled_data
315+
316+
- name: Run `dart pub get`
317+
run: |
318+
cd ffi/dart
319+
dart pub get
320+
321+
- run: dart ffi/dart/tool/write_option_file.dart ffi/dart/pubspec.yaml local $(realpath bin/linux_x64)
322+
if: matrix.os == 'ubuntu-latest'
323+
324+
- run: dart ffi/dart/tool/write_option_file.dart ffi/dart/pubspec.yaml local $(realpath bin/macos_arm64)
325+
if: matrix.os == 'macos-latest'
326+
327+
- run: dart ffi/dart/tool/write_option_file.dart ffi/dart/pubspec.yaml local (Get-Item bin\windows_x64).FullName -replace '/', '\'
328+
if: matrix.os == 'windows-latest'
329+
330+
- run: echo $LOCAL_ICU4X_BINARY
331+
332+
- name: Display structure of downloaded files
333+
run: ls -R
334+
335+
- name: Run `dart test`
336+
run: |
337+
cd ffi/dart
338+
dart test
339+
340+
- run: dart pub get
341+
working-directory: ffi/dart/example
342+
343+
- run: dart --enable-experiment=record-use build cli
344+
working-directory: ffi/dart/example

0 commit comments

Comments
 (0)