diff --git a/.github/workflows/build-and-deploy-on-pypi.yml b/.github/workflows/build-and-deploy-on-pypi.yml new file mode 100644 index 0000000..74a5d73 --- /dev/null +++ b/.github/workflows/build-and-deploy-on-pypi.yml @@ -0,0 +1,53 @@ +name: PyPi Build and Deploy 🐍📦 + +on: + release: + types: [published] + # use this for testing + push: + branches: + - main + +jobs: + build-n-publish: + name: Build and publish MyProxyClient on PyPi + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/MyProxyClient/ + # use the new Trusted Publishers feature + # details at https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/ + # to add a PyPI project to Trusted Publishers, see + # https://docs.pypi.org/trusted-publishers/adding-a-publisher/ + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: "3.12" + - name: Install pep517 + run: >- + python -m + pip install + pep517 + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + pep517.build + --source + --binary + --out-dir dist/ + . + # - name: Publish distribution 📦 to Test PyP + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # repository-url: https://test.pypi.org/legacy/ + - name: Publish distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..7f33d31 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,38 @@ +name: Test + +on: + push: + branches: + - main + schedule: + - cron: '0 0 * * *' # nightly + +# Required shell entrypoint to have properly configured bash shell +defaults: + run: + shell: bash -l {0} + +jobs: + linux: + runs-on: "ubuntu-latest" + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + fail-fast: false + name: Linux Python ${{ matrix.python-version }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: myproxy + environment-file: environment-test.yml + python-version: ${{ matrix.python-version }} + miniforge-version: "latest" + miniforge-variant: Mambaforge + use-mamba: true + - run: conda --version + - run: python -V + - run: pip install -e . + - run: pytest tests/unit/test_simple.py diff --git a/.gitignore b/.gitignore index 0c0f496..b0ac4e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ MyProxyClient.egg-info/ build/ dist/ +__pycache__/ diff --git a/environment-test.yml b/environment-test.yml new file mode 100644 index 0000000..b2010b1 --- /dev/null +++ b/environment-test.yml @@ -0,0 +1,9 @@ +--- +name: myproxy +channels: + - conda-forge + - nodefaults + +dependencies: + - pip + - pytest diff --git a/myproxy/client/utils/__init__.py b/myproxy/client/utils/__init__.py index 72b5589..4438b71 100644 --- a/myproxy/client/utils/__init__.py +++ b/myproxy/client/utils/__init__.py @@ -12,7 +12,7 @@ class CaseSensitiveConfigParser(ConfigParser): - '''Subclass the SafeConfigParser - to preserve the original string case of + '''Subclass ConfigParser - to preserve the original string case of config section names ''' def optionxform(self, optionstr): diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..941ddb7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools >= 40.6.0", "wheel", "setuptools_scm>=6.2"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index 602006c..41ea271 100644 --- a/setup.py +++ b/setup.py @@ -44,6 +44,7 @@ version = '2.1.1', description = 'MyProxy Client', long_description = LONG_DESCR, + long_description_content_type='text/markdown', author = 'Philip Kershaw', author_email = 'Philip.Kershaw@stfc.ac.uk', maintainer = 'Philip Kershaw', diff --git a/tests/unit/test_simple.py b/tests/unit/test_simple.py new file mode 100644 index 0000000..bb58c5d --- /dev/null +++ b/tests/unit/test_simple.py @@ -0,0 +1,26 @@ +from myproxy.client import MyProxyClient + + +def test_members(): + """Test public method members of MyProxyClient.""" + expected_members = [ + 'caCertDir', 'changePassphrase', 'destroy', 'getDelegation', + 'getTrustRoots', 'hostname', 'info', 'locateClientCredentials', + 'logon', 'openSSLConfFilePath', 'openSSLConfig', 'parseConfig', + 'port', 'proxyCertLifetime', 'proxyCertMaxLifetime', 'put', + 'readProxyFile', 'serverDN', 'setDefaultCACertDir', + 'ssl_verification', 'store', 'writeProxyFile' + ] + actual_members = dir(MyProxyClient) + for member in expected_members: + assert member in actual_members + + +def test_simple(): + """Test a simple instance of MyProxyClient.""" + hostname = "example.com" + c = MyProxyClient(hostname=hostname, caCertDir="") + assert c.hostname == "example.com" + assert not c.caCertDir + assert c.proxyCertLifetime == 43200 + assert not c.serverDN