diff --git a/.github/workflows/test-docs.yml b/.github/workflows/test-docs.yml new file mode 100644 index 00000000..56eb0b34 --- /dev/null +++ b/.github/workflows/test-docs.yml @@ -0,0 +1,69 @@ +name: Test & Docs + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + tests: + timeout-minutes: 60 + runs-on: ubuntu-latest + services: + postgres: + image: postgis/postgis:12-2.5 + ports: + - 5432:5432 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + dependencies: [normal, minimal] + database: [postgresql] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: '**/pyproject.toml' + - name: Change dependencies to minimal supported versions + run: sed -i -e '/requires-python/!s/>=/==/g; /requires-python/!s/~=.*==\(.*\)/==\1/g; /requires-python/!s/~=/==/g;' pyproject.toml + if: matrix.dependencies == 'minimal' + - name: Install dependencies + run: | + sudo apt update + sudo apt install libgdal-dev + python -m pip install --upgrade pip + make develop installjs vendors + - name: run tests + run: make test + env: + DJANGO_SETTINGS_MODULE: 'umap.tests.settings' + UMAP_SETTINGS: 'umap/tests/settings.py' + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: Install dependencies + run: | + python3 -m pip install -e .[test,dev] + + - name: Run Lint + run: make lint + + - name: Run Docs + run: make docs diff --git a/.gitignore b/.gitignore index 5b5d15b3..efb609d9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,12 @@ umap/settings/local/* docs/_build umap/remote_static tmp/* -node_modules/* umap/static/umap/vendors site/* .pytest_cache/ +node_modules +umap.conf +data ### Python ### # Byte-compiled / optimized / DLL files diff --git a/Makefile b/Makefile index a66e462d..0189f821 100644 --- a/Makefile +++ b/Makefile @@ -10,13 +10,21 @@ develop: ## Install the test and dev dependencies python3 -m pip install -e .[test,dev] playwright install -.PHONY: pretty-templates -pretty-templates: ## Prettify template files - djlint umap/templates --reformat +.PHONY: format +format: ## Format the code and templates files + djlint umap/templates --reformat &&\ + isort --profile black . &&\ + ruff format --target-version=py38 . -.PHONY: lint-templates -lint-templates: ## Lint template files - djlint umap/templates --lint +.PHONY: lint +lint: ## Lint the code and template files + djlint umap/templates --lint &&\ + isort --check --profile black . &&\ + ruff format --check --target-version=py38 . &&\ + vermin --no-tips --violations -t=3.8- . + +docs: ## Compile the docs + mkdocs build .PHONY: version version: ## Display the current version @@ -47,10 +55,10 @@ publish: ## Publish the Python package to Pypi make clean test: - py.test -xv umap/tests/ + pytest -xv umap/tests/ test-integration: - py.test -xv umap/tests/integration/ + pytest -xv umap/tests/integration/ clean: rm -f dist/* diff --git a/package-lock.json b/package-lock.json index f6c5ca40..557d3962 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "WTFPL", "dependencies": { "@tmcw/togeojson": "^5.8.0", + "colorbrewer": "^1.5.6", "csv2geojson": "5.1.1", "dompurify": "^3.0.3", "georsstogeojson": "^0.1.0", @@ -31,6 +32,7 @@ "leaflet.path.drag": "0.0.6", "leaflet.photon": "0.8.0", "osmtogeojson": "^3.0.0-beta.3", + "simple-statistics": "^7.8.3", "togpx": "^0.5.4", "tokml": "0.4.0" }, @@ -494,6 +496,11 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/colorbrewer": { + "version": "1.5.6", + "resolved": "https://registry.npmjs.org/colorbrewer/-/colorbrewer-1.5.6.tgz", + "integrity": "sha512-fONg2pGXyID8zNgKHBlagW8sb/AMShGzj4rRJfz5biZ7iuHQZYquSCLE/Co1oSQFmt/vvwjyezJCejQl7FG/tg==" + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2122,6 +2129,14 @@ "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=" }, + "node_modules/simple-statistics": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/simple-statistics/-/simple-statistics-7.8.3.tgz", + "integrity": "sha512-JFvMY00t6SBGtwMuJ+nqgsx9ylkMiJ5JlK9bkj8AdvniIe5615wWQYkKHXe84XtSuc40G/tlrPu0A5/NlJvv8A==", + "engines": { + "node": "*" + } + }, "node_modules/sinon": { "version": "15.1.0", "resolved": "https://registry.npmjs.org/sinon/-/sinon-15.1.0.tgz", @@ -2898,6 +2913,11 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "colorbrewer": { + "version": "1.5.6", + "resolved": "https://registry.npmjs.org/colorbrewer/-/colorbrewer-1.5.6.tgz", + "integrity": "sha512-fONg2pGXyID8zNgKHBlagW8sb/AMShGzj4rRJfz5biZ7iuHQZYquSCLE/Co1oSQFmt/vvwjyezJCejQl7FG/tg==" + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -4143,6 +4163,11 @@ "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=" }, + "simple-statistics": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/simple-statistics/-/simple-statistics-7.8.3.tgz", + "integrity": "sha512-JFvMY00t6SBGtwMuJ+nqgsx9ylkMiJ5JlK9bkj8AdvniIe5615wWQYkKHXe84XtSuc40G/tlrPu0A5/NlJvv8A==" + }, "sinon": { "version": "15.1.0", "resolved": "https://registry.npmjs.org/sinon/-/sinon-15.1.0.tgz", diff --git a/pyproject.toml b/pyproject.toml index 7831d31a..ea334353 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,13 +23,11 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] dependencies = [ "Django>=4.1", @@ -47,16 +45,20 @@ dependencies = [ [project.optional-dependencies] dev = [ "hatch==1.7.0", - "black==23.3.0", + "ruff==0.1.6", "djlint==1.31.0", "mkdocs==1.5.2", + "vermin==1.5.2", + "pymdown-extensions==10.4", + "isort==5.12", ] test = [ "factory-boy==3.2.1", - "playwright==1.38.0", + "playwright>=1.39,<2", "pytest==6.2.5", "pytest-django==4.5.2", - "pytest-playwright==0.4.2", + "pytest-playwright>=0.4.3,<1", + "pytest-xdist>=3.5.0,<4", ] docker = [ diff --git a/pytest.ini b/pytest.ini index 610ba029..0d65930e 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,3 @@ [pytest] DJANGO_SETTINGS_MODULE=umap.tests.settings -addopts = --pdbcls=IPython.terminal.debugger:Pdb --no-migrations +addopts = --pdbcls=IPython.terminal.debugger:Pdb --no-migrations --numprocesses auto diff --git a/umap/tests/settings.py b/umap/tests/settings.py index 6d2b28bb..37a72c5f 100644 --- a/umap/tests/settings.py +++ b/umap/tests/settings.py @@ -5,15 +5,17 @@ from umap.settings.base import * # pylint: disable=W0614,W0401 SECRET_KEY = "justfortests" COMPRESS_ENABLED = False FROM_EMAIL = "test@test.org" -EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend' +EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend" -if "TRAVIS" in os.environ: +if os.environ.get("GITHUB_ACTIONS", False) == "true": DATABASES = { "default": { "ENGINE": "django.contrib.gis.db.backends.postgis", - "NAME": "umap", - "PORT": 5433, - "USER": "travis", + "NAME": "postgres", + "USER": "postgres", + "HOST": "localhost", + "PORT": 5432, + "PASSWORD": "postgres", } }