Skip to content

Prepare for publishing #6739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
348 changes: 348 additions & 0 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,348 @@
# This file is part of ICU4X. For terms of use, please see the file
# called LICENSE at the top level of the ICU4X source tree
# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

name: package:icu4x
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/dart.yml"
- "ffi/dart/**"
- "ffi/capi/bindings/dart/**"
push:
branches: [main]
paths:
- ".github/workflows/dart.yml"
- "ffi/dart/**"
- "ffi/capi/bindings/dart/**"
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: ffi/dart
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 }})
if: matrix.os == 'ubuntu-latest'

- run: dart tool/write_option_file.dart pubspec.yaml checkout $(realpath ${{ github.workspace }})
if: matrix.os == 'macos-latest'

- run: dart tool/write_option_file.dart pubspec.yaml checkout (Get-Item ${{ github.workspace }}).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 pub get
working-directory: examples/dart

- run: dart tool/write_option_file.dart ../../examples/dart/pubspec.yaml checkout $(realpath ${{ github.workspace }})
if: matrix.os == 'ubuntu-latest'

- run: dart tool/write_option_file.dart ../../examples/dart/pubspec.yaml checkout $(realpath ${{ github.workspace }})
if: matrix.os == 'macos-latest'

- run: dart tool/write_option_file.dart ../../examples/dart/pubspec.yaml checkout (Get-Item ${{ github.workspace }}).FullName -replace '/', '\'
if: matrix.os == 'windows-latest'

- run: dart --enable-experiment=record-use build cli bin/example.dart
working-directory: examples/dart

- run: tree . -a
if: matrix.os == 'ubuntu-latest'

- name: Run example (Linux)
working-directory: examples/dart
if: matrix.os == 'ubuntu-latest'
run: ./build/cli/linux_x64/bundle/bin/example

- name: Print file size and check limit for example (Linux)
working-directory: examples/dart
if: matrix.os == 'ubuntu-latest'
run: |
FILE_PATH="build/cli/linux_x64/bundle/lib/libicu4x.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 (Mac)
working-directory: examples/dart
if: matrix.os == 'macos-latest'
run: ./build/cli/macos_arm64/bundle/bin/example
- name: Print file size and check limit for example (Mac)
working-directory: examples/dart
# 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/libicu4x.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 (Windows)
working-directory: examples/dart
if: matrix.os == 'windows-latest'
run: .\build\cli\windows_x64\bundle\bin\example.exe
- name: Print file size and check limit for example (Windows)
working-directory: examples/dart
if: matrix.os == 'windows-latest'
run: |
$filePath = ".\build\cli\windows_x64\bundle\lib\icu4x.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
# TODO: Uncomment this after releasing artifacts.
# if: github.event_name != 'pull_request' || needs.check_skip_fetch.outputs.skip_fetch == 'false'
if: false

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

defaults:
run:
working-directory: ffi/dart

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 ../../examples/dart/pubspec.yaml fetch

- run: dart test

- run: dart pub get
working-directory: examples/dart

- run: dart --enable-experiment=record-use build cli bin/example.dart
working-directory: examples/dart

- name: Run example (Linux)
working-directory: examples/dart
if: matrix.os == 'ubuntu-latest'
run: ./build/cli/linux_x64/bundle/bin/example

- name: Print file size and check limit for example (Linux)
working-directory: examples/dart
if: matrix.os == 'ubuntu-latest'
run: |
FILE_PATH="build/cli/linux_x64/bundle/lib/libicu4x.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 (Mac)
working-directory: examples/dart
if: matrix.os == 'macos-latest'
run: ./build/cli/macos_arm64/bundle/bin/example

- name: Print file size and check limit for example (Mac)
working-directory: examples/dart
# 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"
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 (Windows)
working-directory: examples/dart
if: matrix.os == 'windows-latest'
run: .\build\cli\windows_x64\bundle\bin\example.exe

- name: Print file size and check limit for example (Windows)
working-directory: examples/dart
if: matrix.os == 'windows-latest'
run: |
$filePath = ".\build\cli\windows_x64\bundle\lib\icu4x.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 ffi/dart && 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 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,default,compiled_data

- name: Build Mac
if: matrix.os == 'macos-latest'
run: |
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin

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,default,compiled_data

- name: Build Windows
if: matrix.os == 'windows-latest'
run: |
rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc

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,default,compiled_data

- name: Run `dart pub get`
run: |
cd ffi/dart
dart pub get

- run: dart ffi/dart/tool/write_option_file.dart ffi/dart/pubspec.yaml local $(realpath bin/linux_x64)
if: matrix.os == 'ubuntu-latest'

- run: dart ffi/dart/tool/write_option_file.dart ffi/dart/pubspec.yaml local $(realpath bin/macos_arm64)
if: matrix.os == 'macos-latest'

- run: dart ffi/dart/tool/write_option_file.dart ffi/dart/pubspec.yaml local (Get-Item 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 ffi/dart
dart test

- run: dart pub get
working-directory: examples/dart

- run: dart --enable-experiment=record-use build cli
working-directory: examples/dart
Loading
Loading