Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .copier-answers.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: ebb6e1c
_commit: '4372075'
_src_path: https://github.com/python-project-templates/base.git
add_docs: false
add_extension: python
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ lint-py: ## lint python with ruff
python -m ruff format --check hatch_js

lint-docs: ## lint docs with mdformat and codespell
python -m mdformat --check README.md
python -m codespell_lib README.md
python -m mdformat --check README.md $(wildcard docs/src)
python -m codespell_lib README.md $(wildcard docs/src)

fix-py: ## autoformat python code with ruff
python -m ruff check --fix hatch_js
python -m ruff format hatch_js

fix-docs: ## autoformat docs with mdformat and codespell
python -m mdformat README.md
python -m codespell_lib --write README.md
python -m mdformat README.md $(wildcard docs/src)
python -m codespell_lib --write README.md $(wildcard docs/src)

lint: lint-py lint-docs ## run all linters
lints: lint
Expand All @@ -50,9 +50,9 @@ check-dist: ## check python sdist and wheel with check-dist
check-dist -v

check-types: ## check python types with ty
ty check --python $$(which python)
python -m ty check

checks: check-dist
checks: check-dist check-types

# Alias
check: checks
Expand Down
4 changes: 2 additions & 2 deletions hatch_js/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def execute(self):

# First navigate to the project path
cwd = Path(curdir).resolve()
chdir(self.path)
chdir(self.path or cwd)

for command in self.commands:
ret = system_call(command)
Expand All @@ -95,7 +95,7 @@ def execute(self):
# Check that all targets exist
# Go back to original path
chdir(str(cwd))
for target in self.targets:
for target in self.targets or []:
if not Path(target).resolve().exists():
raise FileNotFoundError(f"Target '{target}' does not exist after build. Please check your build configuration.")
return self.commands
Expand Down
3 changes: 2 additions & 1 deletion hatch_js/tests/test_hook_registration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from hatchling.metadata.core import ProjectMetadata

from hatch_js.hooks import hatch_register_build_hook

Expand All @@ -10,7 +11,7 @@ def test_registered_build_hook_accepts_hatchling_configuration(tmp_path):
root=str(tmp_path),
config=config,
build_config=None,
metadata=None,
metadata=ProjectMetadata(str(tmp_path), None, {"project": {"name": "project", "version": "0.1.0"}}),
directory=str(tmp_path),
target_name="wheel",
)
Expand Down
21 changes: 21 additions & 0 deletions hatch_js/tests/test_structs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from pathlib import Path

import pytest

from hatch_js.structs import HatchJsBuildPlan


@pytest.mark.parametrize("targets", [None, []])
def test_execute_uses_working_directory_by_default(tmp_path, monkeypatch, targets):
monkeypatch.chdir(tmp_path)
directories = []

def run(command):
directories.append(Path.cwd())
return 0

monkeypatch.setattr("hatch_js.structs.system_call", run)
plan = HatchJsBuildPlan(targets=targets)
plan.generate()
plan.execute()
assert directories == [tmp_path, tmp_path]
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ develop = [
"codespell",
"hatchling",
"mdformat",
"mdformat-frontmatter",
"mdformat-tables>=1",
"pytest",
"pytest-cov",
Expand Down Expand Up @@ -92,7 +93,7 @@ replace = 'version = "{new_version}"'
[tool.coverage.run]
branch = false
omit = [
"hatch_js/tests/integration/",
"hatch_js/tests/integration/*",
]

[tool.coverage.report]
Expand Down