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

CICD Improvements #101

Merged
merged 26 commits into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
71f12ff
add optional binary distribution to setup.py
harelwa Feb 24, 2022
a106b2f
move pytest configuration to tox.ini
harelwa Feb 24, 2022
ae59a2c
add coverage report task to makefile
harelwa Feb 24, 2022
701eb0c
add coverage and publish jobs to gh-workflow
harelwa Feb 24, 2022
8a9e383
add conda-forge shield to README
harelwa Feb 25, 2022
415475a
fix coverage combine
harelwa Mar 7, 2022
82a73f1
add more docs
harelwa Mar 7, 2022
891836a
fix workflow
harelwa Mar 7, 2022
351a33a
remove coverage combine --keep
harelwa Mar 7, 2022
756db3d
remove converage configuration from setup.cfg
harelwa Mar 8, 2022
61b12bc
Update setup.py
harelwa Mar 8, 2022
1c5589c
fix tox usage example
harelwa Mar 11, 2022
7259d93
add os to build matrix with linux, macos, windows
harelwa Mar 11, 2022
a232de6
add os to COVERAGE_FILE path for CI
harelwa Mar 11, 2022
f0122aa
consolidate cicd ghwf
harelwa Mar 18, 2022
235860c
revert to dotted suffix coverage files
harelwa Mar 18, 2022
a14f862
test publish conditions
harelwa Mar 18, 2022
4818c3e
tox: faster lint task ( skip_install = true )
harelwa Mar 18, 2022
170b229
wf cosmetics
harelwa Mar 18, 2022
4f28168
docs fix
harelwa Mar 18, 2022
d34c4b7
remove prev publish workflow
harelwa Mar 19, 2022
fb1b835
Merge branch 'argoproj-labs:main' into cicd-improvements
harelwa Mar 19, 2022
950af97
Update README.md
harelwa Mar 21, 2022
b47ade3
refactor workflow file name
harelwa Mar 25, 2022
0014633
Publish to official PyPI index
flaviuvadan Mar 27, 2022
f299da7
Format
flaviuvadan Mar 27, 2022
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
91 changes: 89 additions & 2 deletions .github/workflows/hera_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Hera PR build
on: pull_request

jobs:
hera-pr-build:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the job name representative of the distribution that is going to be built? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand - by distribution you mean linux ?

Is this question maybe related to #101 (comment) ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, thank you for clarifying! 🙂

build-linux:

timeout-minutes: 10

Expand All @@ -25,7 +25,7 @@ jobs:

- name: Install base dependencies
run: |
python -m pip install --upgrade "tox<4.0"
python -m pip install --upgrade "tox<4.0" tox-wheel twine

- name: Run lint
env:
Expand All @@ -41,6 +41,93 @@ jobs:

- name: Run tests
env:
ENABLE_BDIST_EXT_MODULE: 'yes'
TOXENV: python${{ matrix.python-version }}
run: |
tox

