Support language script subtags (#384) #1419
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: CI | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - v* | |
| pull_request: | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| check-toolchain-is-stable: | |
| name: Check toolchain is stable | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check toolchain | |
| run: | | |
| channel="$(grep channel -i rust-toolchain.toml | cut -d '"' -f2)" | |
| if [ "$channel" != "stable" ]; then | |
| echo 'Toolchain is not "stable", is "$channel". Check the file rust-toolchain.toml' | |
| exit 1 | |
| fi | |
| qa: | |
| name: QA | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| job: [lint, check-all-features, build-all-features] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| components: clippy,rustfmt | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| pip install --upgrade pip | |
| pip install pre-commit | |
| #- name: Install libgtk | |
| # run: | | |
| # sudo apt-get update | |
| # sudo apt-get install -y libgtk-4-dev | |
| - name: Lint | |
| if: matrix.job == 'lint' | |
| uses: nick-fields/retry@v3 | |
| with: | |
| timeout_minutes: 25 | |
| max_attempts: 3 | |
| retry_wait_seconds: 15 | |
| warning_on_retry: false | |
| command: pre-commit run --all-files --show-diff-on-failure | |
| - name: Check all features | |
| if: matrix.job == 'check-all-features' | |
| run: | | |
| pre-commit run --all-files --verbose \ | |
| --config tests/end2end/.pre-commit-config.yaml \ | |
| cargo-check-all-features | |
| - name: Build all features | |
| if: matrix.job == 'build-all-features' | |
| run: | | |
| pre-commit run --all-files --verbose \ | |
| --config tests/end2end/.pre-commit-config.yaml \ | |
| cargo-build-all-features | |
| lychee: | |
| name: Check URLs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Restore lychee cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: .lycheecache | |
| key: cache-lychee-${{ github.sha }} | |
| restore-keys: cache-lychee- | |
| - name: Run Lychee | |
| uses: lycheeverse/lychee-action@v2 | |
| with: | |
| args: "--cache --max-cache-age 1d ." | |
| cargo-machete: | |
| name: Check for unused dependencies | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Install cargo-machete | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-machete | |
| - name: Run cargo-machete | |
| run: cargo machete --skip-target-dir | |
| build-book: | |
| name: Build book | |
| needs: check-toolchain-is-stable | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Install mdbook and plugins | |
| run: | | |
| cargo install mdbook --version 0.4.52 | |
| cargo install mdbook-admonish --version 1.20.0 | |
| cargo install mdbook-toc --version 0.14.2 | |
| - name: Build book | |
| working-directory: book | |
| run: | | |
| mdbook-admonish install . | |
| mdbook build | |
| unit-tests: | |
| name: Unit tests | |
| needs: check-toolchain-is-stable | |
| runs-on: ${{ matrix.runs-on }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runs-on: ubuntu-latest | |
| toolchain: stable | |
| - runs-on: macos-latest | |
| toolchain: stable | |
| - runs-on: windows-latest | |
| toolchain: stable | |
| - runs-on: ubuntu-latest | |
| toolchain: nightly | |
| - runs-on: macos-latest | |
| toolchain: nightly | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Change toolchain to nightly | |
| if: matrix.toolchain == 'nightly' | |
| uses: ./.github/actions/set-toolchain | |
| with: | |
| channel: nightly | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: ${{ matrix.toolchain }} | |
| target: wasm32-unknown-unknown | |
| - name: Install wasm-pack | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: wasm-pack | |
| - name: Run unit tests | |
| shell: bash | |
| run: | | |
| args="" | |
| if [ "${{ matrix.toolchain }}" == "nightly" ]; then | |
| args="--features=leptos-fluent/nightly,leptos-fluent-macros/nightly,leptos/nightly" | |
| fi | |
| cargo test $args -p leptos-fluent -p leptos-fluent-macros -p leptos-fluent-tests | |
| end2end-csr-tests: | |
| needs: check-toolchain-is-stable | |
| name: CSR end to end tests (${{ matrix.browser }}, ${{ matrix.runs-on }}) | |
| runs-on: ${{ matrix.runs-on }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runs-on: ubuntu-latest | |
| browser: firefox | |
| - runs-on: ubuntu-latest | |
| browser: chrome | |
| - runs-on: macos-latest | |
| browser: chrome | |
| - runs-on: windows-latest | |
| browser: firefox | |
| - runs-on: windows-latest | |
| browser: chrome | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| target: wasm32-unknown-unknown | |
| - name: Install wasm-pack | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: wasm-pack | |
| - name: Install wasm-pack-test-all | |
| run: cargo install --force wasm-pack-test-all | |
| - name: Run end to end tests | |
| uses: nick-fields/retry@v3 | |
| with: | |
| timeout_minutes: 25 | |
| max_attempts: 3 | |
| retry_wait_seconds: 1 | |
| warning_on_retry: false | |
| shell: bash | |
| command: wasm-pack-test-all tests/end2end --${{ matrix.browser }} --headless | |
| end2end-ssr-tests: | |
| name: SSR end to end tests | |
| needs: check-toolchain-is-stable | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - tests: | |
| - "initial_language_from_url_param_axum" | |
| - "initial_language_from_cookie_actix" | |
| - "initial_language_from_cookie_axum" | |
| - "initial_language_from_accept_language_header_axum" | |
| - "initial_language_from_url_param_actix" | |
| - "initial_language_from_accept_language_header_actix" | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Install cargo binstall | |
| uses: cargo-bins/cargo-binstall@main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install cargo-leptos | |
| run: cargo binstall -y --force cargo-leptos@0.2.42 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: wasm32-unknown-unknown | |
| - name: Run SSR end-to-end tests | |
| run: | | |
| EXITCODE=0 | |
| echo "Running batch: ${{ join(matrix.tests, ', ') }}" | |
| for test in ${{ join(matrix.tests, ' ') }}; do | |
| echo "▶ Running test: $test" | |
| TESTS="$test" cargo test -p leptos-fluent-end2end-ssr-tests || EXITCODE=$? | |
| done | |
| exit $EXITCODE | |
| build-examples: | |
| needs: check-toolchain-is-stable | |
| name: Build example | |
| runs-on: ${{ matrix.runs-on }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # TODO: re-add 'ssr-islands-axum' and 'system-gtk' | |
| include: | |
| # === CSR === | |
| - example: csr-minimal | |
| toolchain: stable | |
| runs-on: ubuntu-latest | |
| - example: csr-complete | |
| toolchain: stable | |
| runs-on: ubuntu-latest | |
| - example: csr-complete | |
| toolchain: stable | |
| runs-on: macos-latest | |
| - example: csr-complete | |
| toolchain: stable | |
| runs-on: windows-latest | |
| # === SSR Hydrate (stable baseline) === | |
| - example: ssr-hydrate-actix | |
| toolchain: stable | |
| runs-on: ubuntu-latest | |
| # === Nightly coverage (Ubuntu only) === | |
| - example: ssr-hydrate-actix | |
| toolchain: nightly | |
| runs-on: ubuntu-latest | |
| - example: ssr-hydrate-axum | |
| toolchain: nightly | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set nightly toolchain | |
| if: matrix.toolchain == 'nightly' | |
| uses: ./.github/actions/set-toolchain | |
| with: | |
| channel: nightly | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| target: wasm32-unknown-unknown | |
| - name: Install trunk (CSR only) | |
| if: startsWith(matrix.example, 'csr') | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: trunk | |
| - name: Install cargo binstall (SSR only) | |
| if: startsWith(matrix.example, 'ssr') | |
| uses: cargo-bins/cargo-binstall@main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install cargo-leptos (SSR only) | |
| if: startsWith(matrix.example, 'ssr') | |
| run: cargo binstall -y --force cargo-leptos@0.2.42 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get build features | |
| id: build-features | |
| shell: bash | |
| run: | | |
| FEATURES=$([ "${{ matrix.toolchain }}" == "nightly" ] && echo "--features=leptos-fluent/nightly" || echo "") | |
| echo "features=$FEATURES" >> $GITHUB_OUTPUT | |
| - name: Build with trunk | |
| if: startsWith(matrix.example, 'csr') | |
| uses: nick-fields/retry@v3 | |
| with: | |
| timeout_minutes: 20 | |
| max_attempts: 3 | |
| retry_wait_seconds: 2 | |
| warning_on_retry: false | |
| command: | | |
| cd examples/${{ matrix.example }} | |
| trunk build --release ${{ steps.build-features.outputs.features }} | |
| - name: Build with cargo-leptos | |
| if: startsWith(matrix.example, 'ssr') && !(matrix.toolchain == 'nightly' && startsWith(matrix.runs-on, 'macos')) | |
| run: | | |
| cd examples/${{ matrix.example }} | |
| cargo leptos build --release ${{ steps.build-features.outputs.features }} | |
| - name: Install GTK4 (Ubuntu) | |
| if: endsWith(matrix.example, 'gtk') && startsWith(matrix.runs-on, 'ubuntu') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libgtk-4-dev | |
| - name: Install GTK4 (MacOS) | |
| if: endsWith(matrix.example, 'gtk') && startsWith(matrix.runs-on, 'macos') | |
| run: brew install gtk4 | |
| - name: Build with cargo (system only) | |
| if: startsWith(matrix.example, 'system') | |
| run: | | |
| cd examples/${{ matrix.example }} | |
| cargo build --release ${{ steps.build-features.outputs.features }} | |
| report-type-sizes: | |
| needs: | |
| - unit-tests | |
| - build-book | |
| name: Report type sizes | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set nightly toolchain | |
| uses: ./.github/actions/set-toolchain | |
| with: | |
| channel: nightly | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: nightly | |
| - name: leptos-fluent type sizes | |
| run: | | |
| cd leptos-fluent | |
| cargo +nightly rustc -- -Zprint-type-sizes > ../leptos-fluent-type-sizes.log | |
| cat ../leptos-fluent-type-sizes.log | |
| - name: leptos-fluent-macros type sizes | |
| run: | | |
| cd leptos-fluent-macros | |
| cargo +nightly rustc -- -Zprint-type-sizes > ../leptos-fluent-macros-type-sizes.log | |
| cat ../leptos-fluent-macros-type-sizes.log | |
| - name: Upload type sizes | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: type-sizes | |
| path: | | |
| leptos-fluent-type-sizes.log | |
| leptos-fluent-macros-type-sizes.log | |
| test-release-leptos-fluent-macros: | |
| needs: | |
| - qa | |
| - unit-tests | |
| - end2end-csr-tests | |
| - end2end-ssr-tests | |
| - build-examples | |
| - build-book | |
| if: | | |
| github.event.pull_request.user.login == 'mondeja' || | |
| startsWith(github.ref, 'refs/tags/') || | |
| github.ref == 'refs/heads/master' | |
| name: Test leptos-fluent-macros release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Publish (dry run) | |
| run: | | |
| cargo login ${{ secrets.CRATES_TOKEN }} | |
| cargo publish -v --dry-run --features=json -p leptos-fluent-macros | |
| test-release-leptos-fluent: | |
| needs: | |
| - qa | |
| - unit-tests | |
| - end2end-csr-tests | |
| - end2end-ssr-tests | |
| - build-examples | |
| - build-book | |
| if: | | |
| github.event.pull_request.user.login == 'mondeja' || | |
| startsWith(github.ref, 'refs/tags/') || | |
| github.ref == 'refs/heads/master' | |
| name: Test leptos-fluent release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get project version | |
| id: get-version | |
| uses: mondeja/get-current-crate-version@main | |
| with: | |
| working-directory: leptos-fluent | |
| - name: Update version | |
| uses: mondeja/starts-with-line-replacer@main | |
| with: | |
| file: leptos-fluent/Cargo.toml | |
| starts-with: "leptos-fluent-macros" | |
| replace-by: 'leptos-fluent-macros = "=${{ steps.get-version.outputs.version }}"' | |
| - name: Check version update | |
| working-directory: leptos-fluent | |
| run: | | |
| if ! grep -q '^leptos-fluent-macros = "=${{ steps.get-version.outputs.version }}"$' Cargo.toml; then | |
| echo "The version of leptos-fluent-macros dependency has not been correctly updated in leptos-fluent/Cargo.toml" >&2 | |
| exit 1 | |
| fi | |
| release-leptos-fluent-macros: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| name: Release leptos-fluent-macros | |
| needs: | |
| - test-release-leptos-fluent-macros | |
| - test-release-leptos-fluent | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Publish | |
| run: | | |
| cargo login ${{ secrets.CRATES_TOKEN }} | |
| cargo publish -v -p leptos-fluent-macros | |
| release-leptos-fluent: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| name: Release leptos-fluent | |
| needs: | |
| - release-leptos-fluent-macros | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Get project version | |
| id: get-version | |
| uses: mondeja/get-current-crate-version@main | |
| with: | |
| working-directory: leptos-fluent | |
| - name: Update version | |
| uses: mondeja/starts-with-line-replacer@main | |
| with: | |
| file: leptos-fluent/Cargo.toml | |
| starts-with: "leptos-fluent-macros" | |
| replace-by: 'leptos-fluent-macros = "=${{ steps.get-version.outputs.version }}"' | |
| - name: Publish | |
| run: | | |
| cargo login ${{ secrets.CRATES_TOKEN }} | |
| cargo publish --allow-dirty -v -p leptos-fluent | |
| create-release: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| name: Create release | |
| needs: | |
| - release-leptos-fluent | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get tag metadata | |
| id: tag | |
| run: | | |
| TAG_TITLE=${GITHUB_REF#refs/*/} | |
| echo "title=$TAG_TITLE" >> $GITHUB_OUTPUT | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| name: ${{ steps.tag.outputs.title }} | |
| tag_name: ${{ steps.tag.outputs.title }} | |
| body: | | |
| See [CHANGELOG](https://github.com/mondeja/leptos-fluent/blob/master/CHANGELOG.md) | |
| draft: false | |
| prerelease: false | |
| deploy-book: | |
| if: | | |
| startsWith(github.ref, 'refs/tags/') || | |
| github.ref == 'refs/heads/master' | |
| name: Deploy book | |
| permissions: | |
| contents: write | |
| needs: | |
| - build-book | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Get project version | |
| id: get-version | |
| uses: mondeja/get-current-crate-version@main | |
| with: | |
| working-directory: leptos-fluent | |
| - name: Install mdbook and plugins | |
| run: | | |
| cargo install mdbook --version 0.4.52 | |
| cargo install mdbook-admonish --version 1.20.0 | |
| cargo install mdbook-toc --version 0.14.2 | |
| - name: Install cargo binstall | |
| uses: cargo-bins/cargo-binstall@main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build book | |
| working-directory: book | |
| run: | | |
| mdbook-admonish install . | |
| mdbook build | |
| - name: Deploy book (next) | |
| if: github.ref == 'refs/heads/master' | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./book/dist | |
| destination_dir: next | |
| - name: Deploy book (latest) | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./book/dist | |
| destination_dir: latest | |
| - name: Deploy book (v${{ steps.get-version.outputs.version }}) | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./book/dist | |
| destination_dir: v${{ steps.get-version.outputs.version }} |