Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
test: setup pytest (#21)
Browse files Browse the repository at this point in the history
* build: add pytest as dev dependency

* test: exemplary unit test

* build: add pytest-cov as dev dependency

* chore: ignore outputs of pytest

* ci: run pytest on pull requests or pushes to main

* build: use older structure for dev dependencies
  • Loading branch information
lars-reimann authored Dec 5, 2021
1 parent b436e7b commit d9d3f62
Show file tree
Hide file tree
Showing 6 changed files with 552 additions and 133 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Main
on:
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./package_parser
strategy:
matrix:
python-version: [3.9]

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

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/[email protected]
with:
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install library
run: poetry install --no-interaction

# Requires installation of pytest and pytest-cov
- name: Test with pytest
run: poetry run pytest --doctest-modules --cov=package_parser --cov-report=html

- name: Upload test coverage
if: ${{ github.actor != 'dependabot[bot]' }}
uses: actions/upload-artifact@v2
with:
name: Test coverage
path: package_parser/htmlcov
58 changes: 58 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Pull Request

on:
pull_request:
branches: [main]

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

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./package_parser
strategy:
matrix:
python-version: [3.9]

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

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/[email protected]
with:
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install library
run: poetry install --no-interaction

# Requires installation of pytest and pytest-cov
- name: Test with pytest
run: poetry run pytest --doctest-modules --cov=package_parser --cov-report=html

- name: Upload test coverage
if: ${{ github.actor != 'dependabot[bot]' }}
uses: actions/upload-artifact@v2
with:
name: Test coverage
path: package_parser/htmlcov
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ __pycache__/
# Poetry distribution
dist/

# Pytest outputs
.pytest_cache/
htmlcov/
.coverage

# Output of this tool
out/

Expand Down
Loading

0 comments on commit d9d3f62

Please sign in to comment.