From 3a296203b2e204051ce214fbee2cdb34d208887f Mon Sep 17 00:00:00 2001 From: Kazutoshi Horie Date: Sat, 7 Jun 2025 13:43:02 +0900 Subject: [PATCH 1/4] Add config parsing tests and CI --- .github/workflows/test.yml | 18 ++++++++++++++++++ tests/test_configs.py | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 tests/test_configs.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..de89609 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,18 @@ +name: Test + +on: + pull_request: + push: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install dependencies + run: pip install pytest toml + - name: Run tests + run: pytest -v diff --git a/tests/test_configs.py b/tests/test_configs.py new file mode 100644 index 0000000..6de5892 --- /dev/null +++ b/tests/test_configs.py @@ -0,0 +1,18 @@ +import json +import pathlib + +try: + import tomllib # Python 3.11+ +except ModuleNotFoundError: # pragma: no cover - fallback for older versions + import toml as tomllib + + +def test_load_configs(): + repo_root = pathlib.Path(__file__).resolve().parents[1] + karabiner_path = repo_root / ".config" / "karabiner" / "karabiner.json" + with karabiner_path.open('r', encoding='utf-8') as f: + json.load(f) + + starship_path = repo_root / ".config" / "starship.toml" + with starship_path.open('rb') as f: + tomllib.load(f) From fe034c5a307f6ce8d3f196bd4bf77a622b05ad99 Mon Sep 17 00:00:00 2001 From: Kazutoshi Horie Date: Sat, 7 Jun 2025 13:46:15 +0900 Subject: [PATCH 2/4] Restrict CI trigger to master --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index de89609..ac32cd4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,6 +3,8 @@ name: Test on: pull_request: push: + branches: + - master jobs: test: From d87c57e87b643eba979ceed8bfc2669436cba24a Mon Sep 17 00:00:00 2001 From: Kazutoshi Horie Date: Sat, 7 Jun 2025 13:54:19 +0900 Subject: [PATCH 3/4] Update tests/test_configs.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tests/test_configs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_configs.py b/tests/test_configs.py index 6de5892..182d962 100644 --- a/tests/test_configs.py +++ b/tests/test_configs.py @@ -14,5 +14,5 @@ def test_load_configs(): json.load(f) starship_path = repo_root / ".config" / "starship.toml" - with starship_path.open('rb') as f: + with starship_path.open('r', encoding='utf-8') as f: tomllib.load(f) From a487acc1ec656b9fa842888f56567af6810e95b3 Mon Sep 17 00:00:00 2001 From: hekt Date: Sat, 7 Jun 2025 13:56:42 +0900 Subject: [PATCH 4/4] Revert "Update tests/test_configs.py" This reverts commit d87c57e87b643eba979ceed8bfc2669436cba24a. --- tests/test_configs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_configs.py b/tests/test_configs.py index 182d962..6de5892 100644 --- a/tests/test_configs.py +++ b/tests/test_configs.py @@ -14,5 +14,5 @@ def test_load_configs(): json.load(f) starship_path = repo_root / ".config" / "starship.toml" - with starship_path.open('r', encoding='utf-8') as f: + with starship_path.open('rb') as f: tomllib.load(f)