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

test: Creation of a test suite #85

Open
wants to merge 12 commits into
base: 2.0.0
Choose a base branch
from
Open
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
176 changes: 176 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
name: Static analysis and tests

on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

env:
VENV_PATH: ~/.venv
REPORT_PATH: tests/data/reports/


jobs:
setup-env:
name: Setup and cache environment
permissions:
contents: read
runs-on: ubuntu-latest

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

- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.10

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.venv
key: ${{ runner.os }}-pip-${{ hashFiles('**/test-requirements.txt') }}

- name: Install dependencies
run: |
python -m venv ~/.venv
source ~/.venv/bin/activate
python -m pip install --upgrade pip
python -m pip install .
python -m pip install -r test-requirements.txt

formatting:
name: Formatting
permissions:
contents: read
needs: setup-env
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Restore pip dependencies
uses: actions/cache@v2
with:
path: ~/.venv
key: ${{ runner.os }}-pip-${{ hashFiles('**/test-requirements.txt') }}

- name: Check imports and formatting
run: |
source ~/.venv/bin/activate
isort --check-only --diff --profile black .
black --check --diff .

Linting:
name: Linting
permissions:
contents: read
needs: setup-env
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Restore pip dependencies
uses: actions/cache@v2
with:
path: ~/.venv
key: ${{ runner.os }}-pip-${{ hashFiles('**/test-requirements.txt') }}

# C0301: Line too long
- name: Run pylint
run: |
source ~/.venv/bin/activate
pylint --fail-under=9 --disable=C0301 AmpliGone/ tests/ > ${{ env.REPORT_PATH }}pylint-report.txt

# E501: Line too long, W503: Line break before binary operator, E203: Whitespace before ':'
# The last two make it non-PEP8 compliant, but are automatically done by black.
- name: Run flake8
run: |
source ~/.venv/bin/activate
flake8 --ignore=E501,W503,E203 AmpliGone/ tests/ --output-file=${{ env.REPORT_PATH }}flake8-report.txt

static-checking:
name: Static checking
permissions:
contents: read
needs: setup-env
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Restore pip dependencies
uses: actions/cache@v2
with:
path: ~/.venv
key: ${{ runner.os }}-pip-${{ hashFiles('**/test-requirements.txt') }}

- name: Run mypy
run: |
source ~/.venv/bin/activate
mypy --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports --disallow-untyped-decorators --strict-equality \
--warn-redundant-casts --warn-unused-ignores --warn-return-any --warn-unreachable AmpliGone/ tests/ > ${{ env.REPORT_PATH }}mypy-report.txt

- name: Run bandit
run: |
source ~/.venv/bin/activate
bandit -r AmpliGone/ -f json -o ${{ env.REPORT_PATH }}bandit-report.json

run-tests:
name: Run Tests
permissions:
contents: read
needs: setup-env
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Restore pip dependencies
uses: actions/cache@v2
with:
path: ~/.venv
key: ${{ runner.os }}-pip-${{ hashFiles('**/test-requirements.txt') }}

- name: Run tests
run: |
source ~/.venv/bin/activate
pytest -sv --cov=AmpliGone/ --cov-report=xml:tests/data/reports/coverage.xml tests/

- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: tests/data/reports/coverage.xml

sonarcloud:
name: SonarCloud Scan
needs: run-tests
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for SonarCloud analysis

- name: Download coverage report
uses: actions/download-artifact@v3
with:
name: coverage-report
path: tests/data/coverage_reports/coverage.xml

- name: SonarCloud Scan
if: always()
uses: sonarsource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # needed to get PR info
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ htmlcov/
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
Expand Down Expand Up @@ -132,4 +131,6 @@ dmypy.json
# IDE
.vscode/
test/
notes.txt
notes.txt

*:Zone.Identifier
14 changes: 14 additions & 0 deletions AmpliGone/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
"""
AmpliGone: A tool which accurately finds and removes primer sequences from NGS reads in an amplicon experiment.

Attributes
----------
__version__ : str
The current version of the AmpliGone package.

__prog__ : str
The name of the AmpliGone program.
"""

# pylint: disable=C0103
# AmpliGone package name is not following snake_case naming convention
__version__ = "1.3.0"
__prog__ = "AmpliGone"
Loading