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