Skip to content

Commit 97cc151

Browse files
authored
Merge branch 'culture/release' into culture/germany
2 parents d4ee1d2 + 402064a commit 97cc151

5 files changed

Lines changed: 49 additions & 15 deletions

File tree

.github/workflows/validate.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ jobs:
586586
needs: [setup, L4e-hofstede-alignment]
587587
if: needs.setup.outputs.any == 'true'
588588
runs-on: ubuntu-latest
589+
env:
590+
PR_CHANGED_FILES: ${{ needs.setup.outputs.files }}
589591
steps:
590592
- uses: actions/checkout@v4
591593
- name: Set up Python
@@ -602,6 +604,9 @@ jobs:
602604
needs: [setup, L4f-hofstede-derived]
603605
if: needs.setup.outputs.any == 'true' || needs.setup.outputs.data_changed == 'true'
604606
runs-on: ubuntu-latest
607+
env:
608+
PR_CHANGED_FILES: ${{ needs.setup.outputs.files }}
609+
PR_DATA_CHANGED: ${{ needs.setup.outputs.data_changed }}
605610
steps:
606611
- uses: actions/checkout@v4
607612
- name: Set up Python
@@ -654,4 +659,3 @@ jobs:
654659
runs-on: ubuntu-latest
655660
steps:
656661
- run: echo "No regions/*.md files changed - skipping validation"
657-

scripts/update_hofstede_readme.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ def compute_status(declared: int, derived: int) -> tuple[int, str]:
238238

239239
def _status_emoji(status: str) -> str:
240240
return {
241-
"EXCELLENT": "OK",
242-
"PASS": "OK",
243-
"WARN": "WARN",
244-
"FAIL": "FAIL",
241+
"EXCELLENT": "",
242+
"PASS": "",
243+
"WARN": "⚠️",
244+
"FAIL": "",
245245
}[status]
246246

247247

