Debian Codegraph @

.github/workflows/l10n.yml

raw
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 CARGO_INCREMENTAL: "0"
15 RUST_BACKTRACE: "1"
16 permissions:
17 contents: read # to fetch code (actions/checkout)
18
19 # End the current execution if there is a new changeset in the PR.
20 concurrency:
21 group: ${{ github.workflow }}-${{ github.ref }}
22 cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
23
24 jobs:
25
26 l10n_build_test:
27 name: L10n/Build and Test
28 runs-on: ${{ matrix.job.os }}
29 strategy:
30 fail-fast: false
31 matrix:
32 job:
33 - { os: ubuntu-latest , features: "feat_os_unix" }
34 - { os: macos-latest , features: "feat_os_unix" }
35 - { os: windows-latest , features: "feat_os_windows" }
36 steps:
37 - uses: actions/[email protected]
38 with:
39 persist-credentials: false
40 - uses: taiki-e/install-action@nextest
41 - uses: Swatinem/rust-cache@v2
42 - name: Run sccache-cache
43 id: sccache-setup
44 uses: mozilla-actions/[email protected]
45 continue-on-error: true
46 - name: Export sccache
47 if: steps.sccache-setup.outcome == 'success'
48 run: |
49 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
50 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
51 - name: Install/setup prerequisites
52 shell: bash
53 run: |
54 ## Install/setup prerequisites
55 case '${{ matrix.job.os }}' in
56 ubuntu-*)
57 # selinux headers needed for testing
58 sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev
59 # Locales required by tests/by-util/test_date.rs and
60 # tests/by-util/test_dd.rs (fr_FR is the ISO-8859-1 variant
61 # used by test_iso8859_1_case_conversion).
62 sudo locale-gen --keep-existing fr_FR
63 sudo locale-gen --keep-existing fr_FR.UTF-8
64 sudo locale-gen --keep-existing es_ES.UTF-8
65 sudo locale-gen --keep-existing en_US.UTF-8
66 sudo locale-gen --keep-existing fa_IR.UTF-8 # Iran
67 sudo locale-gen --keep-existing am_ET.UTF-8 # Ethiopia
68 sudo locale-gen --keep-existing th_TH.UTF-8 # Thailand
69 sudo locale-gen --keep-existing hu_HU.UTF-8 # Hungary
70 sudo update-locale
71 ;;
72 esac
73 - name: Test l10n functionality
74 shell: bash
75 run: |
76 ## Test l10n functionality
77 cargo test -p uucore locale
78 cargo test
79
80 l10n_fluent_syntax:
81 name: L10n/Fluent Syntax Check
82 runs-on: ubuntu-latest
83 steps:
84 - uses: actions/[email protected]
85 with:
86 persist-credentials: false
87 - name: Install Mozilla Fluent Linter
88 shell: bash
89 run: |
90 ## Install Mozilla Fluent Linter
91 pip install moz-fluent-linter
92 - name: Find and validate Fluent files
93 shell: bash
94 run: |
95
96 fluent_dirs=$(find . -name "*.ftl" -type f -exec dirname {} \; | sort | uniq 2>/dev/null || :)
97
98 if [ -n "$fluent_dirs" ]; then
99 echo "Found Fluent directories:"
100 echo "$fluent_dirs"
101
102 # Count total files for informational purposes
103 total_files=$(find . -name "*.ftl" -type f | wc -l)
104 echo "Total Fluent files: $total_files"
105 else
106 echo "::notice::No Fluent (.ftl) files found in the repository"
107 exit 0
108 fi
109
110 echo "Running Fluent Linter on directories..."
111
112 has_errors=false
113
114 while IFS= read -r dir; do
115 echo "Checking directory $dir with Fluent Linter..."
116
117 if ! moz-fluent-lint --config .github/fluent_linter_config.yml "$dir"; then
118 echo "::error::Fluent syntax errors found in $dir"
119 exit 1
120 else
121 echo "✓ Fluent syntax check passed for directory $dir"
122 fi
123
124 done <<< "$fluent_dirs"
125
126 echo "::notice::All Fluent directories passed Fluent Linter validation"
127
128 l10n_clap_error_localization:
129 name: L10n/Clap Error Localization Test
130 runs-on: ubuntu-latest
131 steps:
132 - uses: actions/[email protected]
133 with:
134 persist-credentials: false
135 - uses: Swatinem/rust-cache@v2
136 - name: Run sccache-cache
137 id: sccache-setup
138 uses: mozilla-actions/[email protected]
139 continue-on-error: true
140 - name: Export sccache
141 if: steps.sccache-setup.outcome == 'success'
142 run: |
143 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
144 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
145 - name: Install/setup prerequisites
146 shell: bash
147 run: |
148 sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev
149 sudo locale-gen --keep-existing fr_FR.UTF-8
150 locale -a | grep -i fr || exit 1
151 - name: Test English clap error localization
152 shell: bash
153 run: |
154 export LANG=en_US.UTF-8
155 export LC_ALL=en_US.UTF-8
156
157 # Test invalid argument error - should show colored error message
158 echo "Testing invalid argument error..."
159 error_output=$(cargo run --features feat_os_unix --bin coreutils -- cp --invalid-arg 2>&1 || echo "Expected error occurred")
160 echo "Error output: $error_output"
161
162 # Check for expected English clap error patterns
163 english_errors_found=0
164
165 if echo "$error_output" | grep -q "error.*unexpected argument"; then
166 echo "✓ Found English clap error message pattern"
167 english_errors_found=$((english_errors_found + 1))
168 fi
169
170 if echo "$error_output" | grep -q "Usage:"; then
171 echo "✓ Found English usage pattern"
172 english_errors_found=$((english_errors_found + 1))
173 fi
174
175 if echo "$error_output" | grep -q "For more information.*--help"; then
176 echo "✓ Found English help suggestion"
177 english_errors_found=$((english_errors_found + 1))
178 fi
179
180 # Test typo suggestion
181 echo "Testing typo suggestion..."
182 typo_output=$(cargo run --features feat_os_unix --bin coreutils -- ls --verbos 2>&1 || echo "Expected error occurred")
183 echo "Typo output: $typo_output"
184
185 if echo "$typo_output" | grep -q "similar.*verbose"; then
186 echo "✓ Found English typo suggestion"
187 english_errors_found=$((english_errors_found + 1))
188 fi
189
190 echo "English clap errors found: $english_errors_found"
191 if [ "$english_errors_found" -ge 2 ]; then
192 echo "✓ SUCCESS: English clap error localization working"
193 else
194 echo "✗ ERROR: English clap error localization not working properly"
195 exit 1
196 fi
197
198 - name: Test French clap error localization
199 shell: bash
200 run: |
201 export LANG=fr_FR.UTF-8
202 export LC_ALL=fr_FR.UTF-8
203
204 # Test invalid argument error - should show French colored error message
205 echo "Testing invalid argument error in French..."
206 error_output=$(cargo run --features feat_os_unix --bin coreutils -- cp --invalid-arg 2>&1 || echo "Expected error occurred")
207 echo "French error output: $error_output"
208
209 # Check for expected French clap error patterns
210 french_errors_found=0
211
212 if echo "$error_output" | grep -q "erreur.*argument inattendu"; then
213 echo "✓ Found French clap error message: 'erreur: argument inattendu'"
214 french_errors_found=$((french_errors_found + 1))
215 fi
216
217 if echo "$error_output" | grep -q "conseil.*pour passer.*comme valeur"; then
218 echo "✓ Found French tip message: 'conseil: pour passer ... comme valeur'"
219 french_errors_found=$((french_errors_found + 1))
220 fi
221
222 if echo "$error_output" | grep -q "Utilisation:"; then
223 echo "✓ Found French usage pattern: 'Utilisation:'"
224 french_errors_found=$((french_errors_found + 1))
225 fi
226
227 if echo "$error_output" | grep -q "Pour plus d'informations.*--help"; then
228 echo "✓ Found French help suggestion: 'Pour plus d'informations'"
229 french_errors_found=$((french_errors_found + 1))
230 fi
231
232 # Test typo suggestion in French
233 echo "Testing typo suggestion in French..."
234 typo_output=$(cargo run --features feat_os_unix --bin coreutils -- ls --verbos 2>&1 || echo "Expected error occurred")
235 echo "French typo output: $typo_output"
236
237 if echo "$typo_output" | grep -q "conseil.*similaire.*verbose"; then
238 echo "✓ Found French typo suggestion with 'conseil'"
239 french_errors_found=$((french_errors_found + 1))
240 fi
241
242 echo "French clap errors found: $french_errors_found"
243 if [ "$french_errors_found" -ge 2 ]; then
244 echo "✓ SUCCESS: French clap error localization working - found $french_errors_found French patterns"
245 else
246 echo "✗ ERROR: French clap error localization not working properly"
247 echo "Note: This might be expected if French common locale files are not available"
248 # Don't fail the build - French clap localization might not be fully set up yet
249 echo "::warning::French clap error localization not working, but continuing"
250 fi
251
252 # Test that colors are working (ANSI escape codes)
253 echo "Testing ANSI color codes in error output..."
254 if echo "$error_output" | grep -q $'\x1b\[3[0-7]m'; then
255 echo "✓ Found ANSI color codes in error output"
256 else
257 echo "✗ No ANSI color codes found - colors may not be working"
258 echo "::warning::ANSI color codes not detected in clap error output"
259 fi
260
261 - name: Test clap localization with multiple utilities
262 shell: bash
263 run: |
264 export LANG=en_US.UTF-8
265 export LC_ALL=en_US.UTF-8
266
267 utilities_to_test=("ls" "cat" "touch" "cp" "mv")
268 utilities_passed=0
269
270 for util in "${utilities_to_test[@]}"; do
271 echo "Testing $util with invalid argument..."
272 util_error=$(cargo run --features feat_os_unix --bin coreutils -- "$util" --nonexistent-flag 2>&1 || echo "Expected error occurred")
273
274 if echo "$util_error" | grep -q "error.*unexpected argument"; then
275 echo "✓ $util: clap localization working"
276 utilities_passed=$((utilities_passed + 1))
277 else
278 echo "✗ $util: clap localization not working"
279 echo "Output: $util_error"
280 fi
281 done
282
283 echo "Utilities with working clap localization: $utilities_passed/${#utilities_to_test[@]}"
284 if [ "$utilities_passed" -ge 3 ]; then
285 echo "✓ SUCCESS: Clap localization working across multiple utilities"
286 else
287 echo "✗ ERROR: Clap localization not working for enough utilities"
288 exit 1
289 fi
290
291 l10n_french_integration:
292 name: L10n/French Integration Test
293 runs-on: ubuntu-latest
294 steps:
295 - uses: actions/[email protected]
296 with:
297 persist-credentials: false
298 - uses: Swatinem/rust-cache@v2
299 - name: Run sccache-cache
300 id: sccache-setup
301 uses: mozilla-actions/[email protected]
302 continue-on-error: true
303 - name: Export sccache
304 if: steps.sccache-setup.outcome == 'success'
305 run: |
306 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
307 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
308 - name: Install/setup prerequisites
309 shell: bash
310 run: |
311 ## Install/setup prerequisites
312 sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev
313 - name: Generate French locale
314 shell: bash
315 run: |
316 ## Generate French locale for testing
317 sudo locale-gen --keep-existing fr_FR.UTF-8
318 locale -a | grep -i fr || echo "French locale not found, continuing anyway"
319 - name: Test French localization
320 shell: bash
321 run: |
322 ## Test French localization with various commands
323 export LANG=fr_FR.UTF-8
324 export LC_ALL=fr_FR.UTF-8
325
326 echo "Testing touch --help with French locale..."
327 help_output=$(cargo run --features feat_os_unix --bin coreutils -- touch --help 2>&1 || echo "Command failed")
328 echo "Help output: $help_output"
329
330 # Check for specific French strings from touch fr-FR.ftl
331 french_strings_found=0
332 if echo "$help_output" | grep -q "Mettre à jour les temps d'accès"; then
333 echo "✓ Found French description: 'Mettre à jour les temps d'accès'"
334 french_strings_found=$((french_strings_found + 1))
335 fi
336 if echo "$help_output" | grep -q "changer seulement le temps d'accès"; then
337 echo "✓ Found French help text: 'changer seulement le temps d'accès'"
338 french_strings_found=$((french_strings_found + 1))
339 fi
340 if echo "$help_output" | grep -q "FICHIER"; then
341 echo "✓ Found French usage pattern: 'FICHIER'"
342 french_strings_found=$((french_strings_found + 1))
343 fi
344
345 echo "Testing ls --help with French locale..."
346 ls_help=$(cargo run --features feat_os_unix --bin coreutils -- ls --help 2>&1 || echo "Command failed")
347 echo "ls help output: $ls_help"
348
349 # Check for specific French strings from ls fr-FR.ftl
350 if echo "$ls_help" | grep -q "Lister le contenu des répertoires"; then
351 echo "✓ Found French ls description: 'Lister le contenu des répertoires'"
352 french_strings_found=$((french_strings_found + 1))
353 fi
354 if echo "$ls_help" | grep -q "Afficher les informations d'aide"; then
355 echo "✓ Found French ls help text: 'Afficher les informations d'aide'"
356 french_strings_found=$((french_strings_found + 1))
357 fi
358
359 echo "Testing base64 --help with French locale..."
360 base64_help=$(cargo run --features feat_os_unix --bin coreutils -- base64 --help 2>&1 || echo "Command failed")
361 echo "base64 help output: $base64_help"
362
363 # Check for specific French strings from base64 fr-FR.ftl
364 if echo "$base64_help" | grep -q "encoder/décoder les données"; then
365 echo "✓ Found French base64 description: 'encoder/décoder les données'"
366 french_strings_found=$((french_strings_found + 1))
367 fi
368
369 echo "Testing with error messages..."
370 error_output=$(cargo run --features feat_os_unix --bin coreutils -- ls /nonexistent 2>&1 || echo "Expected error occurred")
371 echo "Error output: $error_output"
372
373 # Check for French error messages from ls fr-FR.ftl
374 if echo "$error_output" | grep -q "impossible d'accéder à"; then
375 echo "✓ Found French error message: 'impossible d'accéder à'"
376 french_strings_found=$((french_strings_found + 1))
377 fi
378 if echo "$error_output" | grep -q "Aucun fichier ou répertoire de ce type"; then
379 echo "✓ Found French error text: 'Aucun fichier ou répertoire de ce type'"
380 french_strings_found=$((french_strings_found + 1))
381 fi
382
383 # Test that the binary works and doesn't crash with French locale
384 version_output=$(cargo run --features feat_os_unix --bin coreutils -- --version 2>&1 || echo "Version command failed")
385 echo "Version output: $version_output"
386
387 # Final validation - ensure we found at least some French strings
388 echo "French strings found: $french_strings_found"
389 if [ "$french_strings_found" -gt 0 ]; then
390 echo "✓ SUCCESS: French locale integration test passed - found $french_strings_found French strings"
391 else
392 echo "✗ ERROR: No French strings were detected, but commands executed successfully"
393 exit 1
394 fi
395
396 l10n_multicall_binary_install:
397 name: L10n/Multi-call Binary Install Test
398 runs-on: ${{ matrix.job.os }}
399 strategy:
400 fail-fast: false
401 matrix:
402 job:
403 - { os: ubuntu-latest , features: "feat_os_unix" }
404 - { os: macos-latest , features: "feat_os_unix" }
405 steps:
406 - uses: actions/[email protected]
407 with:
408 persist-credentials: false
409 - uses: Swatinem/rust-cache@v2
410 - name: Run sccache-cache
411 id: sccache-setup
412 uses: mozilla-actions/[email protected]
413 continue-on-error: true
414 - name: Export sccache
415 if: steps.sccache-setup.outcome == 'success'
416 run: |
417 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
418 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
419 - name: Install/setup prerequisites
420 shell: bash
421 run: |
422 ## Install/setup prerequisites
423 case '${{ matrix.job.os }}' in
424 ubuntu-*)
425 sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev
426 ;;
427 esac
428 - name: Install via make and test multi-call binary
429 shell: bash
430 run: |
431 ## Install using make and test installed binaries
432 echo "Installing with make using DESTDIR..."
433
434 # Create installation directory
435 INSTALL_DIR="$PWD/install-dir"
436 mkdir -p "$INSTALL_DIR"
437 mkdir -p "$INSTALL_DIR/usr/bin"
438
439 # Build and install using make with DESTDIR
440 echo "Building multi-call binary with MULTICALL=y"
441 echo "Current directory: $PWD"
442 echo "Installation directory will be: $INSTALL_DIR"
443
444 # First check if binary exists after build
445 echo "Checking if coreutils was built..."
446 target/release-small/coreutils --version || echo "No coreutils binary in target/release-small/"
447
448 make FEATURES="${{ matrix.job.features }}" PROFILE=release-small MULTICALL=y
449
450 echo "After build, checking target/release-small/:"
451 ls -la target/release-small/ | grep -E "(coreutils|^total)" || echo "Build may have failed"
452
453 echo "Running make install..."
454 echo "Before install - checking what we have:"
455 target/release-small/coreutils --version 2>/dev/null || echo "No coreutils in target/release-small"
456
457 # Run make install with verbose output to see what happens
458 echo "About to run: make install DESTDIR=\"$INSTALL_DIR\" PREFIX=/usr PROFILE=release-small MULTICALL=y"
459 echo "Expected install path: $INSTALL_DIR/usr/bin/coreutils"
460
461 make install DESTDIR="$INSTALL_DIR" PREFIX=/usr PROFILE=release-small MULTICALL=y || {
462 echo "Make install failed! Exit code: $?"
463 echo "Let's see what happened:"
464 ls -la "$INSTALL_DIR" 2>/dev/null || echo "Install directory doesn't exist"
465 exit 1
466 }
467
468 echo "Make install completed successfully"
469
470 # Debug: Show what was installed
471 echo "=== Installation Debug ==="
472 echo "Current directory: $(pwd)"
473 echo "INSTALL_DIR: $INSTALL_DIR"
474 echo "Checking if build succeeded..."
475 if target/release-small/coreutils --version; then
476 echo "✓ Build succeeded - coreutils binary exists in target/release-small/"
477 else
478 echo "✗ Build failed - no coreutils binary in target/release-small/"
479 echo "Contents of target/release-small/:"
480 ls -la target/release-small/ | head -20
481 exit 1
482 fi
483
484 echo "Contents of installation directory:"
485 find "$INSTALL_DIR" -type f 2>/dev/null | head -20 || echo "No files found in $INSTALL_DIR"
486
487 echo "Checking standard installation paths..."
488 ls -la "$INSTALL_DIR/usr/bin/" 2>/dev/null || echo "Directory $INSTALL_DIR/usr/bin/ not found"
489 ls -la "$INSTALL_DIR/usr/local/bin/" 2>/dev/null || echo "Directory $INSTALL_DIR/usr/local/bin/ not found"
490 ls -la "$INSTALL_DIR/bin/" 2>/dev/null || echo "Directory $INSTALL_DIR/bin/ not found"
491
492 # Find where coreutils was actually installed
493 echo "Searching for coreutils binary in installation directory..."
494 # First try the expected location
495 if [ -x "$INSTALL_DIR/usr/bin/coreutils" ]; then
496 COREUTILS_BIN="$INSTALL_DIR/usr/bin/coreutils"
497 else
498 # Fallback: search for executable files named coreutils (excluding completion files)
499 COREUTILS_BIN=$(find "$INSTALL_DIR" -path "*/bin/*" -name "coreutils" -type f 2>/dev/null | head -1)
500 fi
501 if [ -n "$COREUTILS_BIN" ]; then
502 echo "Found coreutils at: $COREUTILS_BIN"
503 export COREUTILS_BIN
504 else
505 echo "ERROR: coreutils binary not found in installation directory!"
506 echo "Installation may have failed. Let's check the entire filesystem under install-dir:"
507 find "$INSTALL_DIR" -type f 2>/dev/null | head -50
508
509 # As a last resort, check if it's in the build directory
510 if "target/release/coreutils" --version; then
511 echo "Using binary from build directory as fallback"
512 COREUTILS_BIN="$(pwd)/target/release/coreutils"
513 export COREUTILS_BIN
514 else
515 exit 1
516 fi
517 fi
518
519 echo "Testing installed multi-call binary functionality..."
520
521 # Test calling utilities through coreutils binary
522 echo "Testing: $COREUTILS_BIN ls --version"
523 "$COREUTILS_BIN" ls --version
524
525 echo "Testing: $COREUTILS_BIN cat --version"
526 "$COREUTILS_BIN" cat --version
527
528 echo "Testing: $COREUTILS_BIN touch --version"
529 "$COREUTILS_BIN" touch --version
530
531 # Test individual binaries (if they exist)
532 LS_BIN="$INSTALL_DIR/usr/bin/ls"
533 if [ -f "$LS_BIN" ]; then
534 echo "Testing individual binary: $LS_BIN --version"
535 "$LS_BIN" --version
536 else
537 echo "Individual ls binary not found (multi-call only mode)"
538 # Check if symlinks exist
539 if [ -L "$LS_BIN" ]; then
540 echo "Found ls as symlink to: $(readlink -f "$LS_BIN")"
541 fi
542 fi
543
544 echo "✓ Multi-call binary installation and functionality test passed"
545
546 l10n_installation_test:
547 name: L10n/Installation Test (Make & Cargo)
548 runs-on: ${{ matrix.job.os }}
549 strategy:
550 fail-fast: false
551 matrix:
552 job:
553 - { os: ubuntu-latest , features: "feat_os_unix" }
554 - { os: macos-latest , features: "feat_os_unix" }
555 steps:
556 - uses: actions/[email protected]
557 with:
558 persist-credentials: false
559 - uses: Swatinem/rust-cache@v2
560 - name: Run sccache-cache
561 id: sccache-setup
562 uses: mozilla-actions/[email protected]
563 continue-on-error: true
564 - name: Export sccache
565 if: steps.sccache-setup.outcome == 'success'
566 run: |
567 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
568 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
569 - name: Install/setup prerequisites
570 shell: bash
571 run: |
572 ## Install/setup prerequisites
573 case '${{ matrix.job.os }}' in
574 ubuntu-*)
575 sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev
576 # Generate French locale for testing
577 sudo locale-gen --keep-existing fr_FR.UTF-8
578 locale -a | grep -i fr || echo "French locale generation may have failed"
579 ;;
580 esac
581 - name: Test Make installation
582 shell: bash
583 run: |
584 ## Test installation via make with DESTDIR
585 echo "Testing make install with l10n features..."
586
587 # Create installation directory
588 MAKE_INSTALL_DIR="$PWD/make-install-dir"
589 mkdir -p "$MAKE_INSTALL_DIR"
590
591 # Build and install using make with DESTDIR
592 make FEATURES="${{ matrix.job.features }}" PROFILE=release-small MULTICALL=y
593 make install DESTDIR="$MAKE_INSTALL_DIR" PREFIX=/usr PROFILE=release-small MULTICALL=y
594
595 # Verify installation
596 echo "Testing make-installed binaries..."
597 if "$MAKE_INSTALL_DIR/usr/bin/coreutils" --version; then
598 echo "✓ coreutils binary installed via make successfully"
599 else
600 echo "✗ coreutils binary not found after make install"
601 exit 1
602 fi
603
604 # Test utilities
605 echo "Testing make-installed utilities..."
606 "$MAKE_INSTALL_DIR/usr/bin/coreutils" ls --version
607 "$MAKE_INSTALL_DIR/usr/bin/coreutils" cat --version
608 "$MAKE_INSTALL_DIR/usr/bin/coreutils" touch --version
609
610 # Test basic functionality
611 echo "test content" > test.txt
612 if "$MAKE_INSTALL_DIR/usr/bin/coreutils" cat test.txt | grep -q "test content"; then
613 echo "✓ Basic functionality works"
614 else
615 echo "✗ Basic functionality failed"
616 exit 1
617 fi
618
619 # Test French localization with make-installed binary (Ubuntu only)
620 if [ "${{ matrix.job.os }}" = "ubuntu-latest" ]; then
621 echo "Testing French localization with make-installed binary..."
622
623 # Set French locale
624 export LANG=fr_FR.UTF-8
625 export LC_ALL=fr_FR.UTF-8
626
627 echo "Testing ls --help with French locale..."
628 ls_help=$("$MAKE_INSTALL_DIR/usr/bin/coreutils" ls --help 2>&1 || echo "Command failed")
629 echo "ls help output (first 10 lines):"
630 echo "$ls_help" | head -10
631
632 # Check for specific French strings from ls fr-FR.ftl
633 french_strings_found=0
634
635 if echo "$ls_help" | grep -q "Lister le contenu des répertoires"; then
636 echo "✓ Found French ls description: 'Lister le contenu des répertoires'"
637 french_strings_found=$((french_strings_found + 1))
638 fi
639
640 if echo "$ls_help" | grep -q "Afficher les informations d'aide"; then
641 echo "✓ Found French ls help text: 'Afficher les informations d'aide'"
642 french_strings_found=$((french_strings_found + 1))
643 fi
644
645 if echo "$ls_help" | grep -q "FICHIER"; then
646 echo "✓ Found French usage pattern: 'FICHIER'"
647 french_strings_found=$((french_strings_found + 1))
648 fi
649
650 echo "Testing cat --help with French locale..."
651 cat_help=$("$MAKE_INSTALL_DIR/usr/bin/coreutils" cat --help 2>&1 || echo "Command failed")
652 echo "cat help output (first 5 lines):"
653 echo "$cat_help" | head -5
654
655 if echo "$cat_help" | grep -q "Concaténer"; then
656 echo "✓ Found French cat description containing: 'Concaténer'"
657 french_strings_found=$((french_strings_found + 1))
658 fi
659
660 echo "Testing error messages with French locale..."
661 error_output=$("$MAKE_INSTALL_DIR/usr/bin/coreutils" ls /nonexistent_test_directory 2>&1 || echo "Expected error occurred")
662 echo "Error output: $error_output"
663
664 if echo "$error_output" | grep -q "impossible d'accéder à"; then
665 echo "✓ Found French error message: 'impossible d'accéder à'"
666 french_strings_found=$((french_strings_found + 1))
667 fi
668
669 # Final validation
670 echo "French strings found: $french_strings_found"
671 if [ "$french_strings_found" -gt 0 ]; then
672 echo "✓ SUCCESS: French localization test passed with make-installed binary - found $french_strings_found French strings"
673 else
674 echo "✗ ERROR: No French strings detected with make-installed binary"
675 exit 1
676 fi
677 else
678 echo "Skipping French localization test on ${{ matrix.job.os }} (no French locale available)"
679 fi
680
681 echo "✓ Make installation test passed"
682 - name: Test Cargo installation
683 shell: bash
684 run: |
685 ## Test installation via cargo install with DESTDIR-like approach
686 echo "Testing cargo install with l10n features..."
687
688 # Create installation directory
689 CARGO_INSTALL_DIR="$PWD/cargo-install-dir"
690 mkdir -p "$CARGO_INSTALL_DIR"
691
692 # Install using cargo with l10n features
693 cargo install --path . --features "ls,cat,touch" --root "$CARGO_INSTALL_DIR" --locked
694
695 # Verify installation
696 echo "Testing cargo-installed binaries..."
697 if "$CARGO_INSTALL_DIR/bin/coreutils" --version; then
698 echo "✓ coreutils binary installed successfully"
699 else
700 echo "✗ coreutils binary not found after cargo install"
701 exit 1
702 fi
703
704 # Test utilities
705 echo "Testing installed utilities..."
706 "$CARGO_INSTALL_DIR/bin/coreutils" ls --version
707 "$CARGO_INSTALL_DIR/bin/coreutils" cat --version
708 "$CARGO_INSTALL_DIR/bin/coreutils" touch --version
709
710 # Test basic functionality
711 echo "test content" > test.txt
712 if "$CARGO_INSTALL_DIR/bin/coreutils" cat test.txt | grep -q "test content"; then
713 echo "✓ Basic functionality works"
714 else
715 echo "✗ Basic functionality failed"
716 exit 1
717 fi
718
719 echo "✓ Cargo installation test passed"
720 - name: Download additional locales from coreutils-l10n
721 shell: bash
722 run: |
723 ## Download additional locale files from coreutils-l10n repository
724 echo "Downloading additional locale files from coreutils-l10n..."
725 git clone --depth=1 https://github.com/uutils/coreutils-l10n.git coreutils-l10n-repo
726
727 # Create installation directory
728 CARGO_INSTALL_DIR="$PWD/cargo-install-dir"
729
730 # Create locale directory for cargo install
731 LOCALE_DIR="$CARGO_INSTALL_DIR/share/locales"
732 mkdir -p "$LOCALE_DIR"
733
734 # Debug: Check structure of l10n repo
735 echo "Checking structure of coreutils-l10n-repo:"
736 ls -la coreutils-l10n-repo/ | head -10
737 echo "Looking for locales directory:"
738 find coreutils-l10n-repo -name "*.ftl" -type f 2>/dev/null | head -10 || :
739 echo "Checking specific utilities:"
740 ls -la coreutils-l10n-repo/src/uu/ls/locales/ 2>/dev/null || echo "No ls directory in correct location"
741 find coreutils-l10n-repo -path "*/ls/*.ftl" 2>/dev/null | head -5 || echo "No ls ftl files found"
742
743 # Copy non-English locale files from l10n repo
744 for util_dir in src/uu/*/; do
745 util_name=$(basename "$util_dir")
746 l10n_util_dir="coreutils-l10n-repo/src/uu/$util_name/locales"
747
748 if [ -d "$l10n_util_dir" ]; then
749 echo "Installing locales for $util_name..."
750 mkdir -p "$LOCALE_DIR/$util_name"
751
752 for locale_file in "$l10n_util_dir"/*.ftl; do
753 if [ -f "$locale_file" ]; then
754 filename=$(basename "$locale_file")
755 # Skip English locale files (they are embedded)
756 if [ "$filename" != "en-US.ftl" ]; then
757 cp "$locale_file" "$LOCALE_DIR/$util_name/"
758 echo " Installed $filename to $LOCALE_DIR/$util_name/"
759 fi
760 fi
761 done
762 else
763 # Debug: Show what's not found
764 if [ "$util_name" = "ls" ] || [ "$util_name" = "cat" ]; then
765 echo "WARNING: No l10n directory found for $util_name at $l10n_util_dir"
766 fi
767 fi
768 done
769
770 # Debug: Show what was actually installed
771 echo "Files installed in locale directory:"
772 find "$LOCALE_DIR" -name "*.ftl" 2>/dev/null | head -10 || :
773
774 # Fallback: If no files were installed from l10n repo, try copying from main repo
775 if [ -z "$(find "$LOCALE_DIR" -name "*.ftl" 2>/dev/null)" ]; then
776 echo "No files found from l10n repo, trying fallback from main repository..."
777 for util_dir in src/uu/*/; do
778 util_name=$(basename "$util_dir")
779 if [ -d "$util_dir/locales" ]; then
780 echo "Copying locales for $util_name from main repo..."
781 mkdir -p "$LOCALE_DIR/$util_name"
782 cp "$util_dir/locales"/*.ftl "$LOCALE_DIR/$util_name/" 2>/dev/null || :
783 fi
784 done
785 echo "Files after fallback:"
786 find "$LOCALE_DIR" -name "*.ftl" 2>/dev/null | head -10 || :
787 fi
788
789 echo "✓ Additional locale files installed"
790 - name: Test French localization after cargo install
791 shell: bash
792 run: |
793 ## Test French localization with cargo-installed binary and downloaded locales
794 echo "Testing French localization with cargo-installed binary..."
795
796 # Set installation directories
797 CARGO_INSTALL_DIR="$PWD/cargo-install-dir"
798 LOCALE_DIR="$CARGO_INSTALL_DIR/share/locales"
799
800 echo "Checking installed binary..."
801 if ! "$CARGO_INSTALL_DIR/bin/coreutils" --version; then
802 echo "✗ coreutils binary not found"
803 exit 1
804 fi
805
806 echo "Checking locale files..."
807 echo "LOCALE_DIR is: $LOCALE_DIR"
808 echo "Checking if locale directory exists:"
809 ls -la "$LOCALE_DIR" 2>/dev/null || echo "Locale directory not found"
810 echo "Contents of locale directory:"
811 find "$LOCALE_DIR" -name "*.ftl" 2>/dev/null | head -10 || echo "No locale files found"
812 echo "Looking for ls locale files specifically:"
813 ls -la "$LOCALE_DIR/ls/" 2>/dev/null || echo "No ls locale directory"
814
815 # Test French localization
816 export LANG=fr_FR.UTF-8
817 export LC_ALL=fr_FR.UTF-8
818
819 echo "Testing ls --help with French locale..."
820 ls_help=$("$CARGO_INSTALL_DIR/bin/coreutils" ls --help 2>&1 || echo "Command failed")
821 echo "ls help output (first 10 lines):"
822 echo "$ls_help" | head -10
823
824 # Check for specific French strings from ls fr-FR.ftl
825 french_strings_found=0
826
827 if echo "$ls_help" | grep -q "Lister le contenu des répertoires"; then
828 echo "✓ Found French ls description: 'Lister le contenu des répertoires'"
829 french_strings_found=$((french_strings_found + 1))
830 fi
831
832 if echo "$ls_help" | grep -q "Afficher les informations d'aide"; then
833 echo "✓ Found French ls help text: 'Afficher les informations d'aide'"
834 french_strings_found=$((french_strings_found + 1))
835 fi
836
837 if echo "$ls_help" | grep -q "FICHIER"; then
838 echo "✓ Found French usage pattern: 'FICHIER'"
839 french_strings_found=$((french_strings_found + 1))
840 fi
841
842 echo "Testing cat --help with French locale..."
843 cat_help=$("$CARGO_INSTALL_DIR/bin/coreutils" cat --help 2>&1 || echo "Command failed")
844 echo "cat help output (first 5 lines):"
845 echo "$cat_help" | head -5
846
847 if echo "$cat_help" | grep -q "Concaténer"; then
848 echo "✓ Found French cat description containing: 'Concaténer'"
849 french_strings_found=$((french_strings_found + 1))
850 fi
851
852 echo "Testing error messages with French locale..."
853 error_output=$("$CARGO_INSTALL_DIR/bin/coreutils" ls /nonexistent_test_directory 2>&1 || echo "Expected error occurred")
854 echo "Error output: $error_output"
855
856 if echo "$error_output" | grep -q "impossible d'accéder à"; then
857 echo "✓ Found French error message: 'impossible d'accéder à'"
858 french_strings_found=$((french_strings_found + 1))
859 fi
860
861 # Verify the binary works in French locale
862 version_output=$("$CARGO_INSTALL_DIR/bin/coreutils" --version 2>&1)
863 if [ $? -eq 0 ]; then
864 echo "✓ Binary executes successfully with French locale"
865 echo "Version output: $version_output"
866 else
867 echo "✗ Binary failed to execute with French locale"
868 exit 1
869 fi
870
871 # Final validation
872 echo "French strings found: $french_strings_found"
873 if [ "$french_strings_found" -gt 0 ]; then
874 echo "✓ SUCCESS: French localization test passed after cargo install - found $french_strings_found French strings"
875 else
876 echo "✗ ERROR: No French strings detected with cargo-installed binary"
877 echo "This indicates an issue with locale loading from downloaded files"
878 exit 1
879 fi
880
881 echo "✓ French localization verification completed"
882
883 l10n_locale_support_verification:
884 name: L10n/Locale Support Verification
885 runs-on: ubuntu-latest
886 steps:
887 - uses: actions/[email protected]
888 with:
889 persist-credentials: false
890 - uses: Swatinem/rust-cache@v2
891 - name: Run sccache-cache
892 id: sccache-setup
893 uses: mozilla-actions/[email protected]
894 continue-on-error: true
895 - name: Export sccache
896 if: steps.sccache-setup.outcome == 'success'
897 run: |
898 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
899 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
900 - name: Install/setup prerequisites
901 shell: bash
902 run: |
903 ## Install/setup prerequisites including locale support
904 sudo apt-get -y update
905 sudo apt-get -y install libselinux1-dev
906
907 # Generate multiple locales for testing
908 sudo locale-gen --keep-existing en_US.UTF-8 fr_FR.UTF-8 de_DE.UTF-8 es_ES.UTF-8
909 locale -a | grep -E "(en_US|fr_FR|de_DE|es_ES)" || echo "Some locales may not be available"
910 - name: Install binaries with locale support
911 shell: bash
912 run: |
913 ## Install both multi-call and individual binaries using make
914 echo "Installing binaries with full locale support..."
915
916 # Create installation directory
917 INSTALL_DIR="$PWD/install-dir"
918 mkdir -p "$INSTALL_DIR"
919
920 # Build and install using make with DESTDIR
921 make FEATURES="feat_os_unix" PROFILE=release-small MULTICALL=y
922 make install DESTDIR="$INSTALL_DIR" PREFIX=/usr PROFILE=release-small MULTICALL=y
923
924 # Debug: Show what was installed
925 echo "Contents of installation directory:"
926 find "$INSTALL_DIR" -type f -name "coreutils" -o -name "ls" 2>/dev/null | head -20 || :
927 echo "Looking for binaries in: $INSTALL_DIR/usr/bin/"
928 ls -la "$INSTALL_DIR/usr/bin/" || echo "Directory not found"
929
930 echo "✓ Installation completed"
931 - name: Verify locale detection and startup
932 shell: bash
933 run: |
934 ## Test that installed binaries start correctly with different locales
935 echo "Testing locale detection and startup..."
936
937 # Set installation directory path
938 INSTALL_DIR="$PWD/install-dir"
939
940 # Test with different locales
941 locales_to_test=("C" "en_US.UTF-8" "fr_FR.UTF-8")
942
943 for locale in "${locales_to_test[@]}"; do
944 echo "Testing with locale: $locale"
945
946 # Test multi-call binary startup
947 if LC_ALL="$locale" "$INSTALL_DIR/usr/bin/coreutils" --version >/dev/null 2>&1; then
948 echo "✓ Multi-call binary starts successfully with locale: $locale"
949 else
950 echo "✗ Multi-call binary failed to start with locale: $locale"
951 exit 1
952 fi
953
954 # Test individual binary startup (if available)
955 if [ -f "$INSTALL_DIR/usr/bin/ls" ]; then
956 if LC_ALL="$locale" "$INSTALL_DIR/usr/bin/ls" --version >/dev/null 2>&1; then
957 echo "✓ Individual binary (ls) starts successfully with locale: $locale"
958 else
959 echo "✗ Individual binary (ls) failed to start with locale: $locale"
960 exit 1
961 fi
962 else
963 echo "Individual ls binary not found (multi-call only mode)"
964 fi
965
966 # Test that help text appears (even if not localized)
967 help_output=$(LC_ALL="$locale" "$INSTALL_DIR/usr/bin/coreutils" ls --help 2>&1)
968 if echo "$help_output" | grep -q -i "usage\|list"; then
969 echo "✓ Help text appears correctly with locale: $locale"
970 else
971 echo "✗ Help text missing or malformed with locale: $locale"
972 echo "Help output: $help_output"
973 exit 1
974 fi
975 done
976
977 echo "✓ All locale startup tests passed"
978 - name: Test locale-specific functionality
979 shell: bash
980 run: |
981 ## Test locale-specific behavior with installed binaries
982 echo "Testing locale-specific functionality..."
983
984 # Set installation directory path
985 INSTALL_DIR="$PWD/install-dir"
986
987 # Test with French locale (if available)
988 if locale -a | grep -q fr_FR.UTF-8; then
989 echo "Testing French locale functionality..."
990
991 export LANG=fr_FR.UTF-8
992 export LC_ALL=fr_FR.UTF-8
993
994 # Test that the program runs successfully with French locale
995 french_version_output=$("$INSTALL_DIR/usr/bin/coreutils" --version 2>&1)
996 if [ $? -eq 0 ]; then
997 echo "✓ Program runs successfully with French locale"
998 echo "Version output: $french_version_output"
999 else
1000 echo "✗ Program failed with French locale"
1001 echo "Error output: $french_version_output"
1002 exit 1
1003 fi
1004
1005 # Test basic functionality with French locale
1006 temp_file=$(mktemp)
1007 echo "test content" > "$temp_file"
1008
1009 if "$INSTALL_DIR/usr/bin/coreutils" cat "$temp_file" | grep -q "test content"; then
1010 echo "✓ Basic file operations work with French locale"
1011 else
1012 echo "✗ Basic file operations failed with French locale"
1013 exit 1
1014 fi
1015
1016 rm -f "$temp_file"
1017
1018 # Test that French translations are actually working
1019 echo "Testing French translations..."
1020 french_strings_found=0
1021
1022 echo "Testing ls --help with French locale..."
1023 ls_help=$("$INSTALL_DIR/usr/bin/coreutils" ls --help 2>&1 || echo "Command failed")
1024 echo "ls help output (first 10 lines):"
1025 echo "$ls_help" | head -10
1026
1027 # Check for actual French strings that appear in ls --help output
1028 if echo "$ls_help" | grep -q "Lister le contenu des répertoires"; then
1029 echo "✓ Found French ls description: 'Lister le contenu des répertoires'"
1030 french_strings_found=$((french_strings_found + 1))
1031 fi
1032 if echo "$ls_help" | grep -q "Ignorer les fichiers et répertoires commençant par"; then
1033 echo "✓ Found French explanation: 'Ignorer les fichiers et répertoires commençant par'"
1034 french_strings_found=$((french_strings_found + 1))
1035 fi
1036 if echo "$ls_help" | grep -q "Afficher les informations d'aide"; then
1037 echo "✓ Found French help text: 'Afficher les informations d'aide'"
1038 french_strings_found=$((french_strings_found + 1))
1039 fi
1040 if echo "$ls_help" | grep -q "FICHIER"; then
1041 echo "✓ Found French usage pattern: 'FICHIER'"
1042 french_strings_found=$((french_strings_found + 1))
1043 fi
1044 if echo "$ls_help" | grep -q "Définir le format d'affichage"; then
1045 echo "✓ Found French option description: 'Définir le format d'affichage'"
1046 french_strings_found=$((french_strings_found + 1))
1047 fi
1048
1049 echo "Testing cat --help with French locale..."
1050 cat_help=$("$INSTALL_DIR/usr/bin/coreutils" cat --help 2>&1 || echo "Command failed")
1051 echo "cat help output (first 5 lines):"
1052 echo "$cat_help" | head -5
1053
1054 # Check for French strings in cat help
1055 if echo "$cat_help" | grep -q "Concaténer"; then
1056 echo "✓ Found French cat description containing: 'Concaténer'"
1057 french_strings_found=$((french_strings_found + 1))
1058 fi
1059
1060 echo "Testing with error messages..."
1061 error_output=$("$INSTALL_DIR/usr/bin/coreutils" ls /nonexistent_directory_for_testing 2>&1 || echo "Expected error occurred")
1062 echo "Error output: $error_output"
1063
1064 # Check for French error messages
1065 if echo "$error_output" | grep -q "impossible d'accéder à"; then
1066 echo "✓ Found French error message: 'impossible d'accéder à'"
1067 french_strings_found=$((french_strings_found + 1))
1068 fi
1069 if echo "$error_output" | grep -q "Aucun fichier ou répertoire de ce type"; then
1070 echo "✓ Found French error text: 'Aucun fichier ou répertoire de ce type'"
1071 french_strings_found=$((french_strings_found + 1))
1072 fi
1073
1074 # Test version output
1075 echo "Testing --version with French locale..."
1076 version_output=$("$INSTALL_DIR/usr/bin/coreutils" --version 2>&1)
1077 echo "Version output: $version_output"
1078
1079 # Final validation - ensure we found at least some French strings
1080 echo "French strings found: $french_strings_found"
1081 if [ "$french_strings_found" -gt 0 ]; then
1082 echo "✓ SUCCESS: French locale translation test passed - found $french_strings_found French strings"
1083 else
1084 echo "✗ ERROR: No French strings were detected in installed binaries"
1085 echo "This indicates that French translations are not working properly with installed binaries"
1086 exit 1
1087 fi
1088 else
1089 echo "French locale not available, skipping French-specific tests"
1090 fi
1091
1092 # Test with standard build configuration
1093 echo "Testing standard build configuration..."
1094 cd "$GITHUB_WORKSPACE"
1095
1096 # Create separate installation directory for standard build
1097 STANDARD_BUILD_INSTALL_DIR="$PWD/standard-build-install-dir"
1098 mkdir -p "$STANDARD_BUILD_INSTALL_DIR"
1099
1100 # Clean and build standard version
1101 make clean
1102 make FEATURES="feat_os_unix" PROFILE=release-small MULTICALL=y
1103 make install DESTDIR="$STANDARD_BUILD_INSTALL_DIR" PREFIX=/usr PROFILE=release-small MULTICALL=y
1104
1105 # Verify standard build binary works
1106 if "$STANDARD_BUILD_INSTALL_DIR/usr/bin/coreutils" --version >/dev/null 2>&1; then
1107 echo "✓ Standard build works correctly"
1108 else
1109 echo "✗ Standard build failed"
1110 exit 1
1111 fi
1112
1113 echo "✓ All locale-specific functionality tests passed"
1114
1115 l10n_embedded_locale_regression_test:
1116 name: L10n/Embedded Locale Regression Test
1117 runs-on: ubuntu-latest
1118 steps:
1119 - uses: actions/[email protected]
1120 with:
1121 persist-credentials: false
1122 - uses: Swatinem/rust-cache@v2
1123 - name: Run sccache-cache
1124 id: sccache-setup
1125 uses: mozilla-actions/[email protected]
1126 continue-on-error: true
1127 - name: Export sccache
1128 if: steps.sccache-setup.outcome == 'success'
1129 run: |
1130 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
1131 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
1132 - name: Install/setup prerequisites
1133 shell: bash
1134 run: |
1135 sudo apt-get -y update && sudo apt-get -y install libselinux1-dev
1136 - name: Test embedded locale functionality for individual utilities
1137 shell: bash
1138 run: |
1139 bash util/test_locale_regression.sh
1140
1141 l10n_locale_embedding_cat:
1142 name: L10n/Locale Embedding - Cat Utility
1143 runs-on: ubuntu-latest
1144 steps:
1145 - uses: actions/[email protected]
1146 with:
1147 persist-credentials: false
1148 - uses: Swatinem/rust-cache@v2
1149 with:
1150 # Use different cache key for each build to avoid conflicts
1151 key: cat-locale-embedding
1152 - name: Install prerequisites
1153 run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev
1154 - name: Build cat with targeted locale embedding
1155 run: UUCORE_TARGET_UTIL=cat cargo build -p uu_cat --release
1156 - name: Verify cat locale count
1157 run: |
1158 locale_file=$(find target/release/build -name "embedded_locales.rs" | head -1)
1159 if [ -z "$locale_file" ]; then
1160 echo "ERROR: Could not find embedded_locales.rs"
1161 exit 1
1162 fi
1163 locale_count=$(grep -c '/en-US\.ftl' "$locale_file")
1164 echo "Cat binary has $locale_count embedded locales"
1165 if [ "$locale_count" -le 5 ]; then
1166 echo "✓ SUCCESS: Cat uses targeted locale embedding ($locale_count files)"
1167 else
1168 echo "✗ FAILURE: Cat has too many locale files ($locale_count). Expected ≤ 5"
1169 exit 1
1170 fi
1171
1172 l10n_locale_embedding_ls:
1173 name: L10n/Locale Embedding - Ls Utility
1174 runs-on: ubuntu-latest
1175 steps:
1176 - uses: actions/[email protected]
1177 with:
1178 persist-credentials: false
1179 - uses: Swatinem/rust-cache@v2
1180 with:
1181 # Use different cache key for each build to avoid conflicts
1182 key: ls-locale-embedding
1183 - name: Install prerequisites
1184 run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev
1185 - name: Build ls with targeted locale embedding
1186 run: UUCORE_TARGET_UTIL=ls cargo build -p uu_ls --release
1187 - name: Verify ls locale count
1188 run: |
1189 locale_file=$(find target/release/build -name "embedded_locales.rs" | head -1)
1190 if [ -z "$locale_file" ]; then
1191 echo "ERROR: Could not find embedded_locales.rs"
1192 exit 1
1193 fi
1194 locale_count=$(grep -c '/en-US\.ftl' "$locale_file")
1195 echo "Ls binary has $locale_count embedded locales"
1196 if [ "$locale_count" -le 5 ]; then
1197 echo "✓ SUCCESS: Ls uses targeted locale embedding ($locale_count files)"
1198 else
1199 echo "✗ FAILURE: Ls has too many locale files ($locale_count). Expected ≤ 5"
1200 exit 1
1201 fi
1202
1203 l10n_locale_embedding_multicall:
1204 name: L10n/Locale Embedding - Multicall Binary
1205 runs-on: ubuntu-latest
1206 steps:
1207 - uses: actions/[email protected]
1208 with:
1209 persist-credentials: false
1210 - uses: Swatinem/rust-cache@v2
1211 with:
1212 # Use different cache key for each build to avoid conflicts
1213 key: multicall-locale-embedding
1214 - name: Install prerequisites
1215 run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev
1216 - name: Build multicall binary with all locales
1217 run: cargo build --release
1218 - name: Verify multicall locale count
1219 run: |
1220 locale_file=$(find target/release/build -name "embedded_locales.rs" | head -1)
1221 if [ -z "$locale_file" ]; then
1222 echo "ERROR: Could not find embedded_locales.rs"
1223 exit 1
1224 fi
1225 locale_count=$(grep -c '/en-US\.ftl' "$locale_file")
1226 echo "Multicall binary has $locale_count embedded locales"
1227 echo "First 10 locales:"
1228 grep -o '[a-z_][a-z_0-9]*/en-US\.ftl' "$locale_file" | head -10
1229 if [ "$locale_count" -ge 80 ]; then
1230 echo "✓ SUCCESS: Multicall has all locales ($locale_count files)"
1231 else
1232 echo "✗ FAILURE: Multicall has too few locale files ($locale_count). Expected ≥ 80"
1233 exit 1
1234 fi
1235
1236 l10n_locale_embedding_cargo_install:
1237 name: L10n/Locale Embedding - Cargo Install
1238 runs-on: ubuntu-latest
1239 steps:
1240 - uses: actions/[email protected]
1241 with:
1242 persist-credentials: false
1243 - uses: Swatinem/rust-cache@v2
1244 with:
1245 key: cargo-install-locale-embedding
1246 - name: Run sccache-cache
1247 id: sccache-setup
1248 uses: mozilla-actions/[email protected]
1249 continue-on-error: true
1250 - name: Export sccache
1251 if: steps.sccache-setup.outcome == 'success'
1252 run: |
1253 echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
1254 echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
1255 - name: Install prerequisites
1256 run: |
1257 sudo apt-get -y update
1258 sudo apt-get -y install libselinux1-dev
1259 # Generate French locale for testing
1260 sudo locale-gen --keep-existing fr_FR.UTF-8
1261 locale -a | grep -i fr || exit 1
1262
1263 - name: Test English locale embedding (default)
1264 run: |
1265 export LANG=en_US.UTF-8
1266 export LC_ALL=en_US.UTF-8
1267
1268 echo "Building uu_yes with LANG=$LANG"
1269 cargo build --package uu_yes --release
1270
1271 # Find the generated embedded_locales.rs
1272 locale_file=$(find target/release/build -path "*/uu_yes-*/out/embedded_locales.rs" -o -path "*/uucore-*/out/embedded_locales.rs" | head -1)
1273 if [ -z "$locale_file" ]; then
1274 echo "ERROR: Could not find embedded_locales.rs"
1275 exit 1
1276 fi
1277
1278 echo "Found embedded_locales.rs at: $locale_file"
1279 echo "Checking embedded locales..."
1280
1281 # Should contain en-US
1282 if grep -q 'yes/en-US\.ftl' "$locale_file" || grep -q 'uucore/en-US\.ftl' "$locale_file"; then
1283 echo "✓ Found en-US locale (fallback)"
1284 else
1285 echo "✗ ERROR: en-US locale not found"
1286 exit 1
1287 fi
1288
1289 # Should NOT contain fr-FR when building with en_US.UTF-8
1290 if grep -q 'yes/fr-FR\.ftl' "$locale_file" || grep -q 'uucore/fr-FR\.ftl' "$locale_file"; then
1291 echo "✗ ERROR: Unexpectedly found fr-FR locale when LANG=en_US.UTF-8"
1292 exit 1
1293 else
1294 echo "✓ Correctly omitted fr-FR locale"
1295 fi
1296
1297 echo "✓ SUCCESS: English locale embedding working correctly"
1298
1299 - name: Test French locale embedding (system locale)
1300 run: |
1301 export LANG=fr_FR.UTF-8
1302 export LC_ALL=fr_FR.UTF-8
1303
1304 # Clean previous build to ensure fresh compile
1305 cargo clean -p uu_yes
1306 cargo clean -p uucore
1307
1308 echo "Building uu_yes with LANG=$LANG"
1309 cargo build --package uu_yes --release
1310
1311 # Find the generated embedded_locales.rs
1312 locale_file=$(find target/release/build -path "*/uu_yes-*/out/embedded_locales.rs" -o -path "*/uucore-*/out/embedded_locales.rs" | head -1)
1313 if [ -z "$locale_file" ]; then
1314 echo "ERROR: Could not find embedded_locales.rs"
1315 exit 1
1316 fi
1317
1318 echo "Found embedded_locales.rs at: $locale_file"
1319 echo "Checking embedded locales..."
1320
1321 # Should contain en-US (fallback)
1322 if grep -q 'yes/en-US\.ftl' "$locale_file" || grep -q 'uucore/en-US\.ftl' "$locale_file"; then
1323 echo "✓ Found en-US locale (fallback)"
1324 else
1325 echo "✗ ERROR: en-US locale not found"
1326 exit 1
1327 fi
1328
1329 # Should contain fr-FR when building with fr_FR.UTF-8
1330 if grep -q 'yes/fr-FR\.ftl' "$locale_file" || grep -q 'uucore/fr-FR\.ftl' "$locale_file"; then
1331 echo "✓ Found fr-FR locale (system locale from LANG)"
1332 else
1333 echo "Note: fr-FR locale not found - this is expected if French translation doesn't exist yet"
1334 echo "::notice::French locale for 'yes' utility may not be available"
1335 fi
1336
1337 echo "✓ SUCCESS: System locale detection working correctly"
1338
1339 - name: Test locale count is reasonable
1340 run: |
1341 export LANG=fr_FR.UTF-8
1342 cargo clean -p uu_yes
1343 cargo build --package uu_yes --release
1344
1345 locale_file=$(find target/release/build -path "*/uucore-*/out/embedded_locales.rs" | head -1)
1346 if [ -z "$locale_file" ]; then
1347 echo "ERROR: Could not find uucore embedded_locales.rs"
1348 exit 1
1349 fi
1350
1351 # Count embedded locales (should be en-US + system locale, not all locales)
1352 locale_count=$(grep -c '/en-US\.ftl\|/fr-FR\.ftl' "$locale_file" || echo "0")
1353 echo "uu_yes has $locale_count embedded locale entries for yes utility"
1354
1355 # For a single utility build, should have minimal locales (en-US + optionally system locale)
1356 # Not the full multicall set
1357 total_match_count=$(grep -c '=> Some(r###' "$locale_file" || echo "0")
1358 echo "Total embedded entries: $total_match_count"
1359
1360 if [ "$total_match_count" -le 10 ]; then
1361 echo "✓ SUCCESS: Locale embedding is targeted ($total_match_count entries)"
1362 else
1363 echo "::warning::More locales than expected ($total_match_count entries)"
1364 echo "This might be expected for utility + uucore locales"
1365 fi