Skip to content

Commit

Permalink
Retry
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmervdl committed Sep 3, 2024
1 parent 42a574e commit 6e5c6a9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ jobs:

- uses: actions/upload-artifact@v3
with:
name: sdist
path: dist/opuscleaner-*.tar.gz
path: dist/opuscleaner-*.*

run_tests:
needs: [build]
Expand All @@ -45,11 +44,10 @@ jobs:

- uses: actions/download-artifact@v3
with:
name: sdist
path: dist

- name: Install
run: python3 -m pip install dist/opuscleaner-*.tar.gz
run: python3 -m pip install dist/opuscleaner-*.whl

- name: Run runtime unittest
run: python3 -m unittest discover -s test
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ python = ["39", "310", "311"]
[tool.hatch.build]
include = ["/opuscleaner"]

[tool.hatch.build.force-include]
[tool.hatch.build.targets.sdist.force-include]
"frontend/dist" = "/opuscleaner/frontend"

[tool.hatch.build.hooks.custom]
[tool.hatch.build.targets.sdist.hooks.custom]
path = "utils/frontend_build_hook.py"
working_dir = "frontend"
artifacts = ["frontend/dist"]
Expand Down
18 changes: 16 additions & 2 deletions utils/frontend_build_hook.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import subprocess
import os
from typing import Any
import logging

from hatchling.builders.hooks.plugin.interface import BuildHookInterface


logger = logging.getLogger(__name__)


class NpmBuildHook(BuildHookInterface):
@property
def working_dir(self):
return self.config.get("working_dir", ".")

def initialize(self, version: str, build_data: dict[str, Any]) -> None:
# if we can't build because we don't have the build dir, skip
if not os.path.exists(self.working_dir):
logger.info(f"Skipping npm build because {self.working_dir=} does not exist")
return
# if we don't need to build because we have all the artifacts, skip
if all(os.path.exists(artifact) for artifact in self.config.get("artifacts", [])):
logger.info(f"Skipping npm build because all artifacts exist")
return
subprocess.check_output(
"npm install && npm run build",
shell=True,
cwd=self.config.get("working_dir", "."))
cwd=self.working_dir)

def clean(self, versions: list[str]) -> None:
subprocess.check_output("npm run clean", shell=True)
subprocess.check_output("npm run clean", shell=True, cwd=self.working_dir)

0 comments on commit 6e5c6a9

Please sign in to comment.