- name: Check build
run: |
twine check .tox/dist/*

- name: upload build artifacts
uses: actions/upload-artifact@v2
with:
name: pypi-build-arts
path: .tox/dist
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to publish the constructed distributions as artifacts. To be clear, these are different than the actually published package, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not quite. If we consolidate to a single GH workflow like I suggested, the build ( and test ) job will run as a dependency of publish job on push to main as well ( see more in #101 (comment) ), and thus provide us with the necessary Distribution builds ( wheels ) - As you can see Distribution builds added to setup.py are OS + Py version specific.

HOWEVER ! what's usually done, is building also a py-none-any wheel + tar.gz and publishing it as well ( like hera publishes now ), e.g. ( from https://pypi.org/project/pydantic/ )

Screen Shot 2022-03-11 at 4 44 18 PM


- name: upload coverage files
uses: actions/upload-artifact@v2
with:
name: coverage-data
path: ".tox/.coverage.*"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the publication of coverage files allow one to construct a test coverage GitHub badge? I am a bit unfamiliar with the necessary setup of coverage so I am very excited this is added, and I would love to see the report on the main repo README! I must say a direct thank you here, as a comment, for the efforts 🚀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With pleasure.

Yes, we are definitely going for a n honorable shield.

See coverage in #101 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

Great 👍


coverage:
needs: [build-linux]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up python 3.7
uses: actions/setup-python@v2
with:
python-version: '3.7'

- name: get coverage files
uses: actions/download-artifact@v2
with:
name: coverage-data
path: .tox

- name: list coverage files
run: |
find .tox -name ".coverage*"

- name: install tox
run: |
python -m pip install --upgrade tox

- name: create coverage report
env:
TOXENV: coverage
run: |
tox

- name: upload coverage HTML report
uses: actions/upload-artifact@v2
with:
name: html-report
path: .tox/htmlcov

publish:
needs: [coverage]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up python 3.7
uses: actions/setup-python@v2
with:
python-version: '3.7'

- name: get pypi build arts
uses: actions/download-artifact@v2
with:
name: pypi-build-arts
path: dist

- name: list pypi build arts
run: |
ls -la dist/

- name: install twine
run: |
python -m pip install --upgrade twine

- name: Check build
run: |
twine check dist/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a check of the built distribution published via the PR, correct?

Copy link
Contributor Author

@harelwa harelwa Mar 11, 2022

Choose a reason for hiding this comment

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

EDITED

Yes. It's not published though. It's uploaded, and then downloaded in publish job, where it will be published if event is push to main ( change not pushed yet ) this is related to #101 (comment)

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ typecheck:
mypy --namespace-packages tests

test:
pytest --durations=5 $(TEST_FOLDER)
pytest -c tox.ini $(TEST_FOLDER)

verify: lint typecheck test
echo "Lint, typecheck, test successfully completed!"
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and its crew were specially protected by the goddess Hera.

[![Build](https://github.com/argoproj-labs/hera-workflows/actions/workflows/hera_build_and_publish.yaml/badge.svg)](https://github.com/argoproj-labs/hera-workflows/blob/main/.github/workflows/hera_build_and_publish.yaml)
[![Pypi](https://img.shields.io/pypi/v/hera-workflows.svg)](https://pypi.python.org/pypi/hera-workflows)
[![CondaForge](https://img.shields.io/conda/v/conda-forge/hera-workflows.svg)](https://anaconda.org/conda-forge/hera-workflows)
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚀

[![Downloads](https://pepy.tech/badge/hera-workflows)](https://pepy.tech/project/hera-workflows)
[![Downloads/month](https://pepy.tech/badge/hera-workflows/month)](https://pepy.tech/project/hera-workflows)
[![Downloads/week](https://pepy.tech/badge/hera-workflows/week)](https://pepy.tech/project/hera-workflows)
Expand Down Expand Up @@ -94,12 +95,24 @@ In you activated `pipenv` shell, you can utilize the tasks found in `Makefile`,
make test
```

To run tests on all supported python versions run [tox](https://tox.wiki/en/latest/):
To run tests on all supported python versions with coverage run [tox](https://tox.wiki/en/latest/):

```shell
tox
```

To run tests for a specific python version with coverage run:

```shell
tox -e python3.7 coverage
```

To list all available `tox` envs run:

```shell
tox -a
```

> See project `tox.ini` for more details
harelwa marked this conversation as resolved.
Show resolved Hide resolved

Also, see the [contributing guide](https://github.com/argoproj-labs/hera-workflows/blob/main/CONTRIBUTING.md)!
Expand Down
5 changes: 0 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
[pytest]
addopts = --cov=hera -vv
# for now, keep this commented out, as it's used explicitly in Makefile
; testpaths = tests

[flake8]
exclude = # do not look here for things to lint
.git
Expand Down
24 changes: 22 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
from setuptools import find_namespace_packages, setup
import os
from setuptools import setup, Distribution

VERSION = open('VERSION').read().strip()
LONG_DESCRIPTION = open('README.md').read()


class BinaryDistribution(Distribution):
"""Distribution which enables a binary package with platform name

Will build `none-any` wheels by default, e.g. -

hera_workflows-1.8.0-py3-none-any.whl

If the env var ENABLE_BDIST_EXT_MODULE=yes is defined built wheel will have platform and
python version info, e.g. -
Used to create wheels for specific OS and Python version, e.g. -

hera_workflows-1.8.0-cp37-cp37m-macosx_10_9_x86_64.whl
"""
def has_ext_modules(foo):
return os.environ.get('ENABLE_BDIST_EXT_MODULE') == 'yes'


setup(
name='hera-workflows',
version=VERSION,
Expand Down Expand Up @@ -45,6 +64,7 @@
"certifi",
"pytz"
],
zip_safe=False
zip_safe=False,
distclass=BinaryDistribution
)

44 changes: 40 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
[tox]
envlist = python{3.7,3.8,3.9,3.10}
envlist = python{3.7,3.8,3.9,3.10},coverage

[pytest]
addopts = --durations=5 -vv

[coverage:run]
branch = true
parallel = true

[coverage:report]
skip_covered = True
show_missing = True

[coverage:paths]
source = src/hera
*/.tox/*/lib/python*/site-packages/hera
*/.tox/pypy*/site-packages/hera
*/.tox\*\Lib\site-packages\hera
*/src/hera
*\src\hera

[testenv]
wheel = true
allowlist_externals =
make
setenv =
ENABLE_BDIST_EXT_MODULE = {env:ENABLE_BDIST_EXT_MODULE:no}
COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
deps =
pytest
pytest-cov
commands=
make test
pytest \
--cov "{envsitepackagesdir}/hera" \
--cov-config "{toxinidir}/tox.ini"

[testenv:coverage]
setenv =
COVERAGE_FILE = {toxworkdir}/.coverage
skip_install = true
deps =
coverage
commands =
coverage combine
coverage report -m
coverage xml -o {toxworkdir}/coverage.xml
coverage html -d {toxworkdir}/htmlcov
depends = python3.7, python3.8, python3.9, python3.10

[testenv:lint]
skipsdist = True
Expand Down