Skip to content

Commit e9887c8

Browse files
committed
Merge main
2 parents fc2f65f + 8466fb2 commit e9887c8

35 files changed

+515
-2799
lines changed

.github/workflows/check-beta.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
outputs:
1515
win_reportable: ${{ steps.reportable.outputs.win }}
1616
mac_reportable: ${{ steps.reportable.outputs.mac }}
17+
mac_l10n_reportable: ${{ steps.reportable.outputs.mac_l10n }}
1718
steps:
1819
- name: Checkout repository
1920
uses: actions/checkout@v4
@@ -29,6 +30,16 @@ jobs:
2930
pipenv install
3031
echo win=$(pipenv run python -c 'from modules import testrail_integration as tri; print(tri.reportable("Windows"))') >> "$GITHUB_OUTPUT"
3132
echo mac=$(pipenv run python -c 'from modules import testrail_integration as tri; print(tri.reportable("Darwin"))') >> "$GITHUB_OUTPUT"
33+
- name: Check if the l10n run is reportable
34+
id: l10n-reportable
35+
env:
36+
TESTRAIL_REPORT: true
37+
FX_L10N: true
38+
TESTRAIL_BASE_URL: ${{ secrets.TESTRAIL_BASE_URL }}
39+
TESTRAIL_API_KEY: ${{ secrets.TESTRAIL_API_KEY }}
40+
TESTRAIL_USERNAME: ${{ secrets.TESTRAIL_USERNAME }}
41+
run: echo mac_l10n=$(pipenv run python -c 'from modules import testrail_integration as tri; print(tri.reportable("Darwin"))') >> "$GITHUB_OUTPUT"
42+
3243
Run-Win-Smoke:
3344
needs: Check-Beta-Version
3445
if: ${{ needs.Check-Beta-Version.outputs.win_reportable == 'True' }}
@@ -44,3 +55,11 @@ jobs:
4455
with:
4556
job_to_run: Smoke-MacOS
4657
secrets: inherit
58+
59+
Run-L10N-Mac-Smoke:
60+
needs: Check-Beta-Version
61+
if: ${{ needs.Check-Beta-Version.outputs.mac_l10n_reportable == 'True' }}
62+
uses: ./.github/workflows/l10n_smoke.yml
63+
with:
64+
job_to_run: L10N-MacOS
65+
secrets: inherit

