test: fix freebsd #14
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: L10n (Localization) | |
| # spell-checker: disable | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - '*' | |
| env: | |
| # * style job configuration | |
| STYLE_FAIL_ON_FAULT: true ## (bool) fail the build if a style job contains a fault (error or warning); may be overridden on a per-job basis | |
| permissions: | |
| contents: read # to fetch code (actions/checkout) | |
| # End the current execution if there is a new changeset in the PR. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| jobs: | |
| l10n_build_test: | |
| name: L10n/Build and Test | |
| runs-on: ${{ matrix.job.os }} | |
| env: | |
| SCCACHE_GHA_ENABLED: "true" | |
| RUSTC_WRAPPER: "sccache" | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| job: | |
| - { os: ubuntu-latest , features: "feat_os_unix" } | |
| - { os: macos-latest , features: "feat_os_macos" } | |
| - { os: windows-latest , features: "feat_os_windows" } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: taiki-e/install-action@nextest | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Run sccache-cache | |
| uses: mozilla-actions/sccache-action@v0.0.9 | |
| - name: Install/setup prerequisites | |
| shell: bash | |
| run: | | |
| ## Install/setup prerequisites | |
| case '${{ matrix.job.os }}' in | |
| ubuntu-*) | |
| # selinux headers needed for testing | |
| sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev | |
| ;; | |
| macos-*) | |
| # needed for testing | |
| brew install coreutils | |
| ;; | |
| esac | |
| - name: Build with l10n features | |
| shell: bash | |
| run: | | |
| ## Build with l10n features | |
| cargo build --features ${{ matrix.job.features }} | |
| - name: Test l10n functionality | |
| shell: bash | |
| run: | | |
| ## Test l10n functionality | |
| cargo test -p uucore locale | |
| cargo test | |
| env: | |
| RUST_BACKTRACE: "1" | |
| l10n_disable_test: | |
| name: L10n/Disabled Build Test | |
| runs-on: ${{ matrix.job.os }} | |
| env: | |
| SCCACHE_GHA_ENABLED: "true" | |
| RUSTC_WRAPPER: "sccache" | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| job: | |
| - { os: ubuntu-latest , features: "feat_os_unix,disable_i18n" } | |
| - { os: macos-latest , features: "feat_os_macos,disable_i18n" } | |
| - { os: windows-latest , features: "feat_os_windows,disable_i18n" } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: taiki-e/install-action@nextest | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Run sccache-cache | |
| uses: mozilla-actions/sccache-action@v0.0.9 | |
| - name: Install/setup prerequisites | |
| shell: bash | |
| run: | | |
| ## Install/setup prerequisites | |
| case '${{ matrix.job.os }}' in | |
| ubuntu-*) | |
| # selinux headers needed for testing | |
| sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev | |
| ;; | |
| macos-*) | |
| # needed for testing | |
| brew install coreutils | |
| ;; | |
| esac | |
| - name: Build without l10n features | |
| shell: bash | |
| run: | | |
| ## Build without l10n features | |
| cargo build --features ${{ matrix.job.features }} | |
| - name: Test l10n disabled functionality | |
| shell: bash | |
| run: | | |
| ## Test l10n disabled functionality | |
| cargo test --features disable_i18n -p uucore locale | |
| cargo test --features disable_i18n | |
| env: | |
| RUST_BACKTRACE: "1" | |
| l10n_fluent_syntax: | |
| name: L10n/Fluent Syntax Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install Mozilla Fluent Linter | |
| shell: bash | |
| run: | | |
| ## Install Mozilla Fluent Linter | |
| pip install moz-fluent-linter | |
| - name: Find and validate Fluent files | |
| shell: bash | |
| run: | | |
| ## Find and validate Fluent files with Mozilla Fluent Linter | |
| # Check if any .ftl files exist | |
| fluent_files=$(find . -name "*.ftl" -type f 2>/dev/null || true) | |
| if [ -z "$fluent_files" ]; then | |
| echo "::notice::No Fluent (.ftl) files found in the repository" | |
| exit 0 | |
| fi | |
| echo "Found Fluent files:" | |
| echo "$fluent_files" | |
| # Use Mozilla Fluent Linter for comprehensive validation | |
| echo "Running Mozilla Fluent Linter..." | |
| has_errors=false | |
| while IFS= read -r file; do | |
| echo "Checking $file with Mozilla Fluent Linter..." | |
| # Run fluent-linter on each file | |
| if ! moz-fluent-lint "$file"; then | |
| echo "::error file=$file::Fluent syntax errors found in $file" | |
| has_errors=true | |
| else | |
| echo "✓ Fluent syntax check passed for $file" | |
| fi | |
| done <<< "$fluent_files" | |
| if [ "$has_errors" = true ]; then | |
| echo "::error::Fluent linting failed - please fix syntax errors" | |
| exit 1 | |
| fi | |
| echo "::notice::All Fluent files passed Mozilla Fluent Linter validation" | |
| l10n_feature_combinations: | |
| name: L10n/Feature Combinations | |
| runs-on: ubuntu-latest | |
| env: | |
| SCCACHE_GHA_ENABLED: "true" | |
| RUSTC_WRAPPER: "sccache" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Run sccache-cache | |
| uses: mozilla-actions/sccache-action@v0.0.9 | |
| - name: Install/setup prerequisites | |
| shell: bash | |
| run: | | |
| sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev | |
| - name: Test feature combinations | |
| shell: bash | |
| run: | | |
| ## Test different l10n feature combinations | |
| echo "Testing with i18n enabled by default..." | |
| cargo check -p uucore | |
| echo "Testing with disable_i18n feature..." | |
| cargo check --features "disable_i18n" -p uucore | |
| echo "All feature combinations compiled successfully" | |
| env: | |
| RUST_BACKTRACE: "1" | |
| l10n_french_integration: | |
| name: L10n/French Integration Test | |
| runs-on: ubuntu-latest | |
| env: | |
| SCCACHE_GHA_ENABLED: "true" | |
| RUSTC_WRAPPER: "sccache" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Run sccache-cache | |
| uses: mozilla-actions/sccache-action@v0.0.9 | |
| - name: Install/setup prerequisites | |
| shell: bash | |
| run: | | |
| ## Install/setup prerequisites | |
| sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev locales | |
| - name: Generate French locale | |
| shell: bash | |
| run: | | |
| ## Generate French locale for testing | |
| sudo locale-gen --keep-existing fr_FR.UTF-8 | |
| locale -a | grep -i fr || echo "French locale not found, continuing anyway" | |
| - name: Build coreutils with l10n support | |
| shell: bash | |
| run: | | |
| ## Build coreutils with Unix features and l10n support | |
| cargo build --features feat_os_unix --bin coreutils | |
| - name: Test French localization | |
| shell: bash | |
| run: | | |
| ## Test French localization with various commands | |
| export LANG=fr_FR.UTF-8 | |
| export LC_ALL=fr_FR.UTF-8 | |
| echo "Testing touch --help with French locale..." | |
| help_output=$(cargo run --features feat_os_unix --bin coreutils -- touch --help 2>&1 || echo "Command failed") | |
| echo "Help output: $help_output" | |
| # Check for specific French strings from touch fr-FR.ftl | |
| french_strings_found=0 | |
| if echo "$help_output" | grep -q "Mettre à jour les temps d'accès"; then | |
| echo "✓ Found French description: 'Mettre à jour les temps d'accès'" | |
| french_strings_found=$((french_strings_found + 1)) | |
| fi | |
| if echo "$help_output" | grep -q "changer seulement le temps d'accès"; then | |
| echo "✓ Found French help text: 'changer seulement le temps d'accès'" | |
| french_strings_found=$((french_strings_found + 1)) | |
| fi | |
| if echo "$help_output" | grep -q "FICHIER"; then | |
| echo "✓ Found French usage pattern: 'FICHIER'" | |
| french_strings_found=$((french_strings_found + 1)) | |
| fi | |
| echo "Testing ls --help with French locale..." | |
| ls_help=$(cargo run --features feat_os_unix --bin coreutils -- ls --help 2>&1 || echo "Command failed") | |
| echo "ls help output: $ls_help" | |
| # Check for specific French strings from ls fr-FR.ftl | |
| if echo "$ls_help" | grep -q "Lister le contenu des répertoires"; then | |
| echo "✓ Found French ls description: 'Lister le contenu des répertoires'" | |
| french_strings_found=$((french_strings_found + 1)) | |
| fi | |
| if echo "$ls_help" | grep -q "Afficher les informations d'aide"; then | |
| echo "✓ Found French ls help text: 'Afficher les informations d'aide'" | |
| french_strings_found=$((french_strings_found + 1)) | |
| fi | |
| echo "Testing base64 --help with French locale..." | |
| base64_help=$(cargo run --features feat_os_unix --bin coreutils -- base64 --help 2>&1 || echo "Command failed") | |
| echo "base64 help output: $base64_help" | |
| # Check for specific French strings from base64 fr-FR.ftl | |
| if echo "$base64_help" | grep -q "encoder/décoder les données"; then | |
| echo "✓ Found French base64 description: 'encoder/décoder les données'" | |
| french_strings_found=$((french_strings_found + 1)) | |
| fi | |
| echo "Testing with error messages..." | |
| error_output=$(cargo run --features feat_os_unix --bin coreutils -- ls /nonexistent 2>&1 || echo "Expected error occurred") | |
| echo "Error output: $error_output" | |
| # Check for French error messages from ls fr-FR.ftl | |
| if echo "$error_output" | grep -q "impossible d'accéder à"; then | |
| echo "✓ Found French error message: 'impossible d'accéder à'" | |
| french_strings_found=$((french_strings_found + 1)) | |
| fi | |
| if echo "$error_output" | grep -q "Aucun fichier ou répertoire de ce type"; then | |
| echo "✓ Found French error text: 'Aucun fichier ou répertoire de ce type'" | |
| french_strings_found=$((french_strings_found + 1)) | |
| fi | |
| # Test that the binary works and doesn't crash with French locale | |
| version_output=$(cargo run --features feat_os_unix --bin coreutils -- --version 2>&1 || echo "Version command failed") | |
| echo "Version output: $version_output" | |
| # Final validation - ensure we found at least some French strings | |
| echo "French strings found: $french_strings_found" | |
| if [ "$french_strings_found" -gt 0 ]; then | |
| echo "✓ SUCCESS: French locale integration test passed - found $french_strings_found French strings" | |
| else | |
| echo "⚠ WARNING: No French strings were detected, but commands executed successfully" | |
| exit 1 | |
| fi | |
| env: | |
| RUST_BACKTRACE: "1" |