Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automaatioiden korjaus #9

Merged
merged 14 commits into from
Sep 26, 2024
8 changes: 4 additions & 4 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: code-style
on:
pull_request:
push:
branches: [master, main]
branches: [main]

jobs:
code-style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1
31 changes: 0 additions & 31 deletions .github/workflows/release.yml

This file was deleted.

118 changes: 0 additions & 118 deletions .github/workflows/test-and-pre-release.yml

This file was deleted.

67 changes: 67 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# workflow name
name: Tests

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the wanted branches
on:
pull_request:
push:
branches: [main]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
linux_tests:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container:
image: qgis/qgis:${{ matrix.qgis-image-tags }}
strategy:
matrix:
# Remove unsupported versions and add more versions. Use LTR version in the cov_tests job
qgis-image-tags: [release-3_28, release-3_34, latest]
fail-fast: false

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
apt update && apt install python3-venv -y
python3 -m venv --system-site-packages .venv
.venv/bin/python -m pip install -U setuptools pip
.venv/bin/pip install -r requirements-test.txt
.venv/bin/pip install .

- name: Run tests
env:
QGIS_PLUGIN_IN_CI: 1
QT_QPA_PLATFORM: offscreen
run: |
.venv/bin/pytest

windows_tests:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Choco install qgis
uses: crazy-max/ghaction-chocolatey@v1
with:
args: install qgis-ltr -y

- name: Run tests
shell: pwsh
run: |
$env:QGIS_PATH = (Get-ChildItem "C:\Program Files\QGIS *\bin" | Select-Object -First 1 -ExpandProperty FullName)
$env:PATH="$env:QGIS_PATH;$env:PATH"
$env:QGIS_PLUGIN_IN_CI=1
python-qgis-ltr.bat -m pip install -qr requirements-test.txt
python-qgis-ltr.bat -m pip install .
python-qgis-ltr.bat -m pytest -v
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.11.2
hooks:
- id: mypy
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
rev: v0.6.5
hooks:
# Run the linter.
- id: ruff
Expand Down
6 changes: 3 additions & 3 deletions arho_feature_template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from typing import TYPE_CHECKING

from arho_feature_template.qgis_plugin_tools.infrastructure.debugging import (
setup_debugpy, # noqa F401
setup_ptvsd, # noqa F401
setup_pydevd, # noqa F401
setup_debugpy, # noqa: F401
setup_ptvsd, # noqa: F401
setup_pydevd, # noqa: F401
)

if TYPE_CHECKING:
Expand Down
10 changes: 5 additions & 5 deletions arho_feature_template/core/feature_template_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class FeatureTemplateLibrary:
"""Class for storing FeatureTemplates and loading them from a JSON (or other conf. file)."""

def __init__(self, json_path: str | PathLike):
self.templates = []
self.templates: list[FeatureTemplate] = []
library_dict = self.read_json(json_path)
self.build_templates(library_dict)

Expand All @@ -23,13 +23,13 @@ def read_json(self, json_path: str | PathLike) -> dict:
return json.load(f)

def build_templates(self, library_dict: dict):
templates = []
templates: list[FeatureTemplate] = []

_templates_raw = library_dict["templates"]
# for template_raw in templates_raw:
## ... build FeatureTemplate from dict here, in FeatureTemplate class or elsewhere?
# template = FeatureTemplate()
# templates.append(template)
## ... build FeatureTemplate from dict here, in FeatureTemplate class or elsewhere?
# template = FeatureTemplate()
# templates.append(template)
self.templates = templates

def get_templates(self) -> Sequence[FeatureTemplate]:
Expand Down
2 changes: 1 addition & 1 deletion arho_feature_template/core/forms/add_feature_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self, feature_template: FeatureTemplate):

def _init_feature_attributes(self):
# for feature_attribute in self.feature_template.feature_attributes:
# # Create the form here, add rows with labels and input fields
# # Create the form here, add rows with labels and input fields
pass

def save(self):
Expand Down
3 changes: 2 additions & 1 deletion arho_feature_template/core/forms/feature_attribute_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
ui_path = resources.files(__package__) / "feature_attribute_form.ui"
FormClass, _ = uic.loadUiType(ui_path)

class FeatureAttributeForm(QDialog, FormClass):

class FeatureAttributeForm(QDialog, FormClass): # type: ignore
"""Parent class for feature forms for adding and modifying feature attribute data."""

def __init__(self, feature_template: FeatureTemplate):
Expand Down
3 changes: 2 additions & 1 deletion arho_feature_template/core/panels/template_library_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
ui_path = resources.files(__package__) / "template_library_panel.ui"
FormClass, _ = uic.loadUiType(ui_path)

class TemplateLibraryPanel(QWidget, FormClass):

class TemplateLibraryPanel(QWidget, FormClass): # type: ignore
"""Dock widget for selecting a feature template."""

def __init__(self, feature_template_library: FeatureTemplateLibrary):
Expand Down
3 changes: 2 additions & 1 deletion arho_feature_template/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

LIBRARY_JSON = resources_path("asemakaava-template-library-test.json")


class Plugin:
"""QGIS Plugin Implementation."""

Expand Down Expand Up @@ -128,7 +129,7 @@ def unload(self) -> None:
teardown_logger(Plugin.name)

def run(self) -> None:
self.feature_template_dock= QgsDockWidget()
self.feature_template_dock = QgsDockWidget()
self.add_feature_panel = TemplateLibraryPanel(self.active_library)
self.feature_template_dock.setWidget(self.add_feature_panel)
self.feature_template_dock.setWindowTitle("ARHO") # NOTE: Placeholder name
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
[build-system]
requires = ["setuptools >= 61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "arho-feature-template"
version = "0.1.0"
requires-python = ">= 3.8"

[tool.setuptools]
packages = ["arho_feature_template"]

[tool.pytest.ini_options]
addopts = "-v"
testpaths = "tests"

[tool.coverage.report]
omit = ["arho_feature_template/qgis_plugin_tools/*"]
Expand Down
14 changes: 6 additions & 8 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# Debugging
debugpy

# Dependency maintenance
pip-tools
-c requirements-test.txt

# Testing
pytest
pytest-cov
pytest-qgis
# Debugging
debugpy

# Linting and formatting
pre-commit
Expand All @@ -18,3 +13,6 @@ flake8-qgis

# Stubs
PyQt5-stubs

# repo itself
-e file:.
Loading
Loading