Skip to content

Commit

Permalink
Add CI/CD to the repo (#5)
Browse files Browse the repository at this point in the history
* adds cd_ci routines

* Adds dependabot and labeler

* Removes wildcard asterisk

* Removes wildcard asterisk

* Allows upper or lower case in regular expression

* Allows upper or lower case in regular expression

* Changes test output to adapt for pytest-plugin outputs

* Changes test output to adapt for pytest-plugin outputs

* Changes test output to adapt for pytest-plugin outputs

* Changes test output to adapt for pytest-plugin outputs

* Working on the CD/CI

* Move plugin to its own folder to fix coverage report

* Move plugin to its own folder to fix coverage report

* Fix typo

* Uses regex for wheel name

* Changes software report to pytest-pyvista

* Apply suggestions from code review

Co-authored-by: Maxime Rey <[email protected]>

* Explains entry_point variable

Co-authored-by: Maxime Rey <[email protected]>
  • Loading branch information
AlejandroFernandezLuces and MaxJPRey authored Nov 18, 2022
1 parent 1971196 commit eafb8fb
Show file tree
Hide file tree
Showing 8 changed files with 218 additions and 6 deletions.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
insecure-external-code-execution: allow
schedule:
interval: "daily"
labels:
- "maintenance"
- "dependencies"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
labels:
- "maintenance"
- "dependencies"
18 changes: 18 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
documentation:
- doc/**/*
- examples/**/*
- ./*.md
- ./*.rst
maintenance:
- .github/**/*
- codecov.yml
- .flake8
- .coveragerc
- .codecimate.yml
- ignore_words.txt
- mypy.ini
- pyproject.toml
- setup.py
dependencies:
- requirements*
- environment.yml
122 changes: 122 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Unit Testing and Deployment

on:
pull_request:
workflow_dispatch:
push:
tags:
- "*"
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
ALLOW_PLOTTING: true
SHELLOPTS: 'errexit:pipefail'

jobs:
Linux:
name: Linux Unit Testing
runs-on: ubuntu-latest
strategy:
fail-fast: false

matrix:
include:
- python-version: '3.7'
vtk-version: '8.1.2'
- python-version: '3.8'
vtk-version: '9.0.3'
- python-version: '3.9'
vtk-version: '9.1'
- python-version: '3.10'
vtk-version: 'latest'
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: requirements_test.txt

- uses: actions/cache@v3
with:
path: ~/.local/share/pytest-pyvista/examples
key: Examples-1-${{ hashFiles('*') }}
restore-keys: |
Examples-1-
- name: Build wheel and install pytest-pyvista
run: |
pip install wheel
python setup.py bdist_wheel
pip install dist/pytest_pyvista*.whl
- name: Set up vtk
if: ${{ matrix.vtk-version != 'latest' }}
run: pip install vtk==${{ matrix.vtk-version }}

- uses: awalsh128/[email protected]
with:
packages: libgl1-mesa-glx xvfb python-tk
version: 3.0

- name: Install Testing Requirements
run: pip install -r requirements_test.txt

- name: Software Report
run: |
xvfb-run python -c "import pytest_pyvista; pytest_pyvista"
which python
pip list
- name: Unit Testing
run: xvfb-run coverage run -m --source=pytest_pyvista --module pytest --verbose .
- uses: codecov/codecov-action@v3
if: matrix.python-version == '3.9'
name: 'Upload coverage to CodeCov'

release:
name: Release
if: |
github.event_name == 'push' &&
contains(github.ref, 'refs/tags') &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip build twine
- name: Build artifacts
run: |
python -m build && python -m twine check dist/*
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m twine upload --skip-existing ./**/*.whl
python -m twine upload --skip-existing ./**/*.tar.gz
- name: Publish to GitHub
uses: softprops/action-gh-release@v1
with:
files: |
./**/*.whl
./**/*.tar.gz
49 changes: 49 additions & 0 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "Pull Request Labeler"
on:
pull_request_target:
types: [opened, reopened]

jobs:
triage:
runs-on: ubuntu-latest
steps:
- name: Label based on changed files
uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
# https://github.com/actions/labeler/issues/112#issuecomment-1000491676
sync-labels: ''

# Label based on branch name
- uses: actions-ecosystem/action-add-labels@v1
if: startsWith(github.event.pull_request.head.ref, 'doc/') || startsWith(github.event.pull_request.head.ref, 'docs')
with:
labels: documentation
- uses: actions-ecosystem/action-add-labels@v1
if: startsWith(github.event.pull_request.head.ref, 'docker')
with:
labels: docker
- uses: actions-ecosystem/action-add-labels@v1
if: startsWith(github.event.pull_request.head.ref, 'maint') || startsWith(github.event.pull_request.head.ref, 'no-ci') || startsWith(github.event.pull_request.head.ref, 'ci')
with:
labels: maintenance
- uses: actions-ecosystem/action-add-labels@v1
if: startsWith(github.event.pull_request.head.ref, 'junk')
with:
labels: ignore-for-release
- uses: actions-ecosystem/action-add-labels@v1
if: startsWith(github.event.pull_request.head.ref, 'feat')
with:
labels: enhancement
- uses: actions-ecosystem/action-add-labels@v1
if: startsWith(github.event.pull_request.head.ref, 'fix') || startsWith(github.event.pull_request.head.ref, 'patch')
with:
labels: bug
- uses: actions-ecosystem/action-add-labels@v1
if: startsWith(github.event.pull_request.head.ref, 'release')
with:
labels: release
- uses: actions-ecosystem/action-add-labels@v1
if: startsWith(github.event.pull_request.head.ref, 'breaking-change')
with:
labels: breaking-change
File renamed without changes.
5 changes: 5 additions & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
codecov<2.2.0
coverage==6.5
pytest>=3.5.0
pytest-cov==4.0.0
pyvista==0.37
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def read(fname):
url="https://github.com/pyvista/pytest-pyvista",
description="Plugin to test PyVista plot outputs",
long_description=read("README.rst"),
long_description_content_type='text/x-rst',
long_description_content_type="text/x-rst",
py_modules=["pytest_pyvista"],
python_requires=">=3.7",
install_requires=["pytest>=3.5.0", "pyvista"],
install_requires=["pytest>=3.5.0"],
classifiers=[
"Development Status :: 4 - Beta",
"Framework :: Pytest",
Expand All @@ -40,8 +40,9 @@ def read(fname):
"License :: OSI Approved :: MIT License",
],
entry_points={
# Location of the plugin file, in this case ./pytest_pyvista/pytest_pyvista.py
"pytest11": [
"pyvista = pytest_pyvista",
"pyvista = pytest_pyvista.pytest_pyvista",
],
},
)
6 changes: 3 additions & 3 deletions tests/test_pyvista.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_args(verify_image_cache):
result = testdir.runpytest(
"--reset_image_cache", "--ignore_image_cache", "--fail_extra_image_cache"
)
result.stdout.fnmatch_lines("*Passed*")
result.stdout.fnmatch_lines("*[Pp]assed*")


def test_verify_image_cache(testdir):
Expand All @@ -35,7 +35,7 @@ def test_imcache(verify_image_cache):
)

result = testdir.runpytest()
result.stdout.fnmatch_lines("*Passed*")
result.stdout.fnmatch_lines("*[Pp]assed*")


def test_skip(testdir):
Expand All @@ -56,4 +56,4 @@ def test_imcache(verify_image_cache):
)

result = testdir.runpytest()
result.stdout.fnmatch_lines("*Passed*")
result.stdout.fnmatch_lines("*[Pp]assed*")

0 comments on commit eafb8fb

Please sign in to comment.