.github/workflows/l10n.yml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
name: L10N Test Execution
3+
4+
run-name: ${{ github.actor }} is running l10n tests
5+
on:
6+
pull_request:
7+
workflow_call:
8+
inputs:
9+
channel:
10+
description: "Channel to run tests against"
11+
default: "beta"
12+
type: string
13+
required: false
14+
job_to_run:
15+
required: true
16+
type: string
17+
workflow_dispatch:
18+
inputs:
19+
mac_installer_link:
20+
description: 'The link to the macOS installer for the Fx under test'
21+
required: false
22+
type: string
23+
env:
24+
FX_CHANNEL: ${{ inputs.channel }}
25+
TESTRAIL_BASE_URL: ${{ secrets.TESTRAIL_BASE_URL }}
26+
TESTRAIL_API_KEY: ${{ secrets.TESTRAIL_API_KEY }}
27+
TESTRAIL_USERNAME: ${{ secrets.TESTRAIL_USERNAME }}
28+
SVC_ACCT_DECRYPT: ${{ secrets.SVC_ACCT_DECRYPT }}
29+
FX_L10N: 'true'
30+
31+
jobs:
32+
L10N-MacOS:
33+
if: ${{ inputs.job_to_run == 'L10N-MacOS' || github.event_name == 'pull_request' || inputs.mac_installer_link }}
34+
runs-on: macos-latest
35+
steps:
36+
- name: Create app token
37+
uses: actions/create-github-app-token@v1
38+
id: app-token
39+
with:
40+
app-id: ${{ secrets.BOT_CLIENT_ID }}
41+
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
with:
45+
token: ${{ steps.app-token.outputs.token }}
46+
- name: Set up Python 3.11
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: "3.11"
50+
- name: Check test case numbers
51+
run: |
52+
python check_test_cases.py
53+
exit $?
54+
echo "Triggered by event: ${{ github.event_name }}"
55+
- name: Set Environment (Scheduled Beta)
56+
if: ${{ inputs.job_to_run == 'L10N-MacOS' }}
57+
run: |
58+
echo "TESTRAIL_REPORT='true'" >> "$GITHUB_ENV";
59+
echo "Running report for most recent Beta on MacOS";
60+
- name: Set Environment (Manual)
61+
if: ${{ inputs.mac_installer_link }}
62+
run: |
63+
echo "MANUAL='true'" >> "$GITHUB_ENV";
64+
echo "Running l10n tests on supplied executable";
65+
- name: Install dependencies
66+
run: |
67+
mkdir -p artifacts/;
68+
pip3 install 'pipenv==2023.11.15';
69+
pip3 install 'ruff>=0.4.8,<0.5';
70+
rm ./pyproject.toml;
71+
mv ./ci_pyproject.toml ./pyproject.toml;
72+
pipenv install
73+
- name: Install Fx
74+
id: setup
75+
env:
76+
MANUAL_DOWNLOAD_LINK: ${{ inputs.mac_installer_link }}
77+
run:
78+
echo app_name=$(bash ./collect_executables.sh | xargs -0 ./parse_executables.sh) >> "$GITHUB_OUTPUT"
79+
- name: Run L10N Tests in MacOS
80+
if: steps.setup.conclusion == 'success'
81+
env:
82+
FX_EXECUTABLE: /Volumes/${{ steps.setup.outputs.app_name }}/${{ steps.setup.outputs.app_name }}.app/Contents/MacOS/firefox
83+
run: |
84+
"$FX_EXECUTABLE" --version
85+
echo "0" > TEST_EXIT_CODE
86+
pipenv run python check_l10n_test_cases.py
87+
while IFS= read -r line; do
88+
echo "Running tests for: $line"
89+
pipenv run python l10n_CM/run_l10n.py --fx-executable="$FX_EXECUTABLE" $line || SCRIPT_EXIT_CODE=$?
90+
done < selected_l10n_mappings
91+
mv artifacts artifacts-mac || true
92+
EXIT_CODE=$(cat TEST_EXIT_CODE)
93+
if [ $EXIT_CODE != 0 ]; then
94+
exit $EXIT_CODE
95+
fi
96+
exit $SCRIPT_EXIT_CODE
97+
- name: Run L10N Tests in MacOS (Headed)
98+
if: steps.setup.conclusion == 'success' && always()
99+
env:
100+
FX_EXECUTABLE: /Volumes/${{ steps.setup.outputs.app_name }}/${{ steps.setup.outputs.app_name }}.app/Contents/MacOS/firefox
101+
REPORTABLE: ${{ env.TESTRAIL_REPORT == 'true' }}
102+
run: |
103+
mv ./ci_l10n_pyproject_headed.toml ./pyproject.toml;
104+
echo "0" > TEST_EXIT_CODE
105+
pipenv run python check_l10n_test_cases.py
106+
while IFS= read -r line; do
107+
echo "Running tests for: $line"
108+
pipenv run python l10n_CM/run_l10n.py --fx-executable="$FX_EXECUTABLE" $line || SCRIPT_EXIT_CODE=$?
109+
done < selected_l10n_mappings
110+
mv -n artifacts/* artifacts-mac/ || true
111+
EXIT_CODE=$(cat TEST_EXIT_CODE)
112+
if [ $EXIT_CODE != 0 ]; then
113+
exit $EXIT_CODE
114+
fi
115+
exit $SCRIPT_EXIT_CODE
116+
- name: Upload artifacts
117+
if: ${{ always() && github.event_name == 'pull_request' }}
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: artifacts-mac
121+
path: artifacts-mac
122+
Use-Artifacts:
123+
if: ${{ github.event_name != 'workflow_dispatch' }}
124+
runs-on: ubuntu-latest
125+
needs:
126+
- L10N-MacOS
127+
steps:
128+
- name: Checkout repository
129+
uses: actions/checkout@v4
130+
- name: Set up Python 3.11
131+
uses: actions/setup-python@v5
132+
with:
133+
python-version: "3.11"
134+
- name: Install dependencies
135+
run: |
136+
pip3 install 'pipenv==2023.11.15'
137+
pipenv install
138+
- name: Download MacOS artifact
139+
uses: actions/download-artifact@v4
140+
with:
141+
name: artifacts-mac
142+
path: artifacts-mac
143+
- name: List downloaded MacOS files
144+
run: ls artifacts-mac/
145+
- name: Run script with secret
146+
env:
147+
SLACK_KEY: ${{ secrets.SLACK_KEY }}
148+
GCP_CREDENTIAL: ${{ secrets.GCP_CREDENTIAL }}
149+
GITHUB_SHA: ${{ github.sha }}
150+
GITHUB_RUN_ID: ${{ github.run_id }}
151+
GITHUB_ACTOR: ${{ github.actor }}
152+
GITHUB_REF_NAME: ${{ github.ref_name }}
153+
run: |
154+
pipenv run python notifier.py

check_l10n_test_cases.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import json
2+
import os
3+
import sys
4+
from collections import defaultdict
5+
6+
OUTPUT_FILE = "selected_l10n_mappings"
7+
8+
9+
def valid_l10n_mappings():
10+
mapping = defaultdict(set)
11+
region_paths = [d for d in os.listdir("./l10n_CM/region/")]
12+
for region_path in region_paths:
13+
if region_path != "Unified.json":
14+
region = region_path.split(".")[0]
15+
with open(f"./l10n_CM/region/{region_path}", "r+") as f:
16+
region_file = json.load(f)
17+
if region_file.get("sites"):
18+
for site in region_file.get("sites"):
19+
mapping[site].add(region)
20+
return mapping
21+
22+
23+
if __name__ == "__main__":
24+
l10n_mappings = valid_l10n_mappings()
25+
with open(OUTPUT_FILE, "w") as file:
26+
pass # File is created or cleared
27+
for site, regions in l10n_mappings.items():
28+
with open(OUTPUT_FILE, "a+") as fh:
29+
fh.write(f"{site} {' '.join(regions)}\n")
30+
sys.exit(0)

choose_ci_set.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ def dedupe(run_list: list, slash: str) -> list:
9393
for j, entry_b in enumerate(run_list):
9494
if i == j:
9595
continue
96-
candidate = max((i, j))
97-
if entry_a in entry_b and candidate not in removes:
98-
removes.append(candidate)
96+
candidate = max((entry_a, entry_b))
97+
cand_index = run_list.index(candidate)
98+
if entry_a in entry_b and cand_index not in removes:
99+
removes.append(cand_index)
99100

100101
removes.sort(reverse=True)
101102
for remove in removes:
@@ -228,6 +229,8 @@ def dedupe(run_list: list, slash: str) -> list:
228229
run_list.extend(ci_paths)
229230

230231
# Dedupe just in case
232+
if slash == "\\":
233+
run_list = [entry.replace("/", slash) for entry in run_list]
231234
run_list = dedupe(run_list, slash)
232235
run_list = [entry for entry in run_list if os.path.exists(entry.split("::")[0])]
233236
with open(OUTPUT_FILE, "w") as fh:

ci_l10n_pyproject_headed.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[tool.pytest.ini_options]
2+
generate_report_on_test = true
3+
log_cli = true
4+
log_cli_level = "warn"
5+
markers = [
6+
"audio: test is reliant on audio",
7+
"headed: test must run in headed mode (e.g. uses pynput)",
8+
"incident: incident smoke tests",
9+
"unstable: temporary mark for unstable tests",
10+
"slow: test is clocked at more than 30s on modern machines",
11+
"ci: basic tests to run in ci",
12+
"locale_de: tests run in DE locale versions",
13+
"locale_fr: tests run in FR locale versions",
14+
"locale_gb: tests run in GB locale versions",
15+
"noxvfb: tests that should not run in xvfb sessions"
16+
]
17+
18+
addopts = "-vs --ci -n auto --json-report --json-report-file artifacts/report_headed.json --reruns 3 --reruns-delay 2 --html=artifacts/report_headed.html"
19+
20+
[tool.ruff]
21+
target-version = "py310"

ci_pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ markers = [
1414
"locale_gb: tests run in GB locale versions",
1515
"noxvfb: tests that should not run in xvfb sessions"
1616
]
17-
testpaths = [
18-
"tests"
19-
]
17+
2018
addopts = "-vs --ci --run-headless --json-report --json-report-file artifacts/report.json --reruns 3 --reruns-delay 3 -m 'not incident and not unstable and not headed' --html=artifacts/report.html"
2119

2220
[tool.ruff]

ci_pyproject_headed.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ markers = [
1414
"locale_gb: tests run in GB locale versions",
1515
"noxvfb: tests that should not run in xvfb sessions"
1616
]
17-
testpaths = [
18-
"tests"
19-
]
2017
addopts = "-vs --ci --json-report --json-report-file artifacts/report_headed.json --reruns 3 --reruns-delay 2 -m 'not incident and not unstable and headed' --html=artifacts/report_headed.html"
2118

2219
[tool.ruff]

ci_xvfb_pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ markers = [
1414
"locale_gb: tests run in GB locale versions",
1515
"noxvfb: tests that should not run in xvfb sessions"
1616
]
17-
testpaths = [
18-
"tests"
19-
]
2017
addopts = "-vs --ci --run-headless --json-report --json-report-file artifacts/report.json --reruns 3 --reruns-delay 3 -m 'not unstable and not headed and not noxvfb' --html=artifacts/report.html"
2118

2219
[tool.ruff]

ci_xvfb_pyproject_headed.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ markers = [
1414
"locale_gb: tests run in GB locale versions",
1515
"noxvfb: tests that should not run in xvfb sessions"
1616
]
17-
testpaths = [
18-
"tests"
19-
]
2017
addopts = "-vs --ci --json-report --json-report-file artifacts/report_headed.json --reruns 3 --reruns-delay 2 -m 'not unstable and not noxvfb and headed' --html=artifacts/report_headed.html"
2118

2219
[tool.ruff]

dev_pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ markers = [
1212
"ci: basic tests to run in ci",
1313
"locale_de: tests run in DE locale versions",
1414
"locale_fr: tests run in FR locale versions",
15-
"locale_gb: tests run in GB locale versions"
15+
"locale_gb: tests run in GB locale versions",
16+
"noxvfb: tests that should not run in xvfb sessions"
1617
]
1718

1819
[tool.ruff]

0 commit comments

Comments
 (0)