Compare commits

...

70 Commits

Author SHA1 Message Date
kdmukai
9588895282 bugfix 2025-04-27 13:42:06 -05:00
kdmukai
6bc1ddbac6 revert ES translations to match current dev 2025-04-27 13:42:00 -05:00
kdmukai
4201c70874 Sync to latest ES in transifex 2025-04-27 13:35:50 -05:00
kdmukai
6be95ea336 remove REPO_NAME env var; simplify html output 2025-04-27 13:32:04 -05:00
kdmukai
c6c22a176d [ES update] Additional minor changes to fit live preview screens 2025-04-27 13:29:52 -05:00
kdmukai
c98e16d5df Matches UX update to allow ANYCLICK in image entropy flow 2025-04-27 13:29:52 -05:00
kdmukai
2638c437ba latest ES translations + changes from kdmukai @ 5c6c99b 2025-04-27 13:29:52 -05:00
kdmukai
beb8981454 ES translations for final review 2025-04-27 13:29:52 -05:00
kdmukai
9f4605d876 Matching ES messages.mo for latest .po translations 2025-04-27 13:29:52 -05:00
MaxApogee
5a076ae854 Add files via upload 2025-04-27 13:29:52 -05:00
MaxApogee
7362485714 Add files via upload 2025-04-27 13:29:52 -05:00
kdmukai
b4e8074916
Merge pull request #24 from kdmukai/screenshot_diff_workflow
Remove hard-coded `kdmukai` fork reference; pass in env var instead
2025-04-27 13:15:31 -05:00
kdmukai
ec39d4cc6c Remove hard-coded kdmukai fork reference; pass in env var instead 2025-04-27 12:59:22 -05:00
kdmukai
9a6b1c1fdc Increasing sleep workaround for race condition 2025-01-01 09:21:12 -06:00
kdmukai
8856345353 Remove unused env var setup steps 2025-01-01 09:17:20 -06:00
kdmukai
cc8cce41a4 actions/checkout bumped to v4 2025-01-01 09:13:54 -06:00
kdmukai
84054bd54c Update actions versions per dbast 2024-12-31 12:18:13 -06:00
kdmukai
95c08ee850 Additional code comment 2024-12-30 14:40:40 -06:00
kdmukai
2532e2fe45 resync messages.po to current dev 2024-12-30 14:29:14 -06:00
kdmukai
6eae46c6de temp workaround to avoid race condition 2024-12-30 14:25:50 -06:00
kdmukai
5ea63c3403 html improvements 2024-12-30 14:25:50 -06:00
kdmukai
1da10668b5 Longer artifact retention, html visual improvement 2024-12-30 14:25:50 -06:00
kdmukai
5b4e13637d Add $BRANCH_NAME env var; improve html 2024-12-30 14:25:50 -06:00
kdmukai
f97bb3cb4f Use $BUILD_TAG for screenshot dir name 2024-12-30 14:25:50 -06:00
kdmukai
dfcc21a506 Pull translation updates by event type 2024-12-30 14:25:50 -06:00
kdmukai
735d85c892 re-enable checkout action for submodule 2024-12-30 14:25:50 -06:00
kdmukai
4d6ef64f8a locale bugfix, styling improvements 2024-12-30 14:25:50 -06:00
kdmukai
e3c03974d5 add diff report dir, css styling, html template 2024-12-30 14:25:50 -06:00
kdmukai
7c11b5a47a re-enable cleaning out non-diff screenshots 2024-12-30 14:25:50 -06:00
kdmukai
f9238e1934 re-enable copying changed screenshots 2024-12-30 14:25:50 -06:00
kdmukai
1298dc1ddd pip install editable 2024-12-30 14:25:50 -06:00
kdmukai
c3f876e8dd build default dev screenshots again 2024-12-30 14:25:50 -06:00
kdmukai
ee679a8019 cleanup 2024-12-30 14:25:33 -06:00
kdmukai
e3a0215869 direct clone 2024-12-30 14:25:33 -06:00
kdmukai
f913825ba6 fix artifacts path 2024-12-30 14:25:33 -06:00
kdmukai
34cd9c832a clear out translations dir 2024-12-30 14:25:33 -06:00
kdmukai
7af1edfd42 fix cwd 2024-12-30 14:25:33 -06:00
kdmukai
8c053cb76c Fix commit hash when it's a PR 2024-12-30 14:25:33 -06:00
kdmukai
2230aa4e75 simplify grabbing new translations 2024-12-30 14:25:33 -06:00
kdmukai
1b1ff87dff git fetch update 2024-12-30 14:25:33 -06:00
kdmukai
4a9861f129 git pull bugfix 2024-12-30 14:25:33 -06:00
kdmukai
3a0603c154 git clone url fix 2024-12-30 14:25:33 -06:00
kdmukai
7f3f649247 cwd bugfix 2024-12-30 14:25:33 -06:00
kdmukai
d2fb00d580 manual git calls 2024-12-30 14:25:33 -06:00
kdmukai
09482030da Add compile catalog step 2024-12-30 14:25:33 -06:00
kdmukai
cf949d2af6 don't even create the dev screenshots 2024-12-30 14:25:33 -06:00
kdmukai
6adc17b962 try removing the submodule 2024-12-30 14:25:33 -06:00
kdmukai
febcb16b06 Update .mo file! 2024-12-30 14:25:31 -06:00
kdmukai
f4bcdbcfaf another sanity check 2024-12-30 14:24:50 -06:00
kdmukai
32e74d037c sanity check 2024-12-30 14:24:50 -06:00
kdmukai
ffc5cca16e python version bugfix 2024-12-30 14:24:50 -06:00
kdmukai
2e8bb1d00c simplifying 2024-12-30 14:24:50 -06:00
kdmukai
d1546d0ee3 Remove submodule 2024-12-30 14:24:50 -06:00
kdmukai
78e59f1ff4 bugfix 2024-12-30 14:24:50 -06:00
kdmukai
990197dc87 test with translation changes 2024-12-30 14:24:49 -06:00
kdmukai
0a1f06a587 fix dev screenshots 2024-12-30 14:23:18 -06:00
kdmukai
d1dd257fd4 bugfix 2024-12-30 14:23:18 -06:00
kdmukai
58304ea073 debugging 2024-12-30 14:23:18 -06:00
kdmukai
a762233a8c debugging 2024-12-30 14:23:18 -06:00
kdmukai
ef18dd8e01 debugging 2024-12-30 14:23:18 -06:00
kdmukai
48d070723d debugging 2024-12-30 14:23:18 -06:00
kdmukai
09a6d27107 screenshot copy fix 2024-12-30 14:23:18 -06:00
kdmukai
6f74857578 debugging 2024-12-30 14:23:18 -06:00
kdmukai
d5035fe13e debugging 2024-12-30 14:23:18 -06:00
kdmukai
462bd34299 More subdir fixes 2024-12-30 14:23:18 -06:00
kdmukai
554278c8ec fix submodule subdir 2024-12-30 14:23:18 -06:00
kdmukai
bf3611a937 bugfix on submodule dir 2024-12-30 14:23:18 -06:00
kdmukai
0ec6f42d14 debugging help 2024-12-30 14:23:18 -06:00
kdmukai
983f3fdde6 Separate cleanup step 2024-12-30 14:23:18 -06:00
kdmukai
2e1f94e6ec Initial screenshot diff script and yaml 2024-12-30 14:23:18 -06:00
6 changed files with 460 additions and 222 deletions

