diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..3ec8055 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..d92cdf1 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,141 @@ +name: publish + +on: + push: + branches: + - main + - master + tags: + - '*' + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Install requirements + run: | + pip install --upgrade build + pip install --upgrade setuptools wheel setuptools-scm[toml] importlib-metadata + pip install git+https://github.com/jic-dtool/dtool-annotation.git@main + pip list + + - name: Package distribution + run: | + python -m build + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + + publish-to-testpypi: + name: Publish to TestPyPI + needs: + - build + runs-on: ubuntu-latest + + environment: + name: testpypi + url: https://test.pypi.org/p/dtool-annotation + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + - name: Publish distribution 📦 to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + verbose: true + skip-existing: true + + + publish-to-pypi: + name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/dtool-annotation # Replace with your PyPI project name + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true + + + github-release: + name: >- + Make github release + needs: + - publish-to-pypi + runs-on: ubuntu-latest + + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + - name: Sign with Sigstore + uses: sigstore/gh-action-sigstore-python@v2.1.1 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d74fcd3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,45 @@ +name: test + +on: + push: + branches: + - main + - master + tags: + - '*' + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] + + steps: + - name: Git checkout + uses: actions/checkout@v4 + + - name: Set up python3 ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install requirements + run: | + python -m pip install --upgrade pip + pip install .[test] + pip install flake8 + pip list + + - name: Test with pytest + run: | + pytest -sv + + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=12 --max-line-length=127 --statistics diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d2d4f39..5c6ecac 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,10 +10,16 @@ This change log uses principles from `keep a changelog =42", "setuptools_scm[toml]>=6.3"] +build-backend = "setuptools.build_meta" + +[project] +name = "dtool-annotation" +description = "Add ability to annotate datasets using the dtool CLI" +authors = [ + {name = "Tjelvar Olsson", email = "tjelvar.olsson@gmail.com"}, + {name = "Johannes L. Hörmann", email = "johannes.laurin@gmail.com"}, +] +readme = "README.rst" +requires-python = ">=3.7" +license = {file = "LICENSE"} +dynamic = ["version"] +dependencies = [ + "click", + "dtoolcore>=3.19.0", + "dtool-cli", +] + +[project.optional-dependencies] +test = [ + "pytest", + "pytest-cov" +] +docs = [ + "sphinx", + "sphinx_rtd_theme", + "sphinxcontrib-spelling" +] + +[project.urls] +Repository = "https://github.com/jic-dtool/dtool-annotation" +Documentation = "https://github.com/jic-dtool/dtool-annotation/blob/master/README.rst" +Changelog = "https://github.com/jic-dtool/dtool-annotation/blob/master/CHANGELOG.rst" + +[tool.setuptools_scm] +version_scheme = "guess-next-dev" +local_scheme = "no-local-version" +write_to = "dtool_annotation/version.py" + +[tool.setuptools] +packages = ["dtool_annotation"] + +[project.entry-points."dtool.cli"] +annotation = "dtool_annotation.cli:annotation" diff --git a/setup.py b/setup.py deleted file mode 100644 index 08b4d29..0000000 --- a/setup.py +++ /dev/null @@ -1,29 +0,0 @@ -from setuptools import setup - -url = "https://github.com/jic-dtool/dtool-annotation" -version = "0.1.1" -readme = open('README.rst').read() - -setup( - name="dtool-annotation", - packages=["dtool_annotation"], - version=version, - description="Add ability to annotate datasets using the dtool CLI", - long_description=readme, - include_package_data=True, - author="Tjelvar Olsson", - author_email="tjelvar.olsson@gmail.com", - url=url, - install_requires=[ - "click", - "dtoolcore>=3.13.0", - "dtool-cli", - ], - entry_points={ - "dtool.cli": [ - "annotation=dtool_annotation.cli:annotation", - ], - }, - download_url="{}/tarball/{}".format(url, version), - license="MIT" -) diff --git a/tests/test_annotation_functional.py b/tests/test_annotation_functional.py index 0c5a06d..3fb3064 100644 --- a/tests/test_annotation_functional.py +++ b/tests/test_annotation_functional.py @@ -30,6 +30,23 @@ def test_annotation_basic(tmp_dataset_fixture): # NOQA actual = result.output.strip() assert actual == expected + result = runner.invoke(annotation, [ + "delete", + tmp_dataset_fixture.uri, + "project" + ]) + assert result.exit_code == 0 + + result = runner.invoke(annotation, [ + "get", + tmp_dataset_fixture.uri, + "project" + ]) + assert result.exit_code != 0 + expected = "No annotation named: 'project'" + actual = result.output.strip() + assert actual == expected + def test_annotation_invalid_name(tmp_dataset_fixture): # NOQA @@ -72,6 +89,20 @@ def test_get_non_existing_annotation(tmp_dataset_fixture): # NOQA assert result.output.strip() == expected +def test_delete_non_existing_annotation(tmp_dataset_fixture): # NOQA + + from dtool_annotation.cli import annotation + + runner = CliRunner() + + result = runner.invoke(annotation, [ + "delete", + tmp_dataset_fixture.uri, + "project", + ]) + assert result.exit_code == 0 + + def test_annotation_types(tmp_dataset_fixture): # NOQA from dtool_annotation.cli import annotation