Skip to content

Commit

Permalink
Update Workflows (add build_wheels, codeql, main, test_coverage)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanbreimann committed Jul 23, 2024
1 parent fe7cef0 commit c94c75d
Show file tree
Hide file tree
Showing 36 changed files with 1,882 additions and 908 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Build wheels

on:
release:
types: [published]
workflow_dispatch:

jobs:
generate-wheels-matrix:
name: Generate wheels matrix
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v3
- name: Install cibuildwheel
run: pipx install cibuildwheel==2.14.0
- id: set-matrix
run: |
# ... (Keep this section as is in the original SHAP example)
build_wheels:
name: Build ${{ matrix.only }}
needs: generate-wheels-matrix
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }}
runs-on: ${{ matrix.os }}
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Build wheels
uses: pypa/[email protected]
with:
only: ${{ matrix.only }}

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
name: bdist_files

build_sdist:
name: Build source distribution
runs-on: ubuntu-20.04
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Build sdist (pep517)
run: |
python -m pip install build
python -m build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: sdist_files
path: dist/*.tar.gz

publish_wheels:
name: Publish wheels on pypi
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/download-artifact@v3
with:
name: bdist_files
path: dist
- uses: actions/download-artifact@v3
with:
name: sdist_files
path: dist
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/codeql_analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CodeQL

on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: '0 0 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: "python"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

code-quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.9-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-3.9-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 mypy pylint
- name: Run flake8 (check style)
run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics

- name: Run mypy (check static typing)
run: mypy xomics/__init__.py --follow-imports=skip
45 changes: 45 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Unit Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
- name: Run Tests
run: pytest tests
env:
HYPOTHESIS_DEADLINE: 10000000
MPLBACKEND: Agg
44 changes: 0 additions & 44 deletions .github/workflows/python-package.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test Coverage

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Run tests with coverage and generate XML report
run: |
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: true
env:
MPLBACKEND: Agg
10 changes: 1 addition & 9 deletions xomics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
plot_enrich_map,
plot_prank,
plot_prank_scatter,
plot_imput_histo,
plot_settings,
plot_legend,
plot_get_clist,
plot_gcfs)
plot_imput_histo)

__all__ = [
"pRank",
Expand All @@ -24,8 +20,4 @@
"plot_prank",
"plot_prank_scatter",
"plot_imput_histo",
"plot_settings",
"plot_legend",
"plot_get_clist",
"plot_gcfs"
]
10 changes: 10 additions & 0 deletions xomics/_utils/_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""This is a script for utility functions for utility functions."""


# Helper functions
# This function is only used in utility check function
def add_str(str_error=None, str_add=None):
"""Add additional error message 'str_add' to default error message ('add_str')"""
if str_add:
str_error += "\n " + str_add
return str_error
Loading

0 comments on commit c94c75d

Please sign in to comment.