137
.github/diff_report/diff_screenshots.py vendored Normal file
View File

@ -0,0 +1,137 @@
"""
Utility to compare screenshots before and after a change and generate a report of the
differences.
Expected usage in a GitHub Actions workflow; compare `dev` with the `$BRANCH_NAME` in the
associated PR that triggered the CI run:
python src/seedsigner/resources/seedsigner-translations/.github/diff_report/diff_screenshots.py ./artifacts/dev ./artifacts/$BRANCH_NAME ./artifacts/diff
"""
import argparse
import glob
import hashlib
import os
import pathlib
import shutil
parser = argparse.ArgumentParser(prog=__name__)
parser.add_argument("before_dir", type=str, help="Directory containing screenshots before the proposed changes")
parser.add_argument("after_dir", type=str, help="Directory containing screenshots after the proposed changes")
parser.add_argument("output_dir", type=str, help="Directory to save the screenshots diff report")
args = parser.parse_args()
# "before" and "after" directories are named: artifacts/$TARGET_BRANCH and artifacts/$BRANCH_NAME
before_branch_name = args.before_dir.split(os.path.sep)[-1]
after_branch_name = args.after_dir.split(os.path.sep)[-1]
def list_files_recursively(path: str) -> list[str]:
""" Return a list of paths to all png files in the directory tree """
return glob.glob(path + "/**/*.png", recursive=True)
def compute_file_hash(file_path: str) -> str:
""" Return the file hash using sha256 """
hash_func = hashlib.new('sha256')
with open(file_path, 'rb') as file:
while chunk := file.read(8192): # Read the file in chunks of 8192 bytes
hash_func.update(chunk)
return hash_func.hexdigest()
def get_pathname_fragment(path:str) -> str:
""" Extract the last 3 parts of the path:
en/tools_views/ToolsCalcFinalWordDoneView.png
These paths will be the same in the "before" and "after" directories.
"""
parts = path.split(os.path.sep)
if len(parts) < 3:
raise ValueError(f"Path should have at least 3 parts: {path}")
return os.path.sep.join(parts[-3:])
def get_locale_and_screenshot_name(path: str) -> tuple[str, str]:
""" Parse the path to extract the locale and the screenshot name.
Assumes we're working with a path like:
en/tools_views/ToolsCalcFinalWordDoneView.png
"""
parts = path.split(os.path.sep)
if len(parts) != 3:
raise ValueError(f"Path should have 3 parts: {path}")
return parts[0], parts[-1].split(".")[0]
# Recursively list and hash all png files in the "before" directory
before_screenshots = {}
paths_before = []
for file in list_files_recursively(args.before_dir):
screenshot_path = get_pathname_fragment(file)
before_screenshots[screenshot_path] = compute_file_hash(file)
paths_before.append(screenshot_path)
# Do the same for the "after" directory, but do the diff while we're here
only_in_after = []
diffs: list[str] = []
paths_after = []
for file in list_files_recursively(args.after_dir):
screenshot_path = get_pathname_fragment(file)
if screenshot_path not in before_screenshots:
only_in_after.append(screenshot_path)
elif before_screenshots[screenshot_path] != compute_file_hash(file):
diffs.append(screenshot_path)
paths_after.append(screenshot_path)
only_in_before = set(paths_before) - set(paths_after)
html_content = "<h1>Screenshots diff report</h1>"
html_content += f"""<p>Comparing {before_branch_name} to {after_branch_name}</p>"""
output_dir_before = os.path.join(args.output_dir, "before")
output_dir_after = os.path.join(args.output_dir, "after")
os.makedirs(output_dir_before, exist_ok=True)
os.makedirs(output_dir_after, exist_ok=True)
for screenshot_path in only_in_before:
locale, screenshot_name = get_locale_and_screenshot_name(screenshot_path)
print(f"Screenshot only in before: {locale}: {screenshot_name}")
os.makedirs(os.path.join(output_dir_before, os.path.dirname(screenshot_path)), exist_ok=True)
shutil.copy(os.path.join(args.before_dir, screenshot_path), os.path.join(output_dir_before, screenshot_path))
html_content += f"<p>{locale}: REMOVED {screenshot_name}</br><img src='{os.path.join('before', screenshot_path)}'></p></br></br>"
for screenshot_path in only_in_after:
locale, screenshot_name = get_locale_and_screenshot_name(screenshot_path)
print(f"Screenshot only in after: {locale}: {screenshot_name}")
os.makedirs(os.path.join(output_dir_after, os.path.dirname(screenshot_path)), exist_ok=True)
shutil.copy(os.path.join(args.after_dir, screenshot_path), os.path.join(output_dir_after, screenshot_path))
html_content += f"<p>{locale}: ADDED {screenshot_name}</br><img src='{os.path.join('after', screenshot_path)}'></p></br></br>"
for screenshot_path in diffs:
locale, screenshot_name = get_locale_and_screenshot_name(screenshot_path)
print(f"Screenshot different: {locale}: {screenshot_name}")
# Copy both screenshots to the output dir
os.makedirs(os.path.join(output_dir_before, os.path.dirname(screenshot_path)), exist_ok=True)
os.makedirs(os.path.join(output_dir_after, os.path.dirname(screenshot_path)), exist_ok=True)
shutil.copy(os.path.join(args.before_dir, screenshot_path), os.path.join(output_dir_before, screenshot_path))
shutil.copy(os.path.join(args.after_dir, screenshot_path), os.path.join(output_dir_after, screenshot_path))
html_content += f"<p>{locale}: {screenshot_name}</br><img src='{os.path.join('before', screenshot_path)}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='{os.path.join('after', screenshot_path)}'></p></br></br>"
if not only_in_after and not only_in_before and not diffs:
print("No differences found")
html_content += "<h1>No differences found</h1>"
script_dir = pathlib.Path(__file__).parent.resolve()
html_output = ""
with open(os.path.join(script_dir, "index.html"), "r") as f:
html_output = f.read().replace("{{ content }}", html_content)
with open(os.path.join(args.output_dir, "index.html"), "w") as f:
f.write(html_output)
# Also copy the css file; source: https://github.com/picocss/pico
shutil.copy(os.path.join(script_dir, "pico.min.css"), os.path.join(args.output_dir, "pico.min.css"))

