forked from philipkershaw/MyProxyClient
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from cedadev/add_pypi_pkg_build_GA
Add Github Actions workflow that builds a PyPI package (and deploys it on PyPI if Github release) + simple test with barebones conda environment file
- Loading branch information
Showing
8 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
MyProxyClient.egg-info/ | ||
build/ | ||
dist/ | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
name: myproxy | ||
channels: | ||
- conda-forge | ||
- nodefaults | ||
|
||
dependencies: | ||
- pip | ||
- pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["setuptools >= 40.6.0", "wheel", "setuptools_scm>=6.2"] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |