Move logic to package:icu4x #722
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: package:intl4x | |
permissions: | |
pull-requests: read # Changed to read, as we are only reading labels | |
contents: read # Added for checkout action | |
on: | |
pull_request: | |
branches: [main] | |
types: [opened, synchronize, reopened, labeled, unlabeled] | |
paths: | |
- ".github/workflows/intl4x.yml" | |
- "pkgs/intl4x/**" | |
- "submodules/**" | |
push: | |
branches: [main] | |
paths: | |
- ".github/workflows/intl4x.yml" | |
- "pkgs/intl4x/**" | |
- "submodules/**" | |
schedule: | |
- cron: "0 0 * * 0" # weekly | |
jobs: | |
# This job will determine if the 'skip-fetch' tag is present | |
check_skip_fetch: | |
runs-on: ubuntu-latest | |
outputs: | |
skip_fetch: ${{ steps.get-labels.outputs.skip_fetch }} | |
permissions: | |
pull-requests: read | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Get PR Labels | |
id: get-labels | |
run: | | |
labels="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')" | |
echo "Found labels: $labels" | |
if echo "$labels" | grep -q "skip-fetch"; then | |
echo "skip_fetch=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "skip_fetch=false" >> "$GITHUB_OUTPUT" | |
fi | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
OWNER: ${{ github.repository_owner }} | |
REPO_NAME: ${{ github.event.repository.name }} | |
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} | |
build_checkout: | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
working-directory: pkgs/intl4x | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | |
with: | |
submodules: true | |
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c | |
with: | |
sdk: main | |
- name: Install Rust toolchains | |
run: | | |
rustup toolchain install stable | |
rustup toolchain install nightly | |
- name: Show the selected Rust toolchain | |
run: rustup show | |
- name: Set up toolchain for Linux | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu | |
- name: Set up toolchain for Mac | |
if: matrix.os == 'macos-latest' | |
run: | | |
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin | |
- name: Set up toolchain for Windows | |
if: matrix.os == 'windows-latest' | |
run: | | |
rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc | |
- run: dart pub get | |
- run: dart tool/write_option_file.dart pubspec.yaml checkout $(realpath ${{ github.workspace }}/submodules/icu4x) | |
if: matrix.os == 'ubuntu-latest' | |
- run: dart tool/write_option_file.dart pubspec.yaml checkout $(realpath ${{ github.workspace }}/submodules/icu4x) | |
if: matrix.os == 'macos-latest' | |
- run: dart tool/write_option_file.dart pubspec.yaml checkout (Get-Item ${{ github.workspace }}\submodules\icu4x).FullName -replace '/', '\' | |
if: matrix.os == 'windows-latest' | |
- run: dart analyze --fatal-infos | |
- run: dart format --output=none --set-exit-if-changed . | |
- run: dart test | |
- run: dart test -p chrome | |
- run: dart pub get | |
working-directory: pkgs/intl4x/example_native | |
- run: dart tool/write_option_file.dart example_native/pubspec.yaml checkout $(realpath ${{ github.workspace }}/submodules/icu4x) | |
if: matrix.os == 'ubuntu-latest' | |
- run: dart tool/write_option_file.dart example_native/pubspec.yaml checkout $(realpath ${{ github.workspace }}/submodules/icu4x) | |
if: matrix.os == 'macos-latest' | |
- run: dart tool/write_option_file.dart example_native/pubspec.yaml checkout (Get-Item ${{ github.workspace }}\submodules\icu4x).FullName -replace '/', '\' | |
if: matrix.os == 'windows-latest' | |
- run: dart --enable-experiment=record-use build cli bin/example_native.dart | |
working-directory: pkgs/intl4x/example_native | |
- run: tree . -a | |
if: matrix.os == 'ubuntu-latest' | |
- name: Run example_native (Linux) | |
working-directory: pkgs/intl4x/example_native | |
if: matrix.os == 'ubuntu-latest' | |
run: ./build/cli/linux_x64/bundle/bin/example_native | |
- name: Print file size and check limit for example_native (Linux) | |
working-directory: pkgs/intl4x/example_native | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
FILE_PATH="build/cli/linux_x64/bundle/lib/libintl4x.so" | |
FILE_SIZE=$(stat -c %s "$FILE_PATH") | |
echo "Linux executable size: $FILE_SIZE bytes" | |
if [ "$FILE_SIZE" -gt 10485760 ]; then | |
echo "Error: Linux executable size ($FILE_SIZE bytes) exceeds 10MB limit (10485760 bytes)." | |
exit 1 | |
fi | |
- name: Run example_native (Mac) | |
working-directory: pkgs/intl4x/example_native | |
if: matrix.os == 'macos-latest' | |
run: ./build/cli/macos_arm64/bundle/bin/example_native | |
- name: Print file size and check limit for example_native (Mac) | |
working-directory: pkgs/intl4x/example_native | |
# skip until https://github.com/dart-lang/i18n/issues/989 issue is resolved | |
if: matrix.os == 'macos-latest' && false | |
run: | | |
FILE_PATH="build/cli/macos_arm64/bundle/lib/libintl4x.dylib" | |
FILE_SIZE=$(stat -f %z "$FILE_PATH") | |
echo "macOS executable size: $FILE_SIZE bytes" | |
if [ "$FILE_SIZE" -gt 10485760 ]; then | |
echo "Error: macOS executable size ($FILE_SIZE bytes) exceeds 10MB limit (10485760 bytes)." | |
exit 1 | |
fi | |
- name: Run example_native (Windows) | |
working-directory: pkgs/intl4x/example_native | |
if: matrix.os == 'windows-latest' | |
run: .\build\cli\windows_x64\bundle\bin\example_native.exe | |
- name: Print file size and check limit for example_native (Windows) | |
working-directory: pkgs/intl4x/example_native | |
if: matrix.os == 'windows-latest' | |
run: | | |
$filePath = ".\build\cli\windows_x64\bundle\lib\intl4x.dll" | |
$fileSize = (Get-Item $filePath).Length | |
Write-Host "Windows executable size: $fileSize bytes" | |
if ($fileSize -gt 10485760) { | |
Write-Host "Error: Windows executable size ($fileSize bytes) exceeds 10MB limit (10485760 bytes)." | |
exit 1 | |
} | |
build_fetch: | |
runs-on: ${{ matrix.os }} | |
needs: [check_skip_fetch] | |
# Only run if not PR, or if PR and skip_fetch is false | |
if: github.event_name != 'pull_request' || needs.check_skip_fetch.outputs.skip_fetch == 'false' | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
defaults: | |
run: | |
working-directory: pkgs/intl4x | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | |
with: | |
submodules: true | |
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c | |
with: | |
sdk: main | |
- run: dart pub get | |
- run: | | |
dart tool/write_option_file.dart pubspec.yaml fetch | |
dart tool/write_option_file.dart example_native/pubspec.yaml fetch | |
- run: dart test | |
- run: dart pub get | |
working-directory: pkgs/intl4x/example_native | |
- run: dart --enable-experiment=record-use build cli bin/example_native.dart | |
working-directory: pkgs/intl4x/example_native | |
- name: Run example_native (Linux) | |
working-directory: pkgs/intl4x/example_native | |
if: matrix.os == 'ubuntu-latest' | |
run: ./build/cli/linux_x64/bundle/bin/example_native | |
- name: Print file size and check limit for example_native (Linux) | |
working-directory: pkgs/intl4x/example_native | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
FILE_PATH="build/cli/linux_x64/bundle/lib/libintl4x.so" | |
FILE_SIZE=$(stat -c %s "$FILE_PATH") | |
echo "Linux executable size: $FILE_SIZE bytes" | |
if [ "$FILE_SIZE" -gt 10485760 ]; then | |
echo "Error: Linux executable size ($FILE_SIZE bytes) exceeds 10MB limit (10485760 bytes)." | |
exit 1 | |
fi | |
- name: Run example_native (Mac) | |
working-directory: pkgs/intl4x/example_native | |
if: matrix.os == 'macos-latest' | |
run: ./build/cli/macos_arm64/bundle/bin/example_native | |
- name: Print file size and check limit for example_native (Mac) | |
working-directory: pkgs/intl4x/example_native | |
# skip until https://github.com/dart-lang/i18n/issues/989 issue is resolved | |
if: matrix.os == 'macos-latest' && false | |
run: | | |
FILE_PATH="build/cli/macos_arm64/bundle/lib/example_native" | |
FILE_SIZE=$(stat -f %z "$FILE_PATH") | |
echo "macOS executable size: $FILE_SIZE bytes" | |
if [ "$FILE_SIZE" -gt 10485760 ]; then | |
echo "Error: macOS executable size ($FILE_SIZE bytes) exceeds 10MB limit (10485760 bytes)." | |
exit 1 | |
fi | |
- name: Run example_native (Windows) | |
working-directory: pkgs/intl4x/example_native | |
if: matrix.os == 'windows-latest' | |
run: .\build\cli\windows_x64\bundle\bin\example_native.exe | |
- name: Print file size and check limit for example_native (Windows) | |
working-directory: pkgs/intl4x/example_native | |
if: matrix.os == 'windows-latest' | |
run: | | |
$filePath = ".\build\cli\windows_x64\bundle\lib\intl4x.dll" | |
$fileSize = (Get-Item $filePath).Length | |
Write-Host "Windows executable size: $fileSize bytes" | |
if ($fileSize -gt 10485760) { | |
Write-Host "Error: Windows executable size ($fileSize bytes) exceeds 10MB limit (10485760 bytes)." | |
exit 1 | |
} | |
build_local: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | |
with: | |
submodules: true | |
- name: Install Rust toolchains | |
run: | | |
rustup toolchain install stable | |
rustup toolchain install nightly | |
- name: Show the selected Rust toolchain | |
run: rustup show | |
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c | |
with: | |
sdk: main | |
- name: Prep build | |
run: | | |
(cd pkgs/intl4x && dart pub get) | |
- name: Build Linux | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu | |
dart pkgs/intl4x/lib/src/hook_helpers/build_libs.g.dart --working_directory submodules/icu4x --file submodules/icu4x/bin/linux_x64 --os linux --architecture x64 --compile_type dynamic --cargo_features collator,datetime,list,decimal,plurals,casemap,experimental,compiled_data | |
- name: Build Mac | |
if: matrix.os == 'macos-latest' | |
run: | | |
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin | |
dart pkgs/intl4x/lib/src/hook_helpers/build_libs.g.dart --working_directory submodules/icu4x --file submodules/icu4x/bin/macos_arm64 --os macos --architecture arm64 --compile_type dynamic --cargo_features collator,datetime,list,decimal,plurals,casemap,experimental,compiled_data | |
- name: Build Windows | |
if: matrix.os == 'windows-latest' | |
run: | | |
rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc | |
dart pkgs/intl4x/lib/src/hook_helpers/build_libs.g.dart --working_directory submodules/icu4x --file submodules/icu4x/bin/windows_x64 --os windows --architecture x64 --compile_type dynamic --cargo_features collator,datetime,list,decimal,plurals,casemap,experimental,compiled_data | |
- name: Run `dart pub get` | |
run: | | |
cd pkgs/intl4x | |
dart pub get | |
- run: dart pkgs/intl4x/tool/write_option_file.dart pkgs/intl4x/pubspec.yaml local $(realpath submodules/icu4x/bin/linux_x64) | |
if: matrix.os == 'ubuntu-latest' | |
- run: dart pkgs/intl4x/tool/write_option_file.dart pkgs/intl4x/pubspec.yaml local $(realpath submodules/icu4x/bin/macos_arm64) | |
if: matrix.os == 'macos-latest' | |
- run: dart pkgs/intl4x/tool/write_option_file.dart pkgs/intl4x/pubspec.yaml local (Get-Item submodules\icu4x\bin\windows_x64).FullName -replace '/', '\' | |
if: matrix.os == 'windows-latest' | |
- run: echo $LOCAL_ICU4X_BINARY | |
- name: Display structure of downloaded files | |
run: ls -R | |
- name: Run `dart test` | |
run: | | |
cd pkgs/intl4x | |
dart test | |
- run: dart pub get | |
working-directory: pkgs/intl4x/example_native | |
- run: dart --enable-experiment=record-use build cli | |
working-directory: pkgs/intl4x/example_native |