15
.github/diff_report/index.html vendored Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="color-scheme" content="light dark" />
<title>SeedSigner screenshot diffs</title>
<link rel="stylesheet" href="pico.min.css" />
</head>
<body>
<main class="container">
{{ content }}
</main>
</body>
</html>

4
.github/diff_report/pico.min.css vendored Normal file

File diff suppressed because one or more lines are too long

89
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,89 @@
name: CI
on:
push:
branches:
- dev
- main
pull_request:
concurrency:
# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to main will not cancel.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- name: Checkout main repo 'dev'
uses: actions/checkout@v4
with:
repository: 'SeedSigner/seedsigner'
ref: dev
submodules: true
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
sudo apt-get install libzbar0
python -m pip install --upgrade pip
pip install -r requirements.txt -r tests/requirements.txt -r l10n/requirements-l10n.txt
pip install -e .
- name: Generate current 'dev' screenshots
run: |
mkdir -p artifacts/dev
python -m pytest tests/screenshot_generator/generator.py
sleep 10
mv ./seedsigner-screenshots/* ./artifacts/dev/
- name: Checkout updated translations (PR)
uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request' }}
with:
path: src/seedsigner/resources/seedsigner-translations
ref: ${{ github.event.pull_request.head.sha }}
- name: Checkout updated translations (Push)
uses: actions/checkout@v4
if: ${{ github.event_name == 'push' }}
with:
path: src/seedsigner/resources/seedsigner-translations
ref: ${{ github.sha }}
- name: Compile updated translations catalogs
run: |
python setup.py compile_catalog
cd src/seedsigner/resources/seedsigner-translations
git status
- name: Generate latest screenshots
run: |
rm -rf seedsigner-screenshots
mkdir -p artifacts/$BRANCH_NAME
python -m pytest tests/screenshot_generator/generator.py
sleep 10
mv ./seedsigner-screenshots/* ./artifacts/$BRANCH_NAME/
- name: Diff screenshots
run: |
mkdir -p artifacts/diff
python src/seedsigner/resources/seedsigner-translations/.github/diff_report/diff_screenshots.py ./artifacts/dev ./artifacts/$BRANCH_NAME ./artifacts/diff
- name: Clean up artifacts
run: |
rm -rf ./artifacts/$BRANCH_NAME
rm -rf ./artifacts/dev
mv ./artifacts/diff/* ./artifacts
rmdir ./artifacts/diff
- name: Archive CI Artifacts
uses: actions/upload-artifact@v4
with:
name: ci-artifacts
path: artifacts/**
retention-days: 60
# Upload also when tests fail. The workflow result (red/green) will
# be not effected by this.
if: always()

Binary file not shown.

File diff suppressed because it is too large Load Diff