Skip to content

Commit 5d08a14

Browse files
committed
CI: unbreak the l10n job
1 parent 68ac2dd commit 5d08a14

File tree

2 files changed

+84
-119
lines changed

2 files changed

+84
-119
lines changed

.github/workflows/l10n.yml

Lines changed: 81 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,146 +1147,108 @@ jobs:
11471147
run: |
11481148
bash util/test_locale_regression.sh
11491149
1150-
l10n_locale_embedding_regression_test:
1151-
name: L10n/Locale Embedding Regression Test
1150+
l10n_locale_embedding_cat:
1151+
name: L10n/Locale Embedding - Cat Utility
11521152
runs-on: ubuntu-latest
1153-
env:
1154-
SCCACHE_GHA_ENABLED: "true"
1155-
RUSTC_WRAPPER: "sccache"
11561153
steps:
11571154
- uses: actions/checkout@v5
11581155
with:
11591156
persist-credentials: false
11601157
- uses: dtolnay/rust-toolchain@stable
11611158
- uses: Swatinem/rust-cache@v2
1162-
- name: Run sccache-cache
1163-
uses: mozilla-actions/[email protected]
1164-
- name: Install/setup prerequisites
1165-
shell: bash
1166-
run: |
1167-
## Install/setup prerequisites
1168-
sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev build-essential
1169-
- name: Build binaries for locale embedding test
1170-
shell: bash
1171-
run: |
1172-
## Build individual utilities and multicall binary for locale embedding test
1173-
echo "Building binaries with different locale embedding configurations..."
1174-
mkdir -p target
1175-
1176-
# Build cat utility with targeted locale embedding
1177-
echo "Building cat utility with targeted locale embedding..."
1178-
echo "cat" > target/uucore_target_util.txt
1179-
cargo build -p uu_cat --release
1180-
1181-
# Build ls utility with targeted locale embedding
1182-
echo "Building ls utility with targeted locale embedding..."
1183-
echo "ls" > target/uucore_target_util.txt
1184-
cargo build -p uu_ls --release
1185-
1186-
# Build multicall binary (should have all locales)
1187-
echo "Building multicall binary (should have all locales)..."
1188-
echo "multicall" > target/uucore_target_util.txt
1189-
cargo build --release
1190-
1191-
echo "✓ All binaries built successfully"
1192-
env:
1193-
RUST_BACKTRACE: "1"
1194-
1195-
- name: Analyze embedded locale files
1196-
shell: bash
1159+
with:
1160+
# Use different cache key for each build to avoid conflicts
1161+
key: cat-locale-embedding
1162+
- name: Install prerequisites
1163+
run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev build-essential
1164+
- name: Build cat with targeted locale embedding
1165+
run: UUCORE_TARGET_UTIL=cat cargo build -p uu_cat --release
1166+
- name: Verify cat locale count
11971167
run: |
1198-
## Extract and analyze .ftl files embedded in each binary
1199-
echo "=== Embedded Locale File Analysis ==="
1200-
1201-
# Analyze cat binary
1202-
echo "--- cat binary embedded .ftl files ---"
1203-
cat_ftl_files=$(strings target/release/cat | grep -o "[a-z_][a-z_]*/en-US\.ftl" | sort | uniq)
1204-
cat_locales=$(echo "$cat_ftl_files" | wc -l)
1205-
if [ -n "$cat_ftl_files" ]; then
1206-
echo "$cat_ftl_files"
1207-
else
1208-
echo "(no locale keys found)"
1209-
fi
1210-
echo "Total: $cat_locales files"
1211-
echo
1212-
1213-
# Analyze ls binary
1214-
echo "--- ls binary embedded .ftl files ---"
1215-
ls_ftl_files=$(strings target/release/ls | grep -o "[a-z_][a-z_]*/en-US\.ftl" | sort | uniq)
1216-
ls_locales=$(echo "$ls_ftl_files" | wc -l)
1217-
if [ -n "$ls_ftl_files" ]; then
1218-
echo "$ls_ftl_files"
1219-
else
1220-
echo "(no locale keys found)"
1168+
locale_file=$(find target/release/build -name "embedded_locales.rs" | head -1)
1169+
if [ -z "$locale_file" ]; then
1170+
echo "ERROR: Could not find embedded_locales.rs"
1171+
exit 1
12211172
fi
1222-
echo "Total: $ls_locales files"
1223-
echo
1224-
1225-
# Analyze multicall binary
1226-
echo "--- multicall binary embedded .ftl files (first 10) ---"
1227-
multi_ftl_files=$(strings target/release/coreutils | grep -o "[a-z_][a-z_]*/en-US\.ftl" | sort | uniq)
1228-
multi_locales=$(echo "$multi_ftl_files" | wc -l)
1229-
if [ -n "$multi_ftl_files" ]; then
1230-
echo "$multi_ftl_files" | head -10
1231-
echo "... (showing first 10 of $multi_locales total files)"
1173+
locale_count=$(grep -c '/en-US\.ftl' "$locale_file")
1174+
echo "Cat binary has $locale_count embedded locales"
1175+
if [ "$locale_count" -le 5 ]; then
1176+
echo "✓ SUCCESS: Cat uses targeted locale embedding ($locale_count files)"
12321177
else
1233-
echo "(no locale keys found)"
1178+
echo "✗ FAILURE: Cat has too many locale files ($locale_count). Expected ≤ 5"
1179+
exit 1
12341180
fi
1235-
echo
1236-
1237-
# Store counts for validation step
1238-
echo "cat_locales=$cat_locales" >> $GITHUB_ENV
1239-
echo "ls_locales=$ls_locales" >> $GITHUB_ENV
1240-
echo "multi_locales=$multi_locales" >> $GITHUB_ENV
12411181
1242-
- name: Validate cat binary locale embedding
1243-
shell: bash
1182+
l10n_locale_embedding_ls:
1183+
name: L10n/Locale Embedding - Ls Utility
1184+
runs-on: ubuntu-latest
1185+
steps:
1186+
- uses: actions/checkout@v5
1187+
with:
1188+
persist-credentials: false
1189+
- uses: dtolnay/rust-toolchain@stable
1190+
- uses: Swatinem/rust-cache@v2
1191+
with:
1192+
# Use different cache key for each build to avoid conflicts
1193+
key: ls-locale-embedding
1194+
- name: Install prerequisites
1195+
run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev build-essential
1196+
- name: Build ls with targeted locale embedding
1197+
run: UUCORE_TARGET_UTIL=ls cargo build -p uu_ls --release
1198+
- name: Verify ls locale count
12441199
run: |
1245-
## Validate that cat binary only embeds its own locale files
1246-
echo "Validating cat binary locale embedding..."
1247-
if [ "$cat_locales" -le 5 ]; then
1248-
echo "✓ SUCCESS: cat binary uses targeted locale embedding ($cat_locales files)"
1249-
else
1250-
echo "✗ FAILURE: cat binary has too many embedded locale files ($cat_locales). Expected ≤ 5."
1251-
echo "This indicates LOCALE EMBEDDING REGRESSION - all locales are being embedded instead of just the target utility's locale."
1252-
echo "The optimization is not working correctly!"
1200+
locale_file=$(find target/release/build -name "embedded_locales.rs" | head -1)
1201+
if [ -z "$locale_file" ]; then
1202+
echo "ERROR: Could not find embedded_locales.rs"
12531203
exit 1
12541204
fi
1255-
1256-
- name: Validate ls binary locale embedding
1257-
shell: bash
1258-
run: |
1259-
## Validate that ls binary only embeds its own locale files
1260-
echo "Validating ls binary locale embedding..."
1261-
if [ "$ls_locales" -le 5 ]; then
1262-
echo "✓ SUCCESS: ls binary uses targeted locale embedding ($ls_locales files)"
1205+
locale_count=$(grep -c '/en-US\.ftl' "$locale_file")
1206+
echo "Ls binary has $locale_count embedded locales"
1207+
if [ "$locale_count" -le 5 ]; then
1208+
echo "✓ SUCCESS: Ls uses targeted locale embedding ($locale_count files)"
12631209
else
1264-
echo "✗ FAILURE: ls binary has too many embedded locale files ($ls_locales). Expected ≤ 5."
1265-
echo "This indicates LOCALE EMBEDDING REGRESSION - all locales are being embedded instead of just the target utility's locale."
1266-
echo "The optimization is not working correctly!"
1210+
echo "✗ FAILURE: Ls has too many locale files ($locale_count). Expected ≤ 5"
12671211
exit 1
12681212
fi
12691213
1270-
- name: Validate multicall binary locale embedding
1271-
shell: bash
1214+
l10n_locale_embedding_multicall:
1215+
name: L10n/Locale Embedding - Multicall Binary
1216+
runs-on: ubuntu-latest
1217+
steps:
1218+
- uses: actions/checkout@v5
1219+
with:
1220+
persist-credentials: false
1221+
- uses: dtolnay/rust-toolchain@stable
1222+
- uses: Swatinem/rust-cache@v2
1223+
with:
1224+
# Use different cache key for each build to avoid conflicts
1225+
key: multicall-locale-embedding
1226+
- name: Install prerequisites
1227+
run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev build-essential
1228+
- name: Build multicall binary with all locales
1229+
run: cargo build --release
1230+
- name: Verify multicall locale count
12721231
run: |
1273-
## Validate that multicall binary embeds all utility locale files
1274-
echo "Validating multicall binary locale embedding..."
1275-
if [ "$multi_locales" -ge 80 ]; then
1276-
echo "✓ SUCCESS: multicall binary has all locales ($multi_locales files)"
1232+
locale_file=$(find target/release/build -name "embedded_locales.rs" | head -1)
1233+
if [ -z "$locale_file" ]; then
1234+
echo "ERROR: Could not find embedded_locales.rs"
1235+
exit 1
1236+
fi
1237+
locale_count=$(grep -c '/en-US\.ftl' "$locale_file")
1238+
echo "Multicall binary has $locale_count embedded locales"
1239+
echo "First 10 locales:"
1240+
grep -o '[a-z_][a-z_0-9]*/en-US\.ftl' "$locale_file" | head -10
1241+
if [ "$locale_count" -ge 80 ]; then
1242+
echo "✓ SUCCESS: Multicall has all locales ($locale_count files)"
12771243
else
1278-
echo "✗ FAILURE: multicall binary has too few embedded locale files ($multi_locales). Expected ≥ 80."
1279-
echo "This indicates the multicall binary is not getting all required locales."
1244+
echo "✗ FAILURE: Multicall has too few locale files ($locale_count). Expected ≥ 80"
12801245
exit 1
12811246
fi
12821247
1283-
- name: Finalize locale embedding tests
1284-
shell: bash
1285-
run: |
1286-
## Clean up and report overall test results
1287-
rm -f test.txt target/uucore_target_util.txt
1288-
echo "✓ All locale embedding regression tests passed"
1289-
echo "Summary:"
1290-
echo " - cat binary: $cat_locales locale files (targeted embedding)"
1291-
echo " - ls binary: $ls_locales locale files (targeted embedding)"
1292-
echo " - multicall binary: $multi_locales locale files (full embedding)"
1248+
l10n_locale_embedding_regression_test:
1249+
name: L10n/Locale Embedding Regression Test
1250+
runs-on: ubuntu-latest
1251+
needs: [l10n_locale_embedding_cat, l10n_locale_embedding_ls, l10n_locale_embedding_multicall]
1252+
steps:
1253+
- name: All locale embedding tests passed
1254+
run: echo "✓ All locale embedding tests passed successfully"

src/uucore/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ fn project_root() -> Result<std::path::PathBuf, Box<dyn std::error::Error>> {
6969
fn detect_target_utility() -> Option<String> {
7070
use std::fs;
7171

72+
// Tell Cargo to rerun if this environment variable changes
73+
println!("cargo:rerun-if-env-changed=UUCORE_TARGET_UTIL");
74+
7275
// First check if an explicit environment variable was set
7376
if let Ok(target_util) = env::var("UUCORE_TARGET_UTIL") {
7477
if !target_util.is_empty() {

0 commit comments

Comments
 (0)