Skip to content

Jac/release automation #1613

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

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
tableauserverclient/_version.py export-subst
tableauserverclient/bin/_version.py export-subst
11 changes: 7 additions & 4 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Publish to PyPi

# This will publish a package to TestPyPi (and real Pypi if run on master) with a version
# number generated by versioneer from the most recent tag looking like v____
# TODO: maybe move this into the package job so all release-based actions are together
# This will build a package with a version set by versioneer from the most recent tag matching v____
# It will publish to TestPyPi, and to real Pypi *if* run on master where head has a release tag
# For a live run, this should only need to be triggered by a newly published repo release.
# This can also be run manually for testing
on:
release:
types: [published]
workflow_dispatch:
push:
tags:
Expand All @@ -23,7 +26,7 @@ jobs:
- name: Build dist files
run: |
python -m pip install --upgrade pip
pip install -e .[test] build
python -m pip install -e .[test] build
python -m build
git describe --tag --dirty --always

Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ include CONTRIBUTORS.md
include LICENSE
include LICENSE.versioneer
include README.md
include tableauserverclient/_version.py
include versioneer.py
recursive-include docs *.md
recursive-include samples *.py
recursive-include samples *.txt
Expand All @@ -18,5 +16,4 @@ recursive-include test *.png
recursive-include test *.py
recursive-include test *.xml
recursive-include test *.tde
global-include *.pyi
global-include *.typed
11 changes: 0 additions & 11 deletions publish.sh

This file was deleted.

12 changes: 9 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=75.0", "versioneer[toml]==0.29", "wheel"]
requires = ["setuptools>=77.0", "versioneer[toml]==0.29", "wheel"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -8,7 +8,7 @@ name="tableauserverclient"
dynamic = ["version"]
description='A Python module for working with the Tableau Server REST API.'
authors = [{name="Tableau", email="[email protected]"}]
license = {file = "LICENSE"}
license-files = ["LICENSE"]
readme = "README.md"

dependencies = [
Expand All @@ -35,6 +35,12 @@ repository = "https://github.com/tableau/server-client-python"
test = ["black==24.8", "build", "mypy==1.4", "pytest>=7.0", "pytest-cov", "pytest-subtests",
"requests-mock>=1.0,<2.0"]

[tool.setuptools.packages.find]
where = ["tableauserverclient", "tableauserverclient.helpers", "tableauserverclient.models", "tableauserverclient.server", "tableauserverclient.server.endpoint"]

[tool.setuptools.dynamic]
version = {attr = "versioneer.get_version"}

[tool.black]
line-length = 120
target-version = ['py39', 'py310', 'py311', 'py312', 'py313']
Expand All @@ -61,5 +67,5 @@ addopts = "--junitxml=./test.junit.xml"
VCS = "git"
style = "pep440-pre"
versionfile_source = "tableauserverclient/bin/_version.py"
versionfile_build = "tableauserverclient/bin/_version.py"
versionfile_build = "_version.py"
tag_prefix = "v"
13 changes: 3 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@
from setuptools import setup

setup(
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
# not yet sure how to move this to pyproject.toml
packages=[
"tableauserverclient",
"tableauserverclient.helpers",
"tableauserverclient.models",
"tableauserverclient.server",
"tableauserverclient.server.endpoint",
],
# This line is required to set the version number when building the wheel
# not yet sure how to move this to pyproject.toml - it may require work in versioneer
cmdclass=versioneer.get_cmdclass()
)
4 changes: 0 additions & 4 deletions tableauserverclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,3 @@
"WeeklyInterval",
"WorkbookItem",
]

from .bin import _version

__version__ = _version.get_versions()["version"]
3 changes: 3 additions & 0 deletions tableauserverclient/bin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# generated during initial setup of versioneer
from . import _version
__version__ = _version.get_versions()['version']
5 changes: 2 additions & 3 deletions tableauserverclient/bin/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ class VersioneerConfig:

def get_config() -> VersioneerConfig:
"""Create, populate and return the VersioneerConfig() object."""
# these strings are filled in when 'setup.py versioneer' creates
# _version.py
# these strings are filled in from pyproject.toml at file generation time
cfg = VersioneerConfig()
cfg.VCS = "git"
cfg.style = "pep440-pre"
cfg.tag_prefix = "v"
cfg.parentdir_prefix = "None"
cfg.versionfile_source = "tableauserverclient/_version.py"
cfg.versionfile_source = "tableauserverclient/bin/_version.py"
cfg.verbose = False
return cfg

Expand Down
6 changes: 3 additions & 3 deletions tableauserverclient/models/column_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@


class ColumnItem:
def __init__(self, name, description=None):
def __init__(self, name=None, description=None):
self._id = None
self.description = description
self.name = name
self._name = name

def __repr__(self):
return f"<{self.__class__.__name__} {self._id} {self.name} {self.description}>"
return f"<{self.__class__.__name__} {self._id} {self._name} {self.description}>"

@property
def id(self):
Expand Down
Empty file added test/http/__init__.py
Empty file.
Empty file added test/models/__init__.py
Empty file.
41 changes: 32 additions & 9 deletions test/models/test_repr.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import inspect

from unittest import TestCase
import _models # type: ignore # did not set types for this
import tableauserverclient.models as TSC_models # type: ignore # did not set types for this
import tableauserverclient as TSC

from typing import Any


# ensure that all models that don't need parameters can be instantiated
# todo....
# ensure that all models can be instantiated
def instantiate_class(name: str, obj: Any):
# Get the constructor (init) of the class
constructor = getattr(obj, "__init__", None)
Expand All @@ -31,14 +30,38 @@ def instantiate_class(name: str, obj: Any):
print(f"Class '{name}' does not have a constructor (__init__ method).")


not_yet_done = [
"DQWItem",
"UnpopulatedPropertyError",
"FavoriteItem",
"FileuploadItem",
"FlowRunItem",
"IntervalItem",
"LinkedTaskItem",
"LinkedTaskStepItem",
"LinkedTaskFlowRunItem",
"Permission",
"SiteAuthConfiguration",
"Resource",
"TagItem",
"ExtractItem",
]


class TestAllModels(TestCase):
# not all models have __repr__ yet: see above list

# confirm that all models can be instantiated without params, and have __repr__ implemented
# not all do have __repr__ yet: see above list 'not_yet_done'
def test_repr_is_implemented(self):
m = _models.get_defined_models()
for model in m:
with self.subTest(model.__name__, model=model):
print(model.__name__, type(model.__repr__).__name__)
self.assertEqual(type(model.__repr__).__name__, "function")
m = TSC_models
for type_name in m.__dict__:
if type_name in not_yet_done:
continue
model = getattr(m, type_name)
if inspect.isclass(model):
with self.subTest(type_name):
self.assertTrue(hasattr(model, "__repr__"))
self.assertEqual(type(model.__repr__).__name__, "function")

# 2 - Iterate through the objects in the module
def test_by_reflection(self):
Expand Down
Loading