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
8 changes: 5 additions & 3 deletions .github/workflows/Publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ jobs:
uses: actions/setup-node@v6
with:
node-version-file: zimui/package.json
cache: yarn
cache-dependency-path: zimui/yarn.lock

- name: Enable Corepack
working-directory: zimui
run: corepack enable

- name: Build zimui
working-directory: zimui
run: |
yarn install --frozen-lockfile
yarn install --immutable
yarn build

- name: Set up Python
Expand Down
24 changes: 13 additions & 11 deletions .github/workflows/QA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ jobs:
working-directory: scraper
run: |
pip install -U pip
pip install -e .[lint,check,scripts,test]
pip install -e .[qa,scripts,test]

- name: Check black formatting
- name: Check Linting
working-directory: scraper
run: inv lint-black
run: inv check-lint

- name: Check ruff
- name: Check Formatting
working-directory: scraper
run: inv lint-ruff
run: inv check-format

- name: Check pyright
- name: Check Type
working-directory: scraper
run: inv check-pyright
run: inv check-type

check-zimui-qa:
runs-on: ubuntu-24.04
Expand All @@ -47,18 +47,20 @@ jobs:
uses: actions/setup-node@v6
with:
node-version-file: zimui/package.json
cache: yarn
cache-dependency-path: zimui/yarn.lock

- name: Enable Corepack
working-directory: zimui
run: corepack enable

- name: Install JS dependencies
working-directory: zimui
run: yarn install --frozen-lockfile
run: yarn install --immutable

- name: Check prettier
working-directory: zimui
run: |
yarn format-check

- name: Check eslint
working-directory: zimui
run: |
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ jobs:
uses: actions/setup-node@v6
with:
node-version-file: zimui/package.json
cache: yarn
cache-dependency-path: zimui/yarn.lock

- name: Install dependencies
- name: Enable Corepack
working-directory: zimui
run: corepack enable

- name: Install JS dependencies
working-directory: zimui
run: |
yarn install
yarn install --immutable

- name: Build
working-directory: zimui
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,6 @@ scraper/src/maps2zim/assets/mapbox-gl-rtl-text.js

# Zimui build dist
scraper/src/maps2zim/zimui/

# Yarn Berry local state
zimui/.yarn
17 changes: 7 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: '26.1.0'
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.0
rev: v0.15.15
hooks:
- id: ruff
- id: ruff-check
- id: ruff-format
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.408
rev: v1.1.409
hooks:
- id: pyright
name: pyright (system)
Expand All @@ -30,16 +27,16 @@ repos:
hooks:
- id: prettier
name: prettier (system)
entry: prettier --write --ignore-unknown
entry: npx prettier --write --ignore-unknown
language: node
files: zimui\/.*$ # files in frontend folder
minimum_pre_commit_version: "2.9.2"
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.39.1
rev: v10.4.0
hooks:
- id: eslint
types: [file]
files: zimui\/src\/.*(?:\.[jt]sx?|\.vue)$ # *.js, *.jsx, *.ts, *.tsx, *.vue in zimui/src folder
args:
- --config
- zimui/eslint.config.js
- zimui/eslint.config.js
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM node:24-alpine AS zimui
FROM node:26-alpine AS zimui

WORKDIR /src
COPY . /src
RUN cd zimui && yarn install --frozen-lockfile
COPY zimui /src/zimui
RUN cd zimui && npm install -g npm corepack && corepack enable
RUN cd zimui && yarn install --immutable
RUN cd zimui && yarn build

FROM python:3.14-bookworm
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,13 @@ The following commands can then be used to build and test the scraper:
# Show scripts
❯ hatch env show

# linting, testing, coverage, checking
❯ hatch run lint:all
❯ hatch run lint:fixall
# linting, formating, type checking
❯ hatch run qa:check-all
❯ hatch run qa:fix-all

# run tests
❯ hatch run test:run

# run static type checks
❯ hatch env run check:all

# building packages
❯ hatch build
```
Expand All @@ -117,6 +114,6 @@ The following commands can then be used to build and test the scraper:

This project adheres to openZIM's [Contribution Guidelines](https://github.com/openzim/overview/wiki/Contributing).

This project has implemented openZIM's [Python bootstrap, conventions and policies](https://github.com/openzim/_python-bootstrap/blob/main/docs/Policy.md) **v1.0.3**.
This project has implemented openZIM's [Python bootstrap, conventions and policies](https://github.com/openzim/_python-bootstrap/blob/main/docs/Policy.md) **v2.0.0**.

See details for contributions in [CONTRIBUTING.md](CONTRIBUTING.md).
50 changes: 22 additions & 28 deletions scraper/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ description = "Make ZIM file with offline maps from Openstreetmap"
readme = "../README.md"
dependencies = [
"libzim>=3.9.0", # just to ensure we do not have compression issues anymore
"zimscraperlib==5.3.0",
"pydantic==2.12.5",
"zimscraperlib==5.4.0",
"pydantic==2.13.4",
"schedule==1.2.2",
"shapely==2.1.2",
]
Expand All @@ -23,17 +23,18 @@ additional-keywords = ["openstreetmap"]
[tool.hatch.build.hooks.openzim-build]

[project.optional-dependencies]
scripts = ["invoke==2.2.1"]
lint = ["black==26.1.0", "ruff==0.15.0"]
check = ["pyright==1.1.408"]
test = ["pytest==9.0.2", "coverage==7.13.4"]
scripts = ["invoke==3.0.3"]
qa = [
"ruff==0.15.15",
"pyright==1.1.409"
]
test = ["pytest==9.0.3", "coverage==7.14.1"]
dev = [
"pre-commit==4.5.1",
"pre-commit==4.6.0",
"debugpy==1.8.20",
"maps2zim[scripts]",
"maps2zim[lint]",
"maps2zim[qa]",
"maps2zim[test]",
"maps2zim[check]",
"humanfriendly==10.0"
]

Expand Down Expand Up @@ -65,26 +66,19 @@ report-cov = "inv report-cov"
coverage = "inv coverage --args '{args}'"
html = "inv coverage --html --args '{args}'"

[tool.hatch.envs.lint]
template = "lint"
python = "py314"
[tool.hatch.envs.qa]
template = "qa"
skip-install = false
features = ["scripts", "lint"]

[tool.hatch.envs.lint.scripts]
black = "inv lint-black --args '{args}'"
ruff = "inv lint-ruff --args '{args}'"
all = "inv lintall --args '{args}'"
fix-black = "inv fix-black --args '{args}'"
fix-ruff = "inv fix-ruff --args '{args}'"
fixall = "inv fixall --args '{args}'"

[tool.hatch.envs.check]
features = ["scripts", "check"]

[tool.hatch.envs.check.scripts]
pyright = "inv check-pyright --args '{args}'"
all = "inv checkall --args '{args}'"
features = ["scripts", "qa", "test"]

[tool.hatch.envs.qa.scripts]
check-lint = "inv check-lint --args '{args}'"
check-format = "inv check-format --args '{args}'"
check-type = "inv check-type --args '{args}'"
check-all = "inv check-all --args '{args}'"
fix-format = "inv fix-format --args '{args}'"
fix-lint = "inv fix-lint --args '{args}'"
fix-all = "inv fix-all --args '{args}'"

[tool.black]
line-length = 88
Expand Down
1 change: 0 additions & 1 deletion scraper/src/maps2zim/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def main():
try:
with tempfile.TemporaryDirectory() as tmpdir:

prepare_context(sys.argv[1:], tmpdir)

# import this only once the Context has been initialized, so that it gets an
Expand Down
1 change: 0 additions & 1 deletion scraper/src/maps2zim/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,6 @@ def _write_styles(self, creator: Creator):

# Extract and add styles to ZIM
for style in assets.glob("kiwix-*.json"):

# Parse JSON
style_obj = json.loads(style.read_bytes())

Expand Down
74 changes: 35 additions & 39 deletions scraper/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,69 +42,65 @@ def coverage(ctx: Context, args: str = "", *, html: bool = False):
report_cov(ctx, html=html)


@task(optional=["args"], help={"args": "black additional arguments"})
def lint_black(ctx: Context, args: str = "."):
def _lint(ctx: Context, args: str = "."):
args = args or "." # needed for hatch script
ctx.run("black --version", pty=use_pty)
ctx.run(f"black --check --diff {args}", pty=use_pty)
ctx.run("ruff --version", pty=use_pty)
ctx.run(f"ruff check {args}", pty=use_pty)


@task(optional=["args"], help={"args": "ruff additional arguments"})
def lint_ruff(ctx: Context, args: str = "."):
def check_lint(ctx: Context, args: str = "."):
"""check linting with ruff"""
args = args or "." # needed for hatch script
ctx.run("ruff --version", pty=use_pty)
ctx.run(f"ruff check {args}", pty=use_pty)
_lint(ctx, args)


@task(
optional=["args"],
help={
"args": "linting tools (black, ruff) additional arguments, typically a path",
},
)
def lintall(ctx: Context, args: str = "."):
"""Check linting"""
@task(optional=["args"], help={"args": "ruff additional arguments"})
def fix_lint(ctx: Context, args: str = "."):
"""fix linting issues with ruff"""
args = args or "." # needed for hatch script
lint_black(ctx, args)
lint_ruff(ctx, args)
_lint(ctx, f"--fix {args}")


@task(optional=["args"], help={"args": "check tools (pyright) additional arguments"})
def check_pyright(ctx: Context, args: str = ""):
def check_type(ctx: Context, args: str = ""):
"""check static types with pyright"""
ctx.run("pyright --version")
ctx.run(f"pyright {args}", pty=use_pty)


@task(optional=["args"], help={"args": "check tools (pyright) additional arguments"})
def checkall(ctx: Context, args: str = ""):
"""check static types"""
check_pyright(ctx, args)
def _format(ctx: Context, args: str = "."):
args = args or "." # needed for hatch script
ctx.run("ruff --version", pty=use_pty)
ctx.run(f"ruff format {args}", pty=use_pty)


@task(optional=["args"], help={"args": "black additional arguments"})
def fix_black(ctx: Context, args: str = "."):
"""fix black formatting"""
@task(optional=["args"], help={"args": "ruff additional arguments"})
def check_format(ctx: Context, args: str = "."):
"""check formatting with ruff"""
args = args or "." # needed for hatch script
ctx.run(f"black {args}", pty=use_pty)
_format(ctx, f"--check {args}")


@task(optional=["args"], help={"args": "ruff additional arguments"})
def fix_ruff(ctx: Context, args: str = "."):
"""fix all ruff rules"""
def fix_format(ctx: Context, args: str = "."):
"""fix formatting with ruff"""
args = args or "." # needed for hatch script
ctx.run(f"ruff check --fix {args}", pty=use_pty)
_format(ctx, args)


@task(
optional=["args"],
help={
"args": "linting tools (black, ruff) additional arguments, typically a path",
},
)
def fixall(ctx: Context, args: str = "."):
@task(optional=["args"], help={"args": "additional arguments"})
def check_all(ctx: Context, args: str = ""):
"""check linting, formatting and static types"""
args = args or "." # needed for hatch script
check_lint(ctx, args)
check_format(ctx, args)
check_type(ctx, args)


@task(optional=["args"], help={"args": "additional arguments"})
def fix_all(ctx: Context, args: str = ""):
"""Fix everything automatically"""
args = args or "." # needed for hatch script
fix_black(ctx, args)
fix_ruff(ctx, args)
lintall(ctx, args)
fix_lint(ctx, args)
fix_format(ctx, args)
Loading
Loading