Skip to content

Commit

Permalink
Merge pull request #18 from wayfair-incubator/cantonellis_publish_0.1…
Browse files Browse the repository at this point in the history
….0rc

setup build and deploy action
  • Loading branch information
chrisantonellis authored Feb 17, 2021
2 parents b6191bd + b82836b commit 7b7d71c
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 84 deletions.
8 changes: 8 additions & 0 deletions .github/actions/build-dist/action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set -euo pipefail

echo "Ensuring pip is up to date"
python -m pip install --upgrade pip
echo "Installing the latest version of pypa/build"
pip install build

python -m build --sdist --wheel --outdir dist/ .
8 changes: 8 additions & 0 deletions .github/actions/build-dist/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: "Build Python package"
description: "Build a wheel and sdist for the package"
runs:
using: "composite"
steps:
- name: "Build wheel"
run: "$GITHUB_ACTION_PATH/action.sh"
shell: "bash"
9 changes: 2 additions & 7 deletions .github/actions/verify-wheel/action.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
set -euo pipefail

MODULE_NAME=$1
WHEEL_LOCATION=$2

echo "Ensuring pip is up to date"
python -m pip install --upgrade pip
echo "Installing the latest setuptools & wheel"
pip install --upgrade setuptools wheel

echo "--------------"
echo "Building wheel"
python setup.py bdist_wheel

APP_DIR=$(pwd)

# move into root dir so Python will import the installed package instead of the local source files
cd /
echo "------------------"
echo "Installing package"
pip install ${APP_DIR}/dist/*.whl
pip install ${APP_DIR}/${WHEEL_LOCATION}/*.whl

echo "-----------------------------"
echo "Attempting to import package"
Expand Down
8 changes: 6 additions & 2 deletions .github/actions/verify-wheel/action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
name: "Verify Python Wheel"
description: "Build a wheel for the package and importing the package doesn't cause an error"
description: "Verify importing the package doesn't cause an error"
inputs:
package-import-name:
description: "Name used to import the package from python code"
required: true
packages-dir:
description: The target directory for distribution
required: false
default: dist
runs:
using: "composite"
steps:
- name: "Verify wheel"
run: "$GITHUB_ACTION_PATH/action.sh ${{ inputs.package-import-name }}"
run: "$GITHUB_ACTION_PATH/action.sh ${{ inputs.package-import-name }} ${{ inputs.packages-dir }}"
shell: "bash"
136 changes: 69 additions & 67 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,138 +9,140 @@ env:

jobs:
bandit:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- name: Check out code
uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: "Check out code"
uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: "Install dependencies"
uses: "./.github/actions/install-dependencies"
with:
test-requirements: "true"

- name: Run bandit
run: bandit --ini .bandit -r little_cheesemonger
- name: "Run bandit"
run: "bandit --ini .bandit -r little_cheesemonger"

black:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: "Check out code"
uses: "actions/checkout@v2"
- name: "Set up Python"
uses: "actions/setup-python@v2"
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: "Install dependencies"
uses: "./.github/actions/install-dependencies"
with:
test-requirements: "true"

- name: Run black
run: black --check little_cheesemonger tests
- name: "Run black"
run: "black --check little_cheesemonger tests"

flake8:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- name: Check out code
uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: "Check out code"
uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: "Install dependencies"
uses: "./.github/actions/install-dependencies"
with:
test-requirements: "true"

- name: Run flake8
run: flake8 little_cheesemonger tests
- name: "Run flake8"
run: "flake8 little_cheesemonger tests"

isort:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- name: Check out code
uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: "Check out code"
uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: "Install dependencies"
uses: "./.github/actions/install-dependencies"
with:
requirements: "true"
test-requirements: "true"

- name: Run isort
run: isort --recursive --check-only little_cheesemonger tests
- name: "Run isort"
run: "isort --recursive --check-only little_cheesemonger tests"

mypy:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- name: Check out code
uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: "Check out code"
uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: "Install dependencies"
uses: "./.github/actions/install-dependencies"
with:
test-requirements: "true"

- name: Run mypy
run: mypy little_cheesemonger tests
- name: "Run mypy"
run: "mypy little_cheesemonger tests"

test:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- name: Check out code
uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: "Check out code"
uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: "Install dependencies"
uses: "./.github/actions/install-dependencies"
with:
requirements: "true"
test-requirements: "true"

- name: Run pytest
run: pytest tests/unit --cov-report xml:coverage-${{ matrix.python-version }}.xml --junitxml=test-results-${{ matrix.python-version }}.xml
- name: "Run pytest"
run: "pytest tests/unit --cov-report xml:coverage-${{ matrix.python-version }}.xml --junitxml=test-results-${{ matrix.python-version }}.xml"

- name: Upload pytest test results artifact
uses: actions/upload-artifact@v2
- name: "Upload pytest test results artifact"
uses: "actions/upload-artifact@v2"
with:
name: pytest-results-${{ matrix.python-version }}
path: test-results-${{ matrix.python-version }}.xml
name: "pytest-results-${{ matrix.python-version }}"
path: "test-results-${{ matrix.python-version }}.xml"
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}

- name: Upload coverage results artifact
uses: actions/upload-artifact@v2
- name: "Upload coverage results artifact"
uses: "actions/upload-artifact@v2"
with:
name: pytest-coverage-${{ matrix.python-version }}
path: coverage-${{ matrix.python-version }}.xml
name: 'pytest-coverage-${{ matrix.python-version }}'
path: 'coverage-${{ matrix.python-version }}.xml'
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}

- name: Publish coverage results to Codecov
uses: codecov/codecov-action@v1.0.13
- name: "Publish coverage results to Codecov"
uses: "codecov/codecov-action@v1.0.13"
with:
file: coverage-${{ matrix.python-version }}.xml
fail_ci_if_error: true
file: "coverage-${{ matrix.python-version }}.xml"
fail_ci_if_error: "true"

verify-wheel:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- name: Check out code
uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: "Check out code"
uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Verify wheel
uses: ./.github/actions/verify-wheel
- name: "Build wheel"
uses: "./.github/actions/build-dist"
- name: "Verify wheel"
uses: "./.github/actions/verify-wheel"
with:
package-import-name: "little_cheesemonger"
27 changes: 27 additions & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish Release
env:
PYTHON_VERSION: "3.9"
on:
release:
types: [published]
jobs:
build-and-publish-wheel-to-pypi:
runs-on: "ubuntu-latest"
environment: "Publish Release"
steps:
- name: "Check out code"
uses: "actions/checkout@v2"

- uses: "actions/setup-python@v2"
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: "Build wheel"
uses: "./.github/actions/build-dist"

# v1.4.2 release. Using full SHA for security
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
- name: "Publish distribution 📦 to PyPI"
uses: "pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29"
with:
password: ${{ secrets.PYPI_API_TOKEN }}
5 changes: 3 additions & 2 deletions little_cheesemonger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__version__ = "0.1.0"

from little_cheesemonger._errors import LittleCheesemongerError # noqa
from little_cheesemonger._run import run # noqa

__version__ = "0.1.0rc0"
13 changes: 7 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ long_description = file: README.md
long_description_content_type = text/markdown
license = See LICENSE
classifiers =
"Development Status :: 4 - Beta"
"Programming Language :: Python"
"Programming Language :: Python :: 3"
"Programming Language :: Python :: 3.6"
"Programming Language :: Python :: 3.7"
"Programming Language :: Python :: 3.8"
Development Status :: 4 - Beta
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9

[options]

Expand Down

0 comments on commit 7b7d71c

Please sign in to comment.