tests/test_hofstede_derived.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""L4f: Derived Hofstede scores vs declared — keyword scoring across all culture files."""
2+
import os
23
import re
34
import sys
45
import warnings
@@ -67,6 +68,20 @@ def _derived(country_dir: Path, language: str) -> dict[str, int]:
6768

6869
_COUNTRIES = _country_dirs()
6970

71+
# Narrow to PR-changed countries when CI is running on a PR. Env vars are
72+
# set by the L4f job in .github/workflows/validate.yml; absent on push events
73+
# or local runs, which keeps the full corpus in scope. A Denmark-only
74+
# deviation shouldn't fail a Germany PR's CI.
75+
_pr_changed = os.environ.get("PR_CHANGED_FILES", "").strip()
76+
_pr_data_changed = os.environ.get("PR_DATA_CHANGED", "").strip().lower() == "true"
77+
if _pr_changed and not _pr_data_changed:
78+
_pr_slugs = {
79+
p.split("/")[2]
80+
for p in _pr_changed.split()
81+
if p.startswith("regions/") and len(p.split("/")) >= 4
82+
}
83+
_COUNTRIES = [d for d in _COUNTRIES if d.name in _pr_slugs]
84+
7085

7186
@pytest.mark.parametrize("country_dir", _COUNTRIES, ids=[c.name for c in _COUNTRIES])
7287
def test_derived_within_tolerance(country_dir: Path):

tests/test_hofstede_reference.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from __future__ import annotations
1212

1313
import json
14+
import os
1415
import re
1516
from pathlib import Path
1617

@@ -70,6 +71,20 @@ def _justified_dims(decisions_text: str) -> set[str]:
7071
_REFERENCE = _load_reference()
7172
_COUNTRIES = _country_dirs()
7273

74+
# Narrow to PR-changed countries when CI is running on a PR. Env vars are
75+
# set by the L4g job in .github/workflows/validate.yml; absent on push events
76+
# or local runs, which keeps the full corpus in scope. PR_DATA_CHANGED=true
77+
# (the reference table itself moved) overrides and re-checks every country.
78+
_pr_changed = os.environ.get("PR_CHANGED_FILES", "").strip()
79+
_pr_data_changed = os.environ.get("PR_DATA_CHANGED", "").strip().lower() == "true"
80+
if _pr_changed and not _pr_data_changed:
81+
_pr_slugs = {
82+
p.split("/")[2]
83+
for p in _pr_changed.split()
84+
if p.startswith("regions/") and len(p.split("/")) >= 4
85+
}
86+
_COUNTRIES = [d for d in _COUNTRIES if d.name in _pr_slugs]
87+
7388

7489
@pytest.mark.parametrize("country_dir", _COUNTRIES, ids=[c.name for c in _COUNTRIES])
7590
def test_declared_scores_match_reference(country_dir: Path):

tests/test_update_hofstede_readme.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,19 @@ def test_status_per_dimension(self):
161161
declared = {"PDI": 35, "IDV": 67, "UAI": 65, "MAS": 66, "LTO": 83, "IND": 40}
162162
derived = {"PDI": 33, "IDV": 75, "UAI": 66, "MAS": 60, "LTO": 87, "IND": 33}
163163
out = upd.render_alignment_table(declared, derived)
164-
assert "| PDI | 35 | 33 | 2 | OK EXCELLENT |" in out
165-
assert "| IDV | 67 | 75 | 8 | OK PASS |" in out
166-
assert "| UAI | 65 | 66 | 1 | OK EXCELLENT |" in out
167-
assert "| MAS | 66 | 60 | 6 | OK PASS |" in out
168-
assert "| LTO | 83 | 87 | 4 | OK EXCELLENT |" in out
169-
assert "| IND | 40 | 33 | 7 | OK PASS |" in out
164+
assert "| PDI | 35 | 33 | 2 | EXCELLENT |" in out
165+
assert "| IDV | 67 | 75 | 8 | PASS |" in out
166+
assert "| UAI | 65 | 66 | 1 | EXCELLENT |" in out
167+
assert "| MAS | 66 | 60 | 6 | PASS |" in out
168+
assert "| LTO | 83 | 87 | 4 | EXCELLENT |" in out
169+
assert "| IND | 40 | 33 | 7 | PASS |" in out
170170

171171
def test_warn_and_fail_surface(self):
172172
declared = {"PDI": 50, "IDV": 50}
173173
derived = {"PDI": 65, "IDV": 90}
174174
out = upd.render_alignment_table(declared, derived)
175-
assert "WARN WARN" in out # 50 vs 65 -> gap 15 -> WARN
176-
assert "FAIL FAIL" in out # 50 vs 90 -> gap 40 -> FAIL
175+
assert "⚠️ WARN" in out # 50 vs 65 -> gap 15 -> WARN
176+
assert " FAIL" in out # 50 vs 90 -> gap 40 -> FAIL
177177

178178
def test_missing_derived_marks_na(self):
179179
declared = {"PDI": 35}
@@ -235,7 +235,7 @@ def test_replaces_both_tables(self):
235235
assert "**High** - DRIFTED" not in new_text
236236
assert "| Individualism (IDV) | 67 | **Moderate**" in new_text
237237
# Alignment table updated with new derived value
238-
assert "| PDI | 35 | 33 | 2 | OK EXCELLENT |" in new_text
238+
assert "| PDI | 35 | 33 | 2 | EXCELLENT |" in new_text
239239
# OLD EXCELLENT label removed (was wrong format)
240240
assert "OLD EXCELLENT" not in new_text
241241

@@ -279,7 +279,7 @@ def test_alignment_only_when_dimensions_missing(self):
279279
text, "X", {"PDI": 35}, {"PDI": 33},
280280
)
281281
# Alignment table updated
282-
assert "| PDI | 35 | 33 | 2 | OK EXCELLENT |" in new_text
282+
assert "| PDI | 35 | 33 | 2 | EXCELLENT |" in new_text
283283
# Cultural Dimensions heading missing -> one warning
284284
assert len(warnings) == 1
285285
assert "Cultural Dimensions" in warnings[0]

0 commit comments

Comments
 (0)