Skip to content
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

Add pr workflow #39

Merged
merged 6 commits into from
May 4, 2021
Merged
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
36 changes: 36 additions & 0 deletions .github/workflows/publish_to_pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish distribution to PyPI

on:
release:
types: [published]

jobs:
build-and-publish:
name: Build and publish distribution to PyPI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: PR

on:
pull_request:
branches:
- "master"

jobs:
python-dependencies:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Pipenv
run: pip install pipenv==2020.11.15
- name: Cache virtualenv
id: cache-virtualenv
uses: actions/cache@v2
with:
path: ~/.local/share/virtualenvs/
key: ${{ runner.os }}-${{ matrix.python-version }}-virtualenvs-${{ hashFiles('Pipfile.lock') }}
- name: Install virtual environment
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
run: pipenv install --dev

test-unit:
needs: python-dependencies
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install pipenv
run: pip install pipenv==2020.11.15
- name: Cache virtualenv
id: cache-virtualenv
uses: actions/cache@v2
with:
path: ~/.local/share/virtualenvs/
key: ${{ runner.os }}-${{ matrix.python-version }}-virtualenvs-${{ hashFiles('Pipfile.lock') }}
- name: Install virtual environment
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
run: pipenv install --dev
- name: Running unit tests
run: pipenv run make test
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
### Unreleased
- Deprecate Travis CI integration
- Add Github Actions workflows

### 1.0.9
- Release to facilitate a Travis Pypi deployment.
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta:__legacy__"
24 changes: 15 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@
# For pip installations
version = str(
ast.literal_eval(
open(os.path.join(
os.path.dirname(__file__),
"sdc", "crypto", "__init__.py"),
'r').read().split("=")[-1].strip()
open(
os.path.join(os.path.dirname(__file__), "sdc", "crypto", "__init__.py"),
"r",
)
.read()
.split("=")[-1]
.strip()
)
)

with open("./README.md") as fp:
description = fp.read()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem to work but I'm not sure how relevant the info is in the Pypi package long description.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In lieu of another long description and the fact it needs a value to suppress the warning it'll probably do. There are other examples in Pypi where the README is simply used here.


# For more info on pipenv and setuptools - https://realpython.com/pipenv-guide/#package-distribution
# and https://pipenv.readthedocs.io/en/latest/advanced/#pipfile-vs-setup-py
setup(
Expand All @@ -28,7 +34,8 @@
description="A shared library for SDC services that use JWT with JWE",
author="ONS",
url="https://github.com/ONSdigital/sdc-cryptography",
long_description=__doc__,
long_description=description,
long_description_content_type="text/markdown",
classifiers=[
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.6",
Expand All @@ -41,12 +48,11 @@
"sdc.crypto",
"sdc.crypto.scripts",
],
scripts=['sdc/crypto/scripts/generate_keys.py'],
scripts=["sdc/crypto/scripts/generate_keys.py"],
install_requires=["jwcrypto", "cryptography", "PyYAML"],
entry_points={
"console_scripts": [
],
"console_scripts": [],
},
namespace_packages=["sdc"],
zip_safe=False
zip_safe=False,
)