Fix error in documentation (#325) #1161
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: | |
| 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 | |
| needs: check-toolchain-is-stable | |
| 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 | |
| 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 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 cargo binstall | |
| uses: cargo-bins/cargo-binstall@main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install mdbook | |
| run: cargo binstall -y --force mdbook mdbook-admonish mdbook-toc | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build book | |
| run: | | |
| cd book | |
| 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-tests: | |
| needs: check-toolchain-is-stable | |
| name: 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 | |
| build-examples: | |
| needs: check-toolchain-is-stable | |
| name: Build example | |
| runs-on: ${{ matrix.runs-on }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| example: | |
| - csr-minimal | |
| - csr-complete | |
| - ssr-hydrate-actix | |
| - ssr-hydrate-axum | |
| # TODO: re-add 'ssr-islands-axum' and 'system-gtk' | |
| toolchain: | |
| - stable | |
| - nightly | |
| runs-on: | |
| - ubuntu-latest | |
| - macos-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 | |
| if: startsWith(matrix.example, 'csr') | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: trunk | |
| - name: Install cargo binstall | |
| if: startsWith(matrix.example, 'ssr') | |
| uses: cargo-bins/cargo-binstall@main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install cargo-leptos | |
| if: startsWith(matrix.example, 'ssr') | |
| run: | | |
| if ! command -v cargo-leptos &> /dev/null; then | |
| cargo binstall -y cargo-leptos | |
| else | |
| echo "cargo-leptos is already installed" | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get build features | |
| id: build-features | |
| run: | | |
| option=$([ "${{ matrix.toolchain }}" == "nightly" ] && echo "--features=leptos-fluent/nightly" || echo "") | |
| echo "features=$option" >> $GITHUB_OUTPUT | |
| - name: Build with trunk | |
| if: startsWith(matrix.example, 'csr') | |
| # Sometimes trunk fails to download wasm-opt and other tools, so we retry | |
| 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') | |
| run: | | |
| cd examples/${{ matrix.example }} | |
| cargo leptos build --release ${{ steps.build-features.outputs.features }} | |
| - name: Install GTK4 on 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 on MacOS | |
| if: endsWith(matrix.example, 'gtk') && startsWith(matrix.runs-on, 'macos') | |
| run: brew install gtk4 | |
| - name: Build with cargo | |
| 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-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-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: Install cargo binstall | |
| uses: cargo-bins/cargo-binstall@main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get project version | |
| id: get-version | |
| uses: mondeja/get-current-crate-version@main | |
| with: | |
| working-directory: leptos-fluent | |
| - name: Install mdbook | |
| run: cargo binstall -y --force mdbook mdbook-admonish mdbook-toc | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build book | |
| run: | | |
| cd book | |
| mdbook-admonish install . | |
| mdbook build | |
| # create versioned copy | |
| cd .. | |
| cp -r book/dist book/v${{ steps.get-version.outputs.version }} | |
| - name: Deploy book | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./book/dist | |
| - name: Deploy book v${{ steps.get-version.outputs.version }} | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./book/v${{ steps.get-version.outputs.version }} | |
| destination_dir: v${{ steps.get-version.outputs.version }} |