|
| 1 | +name: L10n (Localization) |
| 2 | + |
| 3 | +# spell-checker: disable |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - '*' |
| 10 | + |
| 11 | +env: |
| 12 | + # * style job configuration |
| 13 | + 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 |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read # to fetch code (actions/checkout) |
| 17 | + |
| 18 | +# End the current execution if there is a new changeset in the PR. |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 21 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} |
| 22 | + |
| 23 | +jobs: |
| 24 | + |
| 25 | + l10n_build_test: |
| 26 | + name: L10n/Build and Test |
| 27 | + runs-on: ${{ matrix.job.os }} |
| 28 | + env: |
| 29 | + SCCACHE_GHA_ENABLED: "true" |
| 30 | + RUSTC_WRAPPER: "sccache" |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + job: |
| 35 | + - { os: ubuntu-latest , features: "feat_os_unix" } |
| 36 | + - { os: macos-latest , features: "feat_os_macos" } |
| 37 | + - { os: windows-latest , features: "feat_os_windows" } |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + persist-credentials: false |
| 42 | + - uses: dtolnay/rust-toolchain@stable |
| 43 | + - uses: taiki-e/install-action@nextest |
| 44 | + - uses: Swatinem/rust-cache@v2 |
| 45 | + - name: Run sccache-cache |
| 46 | + uses: mozilla-actions/sccache-action@v0.0.9 |
| 47 | + - name: Install/setup prerequisites |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + ## Install/setup prerequisites |
| 51 | + case '${{ matrix.job.os }}' in |
| 52 | + ubuntu-*) |
| 53 | + # selinux headers needed for testing |
| 54 | + sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev |
| 55 | + ;; |
| 56 | + macos-*) |
| 57 | + # needed for testing |
| 58 | + brew install coreutils |
| 59 | + ;; |
| 60 | + esac |
| 61 | + - name: Build with l10n features |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + ## Build with l10n features |
| 65 | + cargo build --features ${{ matrix.job.features }} |
| 66 | + - name: Test l10n functionality |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + ## Test l10n functionality |
| 70 | + cargo test -p uucore locale |
| 71 | + cargo test |
| 72 | + env: |
| 73 | + RUST_BACKTRACE: "1" |
| 74 | + |
| 75 | + l10n_disable_test: |
| 76 | + name: L10n/Disabled Build Test |
| 77 | + runs-on: ${{ matrix.job.os }} |
| 78 | + env: |
| 79 | + SCCACHE_GHA_ENABLED: "true" |
| 80 | + RUSTC_WRAPPER: "sccache" |
| 81 | + strategy: |
| 82 | + fail-fast: false |
| 83 | + matrix: |
| 84 | + job: |
| 85 | + - { os: ubuntu-latest , features: "feat_os_unix,disable_i18n" } |
| 86 | + - { os: macos-latest , features: "feat_os_macos,disable_i18n" } |
| 87 | + - { os: windows-latest , features: "feat_os_windows,disable_i18n" } |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@v4 |
| 90 | + with: |
| 91 | + persist-credentials: false |
| 92 | + - uses: dtolnay/rust-toolchain@stable |
| 93 | + - uses: taiki-e/install-action@nextest |
| 94 | + - uses: Swatinem/rust-cache@v2 |
| 95 | + - name: Run sccache-cache |
| 96 | + uses: mozilla-actions/sccache-action@v0.0.9 |
| 97 | + - name: Install/setup prerequisites |
| 98 | + shell: bash |
| 99 | + run: | |
| 100 | + ## Install/setup prerequisites |
| 101 | + case '${{ matrix.job.os }}' in |
| 102 | + ubuntu-*) |
| 103 | + # selinux headers needed for testing |
| 104 | + sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev |
| 105 | + ;; |
| 106 | + macos-*) |
| 107 | + # needed for testing |
| 108 | + brew install coreutils |
| 109 | + ;; |
| 110 | + esac |
| 111 | + - name: Build without l10n features |
| 112 | + shell: bash |
| 113 | + run: | |
| 114 | + ## Build without l10n features |
| 115 | + cargo build --features ${{ matrix.job.features }} |
| 116 | + - name: Test l10n disabled functionality |
| 117 | + shell: bash |
| 118 | + run: | |
| 119 | + ## Test l10n disabled functionality |
| 120 | + cargo test --features disable_i18n -p uucore locale |
| 121 | + cargo test --features disable_i18n |
| 122 | + env: |
| 123 | + RUST_BACKTRACE: "1" |
| 124 | + |
| 125 | + l10n_fluent_syntax: |
| 126 | + name: L10n/Fluent Syntax Check |
| 127 | + runs-on: ubuntu-latest |
| 128 | + steps: |
| 129 | + - uses: actions/checkout@v4 |
| 130 | + with: |
| 131 | + persist-credentials: false |
| 132 | + - name: Setup Python |
| 133 | + uses: actions/setup-python@v5 |
| 134 | + with: |
| 135 | + python-version: '3.x' |
| 136 | + - name: Install Mozilla Fluent Linter |
| 137 | + shell: bash |
| 138 | + run: | |
| 139 | + ## Install Mozilla Fluent Linter |
| 140 | + pip install moz-fluent-linter |
| 141 | + - name: Find and validate Fluent files |
| 142 | + shell: bash |
| 143 | + run: | |
| 144 | + ## Find and validate Fluent files with Mozilla Fluent Linter |
| 145 | +
|
| 146 | + # Check if any .ftl files exist |
| 147 | + fluent_files=$(find . -name "*.ftl" -type f 2>/dev/null || true) |
| 148 | +
|
| 149 | + if [ -z "$fluent_files" ]; then |
| 150 | + echo "::notice::No Fluent (.ftl) files found in the repository" |
| 151 | + exit 0 |
| 152 | + fi |
| 153 | +
|
| 154 | + echo "Found Fluent files:" |
| 155 | + echo "$fluent_files" |
| 156 | +
|
| 157 | + # Use Mozilla Fluent Linter for comprehensive validation |
| 158 | + echo "Running Mozilla Fluent Linter..." |
| 159 | +
|
| 160 | + has_errors=false |
| 161 | +
|
| 162 | + while IFS= read -r file; do |
| 163 | + echo "Checking $file with Mozilla Fluent Linter..." |
| 164 | +
|
| 165 | + # Run fluent-linter on each file |
| 166 | + if ! moz-fluent-lint "$file"; then |
| 167 | + echo "::error file=$file::Fluent syntax errors found in $file" |
| 168 | + has_errors=true |
| 169 | + else |
| 170 | + echo "✓ Fluent syntax check passed for $file" |
| 171 | + fi |
| 172 | +
|
| 173 | + done <<< "$fluent_files" |
| 174 | +
|
| 175 | + if [ "$has_errors" = true ]; then |
| 176 | + echo "::error::Fluent linting failed - please fix syntax errors" |
| 177 | + exit 1 |
| 178 | + fi |
| 179 | +
|
| 180 | + echo "::notice::All Fluent files passed Mozilla Fluent Linter validation" |
| 181 | +
|
| 182 | + l10n_feature_combinations: |
| 183 | + name: L10n/Feature Combinations |
| 184 | + runs-on: ubuntu-latest |
| 185 | + env: |
| 186 | + SCCACHE_GHA_ENABLED: "true" |
| 187 | + RUSTC_WRAPPER: "sccache" |
| 188 | + steps: |
| 189 | + - uses: actions/checkout@v4 |
| 190 | + with: |
| 191 | + persist-credentials: false |
| 192 | + - uses: dtolnay/rust-toolchain@stable |
| 193 | + - uses: Swatinem/rust-cache@v2 |
| 194 | + - name: Run sccache-cache |
| 195 | + uses: mozilla-actions/sccache-action@v0.0.9 |
| 196 | + - name: Install/setup prerequisites |
| 197 | + shell: bash |
| 198 | + run: | |
| 199 | + sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev |
| 200 | + - name: Test feature combinations |
| 201 | + shell: bash |
| 202 | + run: | |
| 203 | + ## Test different l10n feature combinations |
| 204 | +
|
| 205 | + echo "Testing with i18n enabled by default..." |
| 206 | + cargo check -p uucore |
| 207 | +
|
| 208 | + echo "Testing with disable_i18n feature..." |
| 209 | + cargo check --features "disable_i18n" -p uucore |
| 210 | +
|
| 211 | + echo "All feature combinations compiled successfully" |
| 212 | + env: |
| 213 | + RUST_BACKTRACE: "1" |
| 214 | + |
| 215 | + l10n_french_integration: |
| 216 | + name: L10n/French Integration Test |
| 217 | + runs-on: ubuntu-latest |
| 218 | + env: |
| 219 | + SCCACHE_GHA_ENABLED: "true" |
| 220 | + RUSTC_WRAPPER: "sccache" |
| 221 | + steps: |
| 222 | + - uses: actions/checkout@v4 |
| 223 | + with: |
| 224 | + persist-credentials: false |
| 225 | + - uses: dtolnay/rust-toolchain@stable |
| 226 | + - uses: Swatinem/rust-cache@v2 |
| 227 | + - name: Run sccache-cache |
| 228 | + uses: mozilla-actions/sccache-action@v0.0.9 |
| 229 | + - name: Install/setup prerequisites |
| 230 | + shell: bash |
| 231 | + run: | |
| 232 | + ## Install/setup prerequisites |
| 233 | + sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev locales |
| 234 | + - name: Generate French locale |
| 235 | + shell: bash |
| 236 | + run: | |
| 237 | + ## Generate French locale for testing |
| 238 | + sudo locale-gen --keep-existing fr_FR.UTF-8 |
| 239 | + locale -a | grep -i fr || echo "French locale not found, continuing anyway" |
| 240 | + - name: Build coreutils with l10n support |
| 241 | + shell: bash |
| 242 | + run: | |
| 243 | + ## Build coreutils with Unix features and l10n support |
| 244 | + cargo build --features feat_os_unix --bin coreutils |
| 245 | + - name: Test French localization |
| 246 | + shell: bash |
| 247 | + run: | |
| 248 | + ## Test French localization with various commands |
| 249 | + export LANG=fr_FR.UTF-8 |
| 250 | + export LC_ALL=fr_FR.UTF-8 |
| 251 | +
|
| 252 | + echo "Testing touch --help with French locale..." |
| 253 | + help_output=$(cargo run --features feat_os_unix --bin coreutils -- touch --help 2>&1 || echo "Command failed") |
| 254 | + echo "Help output: $help_output" |
| 255 | +
|
| 256 | + # Check for specific French strings from touch fr-FR.ftl |
| 257 | + french_strings_found=0 |
| 258 | + if echo "$help_output" | grep -q "Mettre à jour les temps d'accès"; then |
| 259 | + echo "✓ Found French description: 'Mettre à jour les temps d'accès'" |
| 260 | + french_strings_found=$((french_strings_found + 1)) |
| 261 | + fi |
| 262 | + if echo "$help_output" | grep -q "changer seulement le temps d'accès"; then |
| 263 | + echo "✓ Found French help text: 'changer seulement le temps d'accès'" |
| 264 | + french_strings_found=$((french_strings_found + 1)) |
| 265 | + fi |
| 266 | + if echo "$help_output" | grep -q "FICHIER"; then |
| 267 | + echo "✓ Found French usage pattern: 'FICHIER'" |
| 268 | + french_strings_found=$((french_strings_found + 1)) |
| 269 | + fi |
| 270 | +
|
| 271 | + echo "Testing ls --help with French locale..." |
| 272 | + ls_help=$(cargo run --features feat_os_unix --bin coreutils -- ls --help 2>&1 || echo "Command failed") |
| 273 | + echo "ls help output: $ls_help" |
| 274 | +
|
| 275 | + # Check for specific French strings from ls fr-FR.ftl |
| 276 | + if echo "$ls_help" | grep -q "Lister le contenu des répertoires"; then |
| 277 | + echo "✓ Found French ls description: 'Lister le contenu des répertoires'" |
| 278 | + french_strings_found=$((french_strings_found + 1)) |
| 279 | + fi |
| 280 | + if echo "$ls_help" | grep -q "Afficher les informations d'aide"; then |
| 281 | + echo "✓ Found French ls help text: 'Afficher les informations d'aide'" |
| 282 | + french_strings_found=$((french_strings_found + 1)) |
| 283 | + fi |
| 284 | +
|
| 285 | + echo "Testing base64 --help with French locale..." |
| 286 | + base64_help=$(cargo run --features feat_os_unix --bin coreutils -- base64 --help 2>&1 || echo "Command failed") |
| 287 | + echo "base64 help output: $base64_help" |
| 288 | +
|
| 289 | + # Check for specific French strings from base64 fr-FR.ftl |
| 290 | + if echo "$base64_help" | grep -q "encoder/décoder les données"; then |
| 291 | + echo "✓ Found French base64 description: 'encoder/décoder les données'" |
| 292 | + french_strings_found=$((french_strings_found + 1)) |
| 293 | + fi |
| 294 | +
|
| 295 | + echo "Testing with error messages..." |
| 296 | + error_output=$(cargo run --features feat_os_unix --bin coreutils -- ls /nonexistent 2>&1 || echo "Expected error occurred") |
| 297 | + echo "Error output: $error_output" |
| 298 | +
|
| 299 | + # Check for French error messages from ls fr-FR.ftl |
| 300 | + if echo "$error_output" | grep -q "impossible d'accéder à"; then |
| 301 | + echo "✓ Found French error message: 'impossible d'accéder à'" |
| 302 | + french_strings_found=$((french_strings_found + 1)) |
| 303 | + fi |
| 304 | + if echo "$error_output" | grep -q "Aucun fichier ou répertoire de ce type"; then |
| 305 | + echo "✓ Found French error text: 'Aucun fichier ou répertoire de ce type'" |
| 306 | + french_strings_found=$((french_strings_found + 1)) |
| 307 | + fi |
| 308 | +
|
| 309 | + # Test that the binary works and doesn't crash with French locale |
| 310 | + version_output=$(cargo run --features feat_os_unix --bin coreutils -- --version 2>&1 || echo "Version command failed") |
| 311 | + echo "Version output: $version_output" |
| 312 | +
|
| 313 | + # Final validation - ensure we found at least some French strings |
| 314 | + echo "French strings found: $french_strings_found" |
| 315 | + if [ "$french_strings_found" -gt 0 ]; then |
| 316 | + echo "✓ SUCCESS: French locale integration test passed - found $french_strings_found French strings" |
| 317 | + else |
| 318 | + echo "⚠ WARNING: No French strings were detected, but commands executed successfully" |
| 319 | + exit 1 |
| 320 | + fi |
| 321 | + env: |
| 322 | + RUST_BACKTRACE: "1" |
0 commit comments