From a65b4ce33a8891c5c7ff931d30573f8fb067f385 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Mon, 13 Nov 2023 16:40:29 +0000 Subject: [PATCH 01/19] add pypi pkg build GA --- .../workflows/build-and-deploy-on-pypi.yml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/build-and-deploy-on-pypi.yml 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..d20aca0 --- /dev/null +++ b/.github/workflows/build-and-deploy-on-pypi.yml @@ -0,0 +1,48 @@ +name: PyPi Build and Deploy 🐍📦 + +on: + release: + types: [published] + # use this for testing + push: + branches: + - main + - add_pypi_pkg_build_GA + +jobs: + build-n-publish: + name: Build and publish MyProxyClient on PyPi + runs-on: ubuntu-latest + 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 PyPI + # uses: pypa/gh-action-pypi-publish@master + # with: + # password: ${{ secrets.test_pypi_password }} + # 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 + with: + user: __token__ + password: ${{ secrets.pypi_password }} From ef5f861707fd46b2aa9c55a323c2b16f1ff183d8 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Mon, 13 Nov 2023 16:48:41 +0000 Subject: [PATCH 02/19] add pyproject toml barebones file --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pyproject.toml 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" From cf7abedf2da3d0e2e8587ad1bbc934dd844b600e Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Mon, 13 Nov 2023 16:53:30 +0000 Subject: [PATCH 03/19] unrun GA --- .github/workflows/build-and-deploy-on-pypi.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-on-pypi.yml b/.github/workflows/build-and-deploy-on-pypi.yml index d20aca0..a9a7eaf 100644 --- a/.github/workflows/build-and-deploy-on-pypi.yml +++ b/.github/workflows/build-and-deploy-on-pypi.yml @@ -7,7 +7,6 @@ on: push: branches: - main - - add_pypi_pkg_build_GA jobs: build-n-publish: From 3e126680b708d8a2b9ff4b8c269b21bf7678dd6a Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 14 Nov 2023 15:59:42 +0000 Subject: [PATCH 04/19] use trusted publishers as Bouwe recommended --- .github/workflows/build-and-deploy-on-pypi.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-deploy-on-pypi.yml b/.github/workflows/build-and-deploy-on-pypi.yml index a9a7eaf..c30a0cb 100644 --- a/.github/workflows/build-and-deploy-on-pypi.yml +++ b/.github/workflows/build-and-deploy-on-pypi.yml @@ -12,6 +12,11 @@ jobs: build-n-publish: name: Build and publish MyProxyClient on PyPi runs-on: ubuntu-latest + # use the new Trusted Publishers feature + # details at https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/ + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write steps: - uses: actions/checkout@v3 with: @@ -42,6 +47,8 @@ jobs: - name: Publish distribution 📦 to PyPI if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.pypi_password }} + # this is the old token and password way; + # we are using the new Truster Publishers (see above) + # with: + # user: __token__ + # password: ${{ secrets.pypi_password }} From 74c72faabb564cf7a48944559824221a309d9e81 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 14 Nov 2023 16:10:04 +0000 Subject: [PATCH 05/19] a couple more bits for trusted publishers --- .github/workflows/build-and-deploy-on-pypi.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-and-deploy-on-pypi.yml b/.github/workflows/build-and-deploy-on-pypi.yml index c30a0cb..3841716 100644 --- a/.github/workflows/build-and-deploy-on-pypi.yml +++ b/.github/workflows/build-and-deploy-on-pypi.yml @@ -12,8 +12,14 @@ jobs: build-n-publish: name: Build and publish MyProxyClient on PyPi runs-on: ubuntu-latest + # may also need this for publishing? + 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 From 6922e7a1556683b2f0736c4deafe14d94d804172 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 14:20:17 +0000 Subject: [PATCH 06/19] replace obsolete SafeConfigParser with ConfigParser in docstring --- myproxy/client/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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): From 5147ee093a42becebf9067b7a2279f6abfaf8aa8 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 15:33:33 +0000 Subject: [PATCH 07/19] add a barebones conda env file --- environment-test.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 environment-test.yml 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 From 4d9385468623f50013b2a653056373d02688ad25 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 15:34:00 +0000 Subject: [PATCH 08/19] adda barebones unit test module --- .github/workflows/run-tests.yml | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..06417b9 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,39 @@ +name: Test + +on: + push: + branches: + - main + - add_pypi_pkg_build_GA + 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 From e9fe36e6c1ecac9300e140b977e5923f55318d50 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 15:34:48 +0000 Subject: [PATCH 09/19] adda barebones unit test module --- tests/unit/test_simple.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/unit/test_simple.py diff --git a/tests/unit/test_simple.py b/tests/unit/test_simple.py new file mode 100644 index 0000000..b277159 --- /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 = "www.google.com" + c = MyProxyClient(hostname=hostname, caCertDir="") + assert c.hostname == "www.google.com" + assert not c.caCertDir + assert c.proxyCertLifetime == 43200 + assert not c.serverDN From 67157e61f7cc01b3b40d3d39ad98bfcc4e0bd13b Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 15:35:57 +0000 Subject: [PATCH 10/19] add to gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 0c0f496..41933cc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ MyProxyClient.egg-info/ build/ dist/ +myproxy/client/__pycache__/ +myproxy/client/utils/__pycache__/ +tests/unit/__pycache__/ From a176207cf42eef7e8546ca2ca3f3054b642f66d0 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 15:38:49 +0000 Subject: [PATCH 11/19] unrun GA --- .github/workflows/run-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 06417b9..7f33d31 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - add_pypi_pkg_build_GA schedule: - cron: '0 0 * * *' # nightly From 96a83d12224b68aaa4a8c3afd1b13cdbbc4d5f79 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 16:04:15 +0000 Subject: [PATCH 12/19] Update .gitignore Co-authored-by: Bouwe Andela --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 41933cc..b0ac4e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ MyProxyClient.egg-info/ build/ dist/ -myproxy/client/__pycache__/ -myproxy/client/utils/__pycache__/ -tests/unit/__pycache__/ +__pycache__/ From 44ed68aa8230fc79aace0fd0275559587dc29406 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 16:11:53 +0000 Subject: [PATCH 13/19] cleanup and trigger pubish to test PyPI --- .github/workflows/build-and-deploy-on-pypi.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-and-deploy-on-pypi.yml b/.github/workflows/build-and-deploy-on-pypi.yml index 3841716..cbadcd6 100644 --- a/.github/workflows/build-and-deploy-on-pypi.yml +++ b/.github/workflows/build-and-deploy-on-pypi.yml @@ -45,16 +45,8 @@ jobs: --binary --out-dir dist/ . - #- name: Publish distribution 📦 to Test PyPI - # uses: pypa/gh-action-pypi-publish@master - # with: - # password: ${{ secrets.test_pypi_password }} - # repository_url: https://test.pypi.org/legacy/ + - name: Publish distribution 📦 to Test PyP + uses: pypa/gh-action-pypi-publish@master - name: Publish distribution 📦 to PyPI if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 - # this is the old token and password way; - # we are using the new Truster Publishers (see above) - # with: - # user: __token__ - # password: ${{ secrets.pypi_password }} From 8901043ed26822fe7f97e0260e2db5a36a648f58 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 16:13:13 +0000 Subject: [PATCH 14/19] mod test to use generic imaginary domain --- tests/unit/test_simple.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_simple.py b/tests/unit/test_simple.py index b277159..bb58c5d 100644 --- a/tests/unit/test_simple.py +++ b/tests/unit/test_simple.py @@ -18,9 +18,9 @@ def test_members(): def test_simple(): """Test a simple instance of MyProxyClient.""" - hostname = "www.google.com" + hostname = "example.com" c = MyProxyClient(hostname=hostname, caCertDir="") - assert c.hostname == "www.google.com" + assert c.hostname == "example.com" assert not c.caCertDir assert c.proxyCertLifetime == 43200 assert not c.serverDN From 5d71bf400054267193d8a241e6609b714b34edc6 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 16:30:35 +0000 Subject: [PATCH 15/19] test upload to Test PyPI --- .github/workflows/build-and-deploy-on-pypi.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-deploy-on-pypi.yml b/.github/workflows/build-and-deploy-on-pypi.yml index cbadcd6..ab187da 100644 --- a/.github/workflows/build-and-deploy-on-pypi.yml +++ b/.github/workflows/build-and-deploy-on-pypi.yml @@ -7,6 +7,7 @@ on: push: branches: - main + - add_pypi_pkg_build_GA jobs: build-n-publish: From cc4dd2d4dc95b1c73193ce3e814eb6c4c7cf39c4 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 16:37:35 +0000 Subject: [PATCH 16/19] set correct publish action you doofus --- .github/workflows/build-and-deploy-on-pypi.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-on-pypi.yml b/.github/workflows/build-and-deploy-on-pypi.yml index ab187da..ea157e2 100644 --- a/.github/workflows/build-and-deploy-on-pypi.yml +++ b/.github/workflows/build-and-deploy-on-pypi.yml @@ -47,7 +47,9 @@ jobs: --out-dir dist/ . - name: Publish distribution 📦 to Test PyP - uses: pypa/gh-action-pypi-publish@master + 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 From 47c1a54c75f69e5c575a47a4a93479d9a7e4b721 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 17:04:44 +0000 Subject: [PATCH 17/19] add long descr context in setup py as per advice from Bouwe --- setup.py | 1 + 1 file changed, 1 insertion(+) 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', From 4f7d057b24e95be134823b8cbbf0dc447468bb4a Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 17:08:17 +0000 Subject: [PATCH 18/19] remove comment and comment out Test PyPI upload bits --- .github/workflows/build-and-deploy-on-pypi.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-deploy-on-pypi.yml b/.github/workflows/build-and-deploy-on-pypi.yml index ea157e2..db1461f 100644 --- a/.github/workflows/build-and-deploy-on-pypi.yml +++ b/.github/workflows/build-and-deploy-on-pypi.yml @@ -13,7 +13,6 @@ jobs: build-n-publish: name: Build and publish MyProxyClient on PyPi runs-on: ubuntu-latest - # may also need this for publishing? environment: name: pypi url: https://pypi.org/project/MyProxyClient/ @@ -46,10 +45,10 @@ jobs: --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 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 From 4b7f8659b654297c818974f53d668c9ce4ba655c Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 21 Nov 2023 17:09:48 +0000 Subject: [PATCH 19/19] unrun GA --- .github/workflows/build-and-deploy-on-pypi.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-on-pypi.yml b/.github/workflows/build-and-deploy-on-pypi.yml index db1461f..74a5d73 100644 --- a/.github/workflows/build-and-deploy-on-pypi.yml +++ b/.github/workflows/build-and-deploy-on-pypi.yml @@ -7,7 +7,6 @@ on: push: branches: - main - - add_pypi_pkg_build_GA jobs: build-n-publish: