diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a900c84..b58254c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,115 +1,48 @@ +# wads CI — calls the reusable workflow hosted in i2mint/wads. +# +# All configuration comes from this repo's pyproject.toml [tool.wads.ci.*]. +# To customize the workflow itself (rare), replace this file with the +# full inline template `wads/data/github_ci_uv.yml` from i2mint/wads. +# +# Pinning: `@master` floats with wads. If you need version stability for +# a release-sensitive repo, change `@master` to a wads tag (e.g. `@v0.1.81`). +# CI failure does not block a published release — it blocks the publish +# step itself — so floating master is generally safe. +# +# Permissions: GitHub validates that the caller grants AT LEAST the +# permissions any job in the called workflow requests — at workflow-parse +# time, not at run-time, even if the job would be skipped via `if:`. +# The reusable workflow needs: +# contents: write for the publish job's version-bump push-back +# and for the github-pages job's gh-pages branch push +# pages: write for the github-pages job's REST API Pages config +# Both default to `write` on org-account GITHUB_TOKEN and need to be +# granted explicitly on personal-account callers (where the default is +# read-only). No `id-token: write` needed — the publish-github-pages +# action uses peaceiris/actions-gh-pages (branch-based) + REST API, +# not the OIDC `actions/deploy-pages` flow. name: Continuous Integration on: [push, pull_request] -env: - PROJECT_NAME: pydrivedol - jobs: - validation: - name: Validation - if: "!contains(github.event.head_commit.message, '[skip ci]')" - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.10", "3.12"] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - # Necessary for 3.12, since setuptools was removed there - # TODO: Get rid of this once we have a better solution for Python 3.12 - - name: Install setuptools - run: python -m pip install setuptools - - - name: Install Dependencies - uses: i2mint/isee/actions/install-packages@master - with: - dependency-files: setup.cfg - # ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} # Uncomment this if you need to install private dependencies from source - - - name: Format Source Code - uses: i2mint/isee/actions/format-source-code@master - - - name: Pylint Validation - uses: i2mint/isee/actions/pylint-validation@master - with: - root-dir: ${{ env.PROJECT_NAME }} - enable: missing-module-docstring - ignore: tests,examples,scrap - # ignore-patterns: '.*tests.*|.*examples.*|.*scrap.*' - - - name: Pytest Validation - uses: i2mint/isee/actions/pytest-validation@master - with: - root-dir: ${{ env.PROJECT_NAME }} - paths-to-ignore: examples,scrap - - publish: - name: Publish - if: "!contains(github.event.head_commit.message, '[skip ci]') && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')" - needs: validation - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.12"] - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Format Source Code - uses: i2mint/isee/actions/format-source-code@master - - - name: Update Version Number - uses: i2mint/isee/actions/bump-version-number@master - - - name: Package - uses: i2mint/isee/actions/package@master - # Uncomment this if you need to install private dependencies from source - # with: - # ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - - name: Publish - uses: i2mint/isee/actions/publish@master - with: - pypi-username: ${{ secrets.PYPI_USERNAME }} - pypi-password: ${{ secrets.PYPI_PASSWORD }} - - - name: Check In - uses: i2mint/isee/actions/check-in@master - with: - commit-message: "**CI** Formatted code + Updated version number and documentation. [skip ci]" - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - - name: Tag Repository With New Version Number - uses: i2mint/isee/actions/tag-repository@master - with: - tag: $VERSION - - github-pages: - name: Publish GitHub Pages - + ci: + uses: i2mint/wads/.github/workflows/uv-ci.yml@master permissions: contents: write pages: write - id-token: write - - if: "!contains(github.event.head_commit.message, '[skip ci]') && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)" - needs: publish - runs-on: ubuntu-latest - steps: - - uses: i2mint/epythet/actions/publish-github-pages@master - with: - # IMPORTANT Note: You don't need to specify GITHUB_TOKEN in your repo secrets. - # GITHUB_TOKEN is special & automatically provided to your workflow run. - github-token: ${{ secrets.GITHUB_TOKEN }} - ignore: "tests/,scrap/" + # Explicit pass-through (not `secrets: inherit`) because `inherit` does + # not reliably propagate caller-repo secrets to a reusable workflow owned + # by a different account (verified empirically: personal-account caller + + # i2mint-org workflow → `${{ secrets.PYPI_PASSWORD }}` resolved to empty). + # + # This list is the per-repo *transport*: it should contain PYPI_PASSWORD + # (for publishing) plus every secret your tests/CI need. It is generated + # from [tool.wads.ci.env] in pyproject.toml. To add one, run + # wads-secrets add VAR_NAME # updates pyproject + this block + # or just append a line below. *Which* of these become job env vars (and + # which are required) is controlled by [tool.wads.ci.env] — passing a + # secret here does not by itself put it in the environment. + # + # A secret name must also be declared in the reusable workflow's superset + # (wads/ci_secrets.py). `wads-secrets add` warns if it is not. + secrets: + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} diff --git a/pydrivedol/tests/test_base.py b/pydrivedol/tests/test_base.py index 7566160..abf0bf5 100644 --- a/pydrivedol/tests/test_base.py +++ b/pydrivedol/tests/test_base.py @@ -248,7 +248,7 @@ def test_extract_file_id(self): ('https://drive.google.com/uc?id=DEF456&export=download', 'DEF456'), ] for url, expected_id in urls: - file_id = pydrivedol._extract_file_id(url) + file_id = pydrivedol.base._extract_file_id(url) assert file_id == expected_id, f"Failed for URL: {url}" def test_extract_folder_id(self): @@ -258,7 +258,7 @@ def test_extract_folder_id(self): ('https://drive.google.com/drive/u/0/folders/XYZ789', 'XYZ789'), ] for url, expected_id in urls: - folder_id = pydrivedol._extract_folder_id(url) + folder_id = pydrivedol.base._extract_folder_id(url) assert folder_id == expected_id, f"Failed for URL: {url}" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..fa4e067 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,157 @@ +[build-system] +requires = [ + "hatchling", +] +build-backend = "hatchling.build" + +[project] +name = "pydrivedol" +version = "0.0.2" +description = "pydrive (googledrive) with a simple (dict-like or list-like) interface" +readme = "README.md" +license = "Apache-2.0" +requires-python = ">=3.10" +keywords = [ + "google drive", + "data", +] +authors = [] +dependencies = [ + "pydrive2", + "requests", +] + +[project.urls] +Homepage = "https://github.com/i2mint/pydrivedol" + +[project.optional-dependencies] +dev = [ + "pytest>=7.0", + "pytest-cov>=4.0", + "ruff>=0.1.0", +] +docs = [ + "sphinx>=6.0", + "sphinx-rtd-theme>=1.0", +] + +[tool.ruff] +line-length = 88 +target-version = "py310" +exclude = [ + "**/*.ipynb", + ".git", + ".venv", + "build", + "dist", + "tests", + "examples", + "scrap", +] + +[tool.ruff.lint] +select = [ + "D100", +] +ignore = [ + "D203", + "E501", + "B905", +] + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.lint.per-file-ignores] +"**/tests/*" = [ + "D", +] +"**/examples/*" = [ + "D", +] +"**/scrap/*" = [ + "D", +] + +[tool.pytest.ini_options] +minversion = "6.0" +testpaths = [ + "pydrivedol", +] +doctest_optionflags = [ + "NORMALIZE_WHITESPACE", + "ELLIPSIS", +] + +[tool.wads.ci] +project_name = "pydrivedol" + +[tool.wads.ci.commands] +pre_test = [] +test = [] +post_test = [] +lint = [] +format = [] + +[tool.wads.ci.env] +required_envvars = [] +test_envvars = [] +extra_envvars = [] + +[tool.wads.ci.env.defaults] + +[tool.wads.ci.quality.ruff] +enabled = true + +[tool.wads.ci.quality.black] +enabled = false + +[tool.wads.ci.quality.mypy] +enabled = false + +[tool.wads.ci.testing] +enabled = true +python_versions = [ + "3.10", + "3.12", +] +pytest_args = [ + "-v", + "--tb=short", +] +coverage_enabled = true +coverage_threshold = 0 +coverage_report_format = [ + "term", + "xml", +] +exclude_paths = [ + "examples", + "scrap", +] +test_on_windows = true + +[tool.wads.ci.metrics] +enabled = true +config_path = ".github/umpyre-config.yml" +storage_branch = "code-metrics" +python_version = "3.10" +force_run = false + +[tool.wads.ci.build] +sdist = true +wheel = true + +[tool.wads.ci.publish] +enabled = true +skip_ci_marker = "[skip ci]" +publish_marker = "[publish]" + +[tool.wads.ci.docs] +enabled = true +builder = "epythet" +ignore_paths = [ + "tests/", + "scrap/", + "examples/", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index bebd0c9..0000000 --- a/setup.cfg +++ /dev/null @@ -1,25 +0,0 @@ -[metadata] -name = pydrivedol -version = 0.0.2 -url = https://github.com/i2mint/pydrivedol -platforms = any -description_file = README.md -root_url = https://github.com/i2mint/ -license = apache-2.0 - -description = pydrive (googledrive) with a simple (dict-like or list-like) interface -long_description = file:README.md -long_description_content_type = text/markdown -keywords = - google drive - data -display_name = pydrivedol - -[options] -packages = find: -include_package_data = True -zip_safe = False -install_requires = - pydrive2 - requests - diff --git a/setup.py b/setup.py deleted file mode 100644 index 201cd4c..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() # Note: Everything should be in the local setup.cfg