Skip to content

Commit

Permalink
Merge pull request #67 from Clinical-Genomics/add_workflows
Browse files Browse the repository at this point in the history
Fix #48 - add GitHub Actions workflows
  • Loading branch information
dnil authored Jul 1, 2024
2 parents 8eb3efb + 14bac2c commit d7a28db
Show file tree
Hide file tree
Showing 24 changed files with 805 additions and 316 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish to PyPI, Docker Hub and GitHub IO

on:
release:
types:
- created

jobs:
build-n-publish:
name: Build and publish Python distribution to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Check out git repository
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Install build tools
run: >-
python -m
pip install
wheel
twine
--user
- name: Build a binary wheel and a source tarball
run: >-
python
setup.py
sdist
bdist_wheel
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

docker-image-CI:
name: Docker Image CI
runs-on: ubuntu-latest
steps:

- name: Check out git repository
uses: actions/checkout@v3

- name: Publish main image (Dockerfile) to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: clinicalgenomics/stranger
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
tags: "latest,${{ github.event.release.tag_name }}"
15 changes: 15 additions & 0 deletions .github/workflows/keep_a_changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Changelog Reminder"
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]

jobs:
# Enforces the update of a changelog file on every pull request
changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dangoslen/changelog-enforcer@v3
with:
changeLogPath: 'CHANGELOG.md'
skipLabels: 'Skip-Changelog'
42 changes: 42 additions & 0 deletions .github/workflows/linting_and_fixing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint files and fix lint errors

# This will only correct linting in local PRs
on: ["push"]

jobs:
build:

name: Lint-and-fix
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]

steps:

# Check out code
- name: Check out git repository
uses: actions/checkout@v4

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

- name: Install Python Dependencies
run: |
pip install black flake8
- name: Run linters
uses: wearerequired/lint-action@v2
# Let linters fix problems if they can
with:
github_token: ${{ secrets.github_token }}
auto_fix: true
# Enable linters
black: true
black_args: "-l 100"
# stop the build if there are Python syntax errors or undefined names
flake8: true
flake8_args: "stranger/ --count --select=E9,F63,F7,F82 --show-source --statistics"
47 changes: 47 additions & 0 deletions .github/workflows/linting_only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Lint files - no fixing

# This will check linting in local PRs
on: ["push", "pull_request"]

jobs:
build:

name: Lint-only
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12]

steps:

# Check out code
- name: Check out git repository
uses: actions/checkout@v4

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

- name: Install Python Dependencies
run: |
pip install black flake8 isort
- name: Run linters
uses: wearerequired/lint-action@v2
# Let linters fix problems if they can
with:
github_token: ${{ secrets.github_token }}
auto_fix: false
# Enable linters
black: true
black_args: "--check -l 100"
# stop the build if there are Python syntax errors or undefined names
flake8: true
flake8_args: "stranger/ --count --select=E9,F63,F7,F82 --show-source --statistics"

- name: Run isort
uses: jamescurtin/isort-action@master
with:
configuration: "--check-only --diff -m 3 --tc --fgw 0 --up -n -l 100"
37 changes: 37 additions & 0 deletions .github/workflows/server_stage_docker_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish to Docker stage

on:
pull_request:
branches:
- main

jobs:
docker-stage-push:
name: Create staging docker image
runs-on: ubuntu-latest
steps:
- name: Check out git repository
uses: actions/checkout@v4

- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
if: steps.branch-name.outputs.is_default == 'false'
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile
push: true
tags: "clinicalgenomics/stranger-stage:${{steps.branch-name.outputs.current_branch}}, clinicalgenomics/stranger-stage:latest"
85 changes: 85 additions & 0 deletions .github/workflows/tests_and_cov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Run tests and push coverage to Codecov

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

jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

# Cache package installation step to speed up the following step
- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }} }}

- name: Install deps
run: |
pip install --upgrade --upgrade-strategy eager -e .
pip check
test:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

# Cache package installation step to speed up the following step
- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}

- name: Install pytest
run: pip install pytest pytest-cov

- name: Run pytest
run: pytest --cov --rootdir=/home/runner/work/stranger

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage${{ matrix.group }}
path: .coverage

coverage:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install deps
run: |
python -m pip install --upgrade pip
pip install coverage
- name: Download all artifacts
# Download and combine coverage1, coverage2, etc.
uses: actions/download-artifact@v4
- name: Run coverage
run: |
coverage combine coverage*/.coverage*
coverage report
coverage xml
- uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/vulture.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Vulture - Find unused code"
on:
- pull_request
jobs:
build:
runs-on: ubuntu-latest
name: vulture
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Find changed Python files
id: files
uses: Ana06/get-changed-files@v2.2.0
with:
filter: "*.py"

- name: Scavenge
uses: anaynayak/python-vulture-action@v1.0
id: vulture
with:
vulture-args: --min-confidence 80 --ignore-names cls,args,kwargs,real_variant_database ${{steps.files.outputs.all}}
continue-on-error: true
15 changes: 15 additions & 0 deletions .github/workflows/woke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: woke
on:
- pull_request
jobs:
woke:
name: Non-inclusive language check with woke
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: woke
uses: get-woke/woke-action@v0
with:
fail-on-error: false
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [unreleased]
### Added
- Added github action test and release workflows
### Fixed
- Docs for TRGT annotation
- Fallback setting allele size to 0 if MC is only set to "." and TRGT annotation requested


## [0.9.0]
- Add Docker image
- Parse TRGT VCFs - in particular, decompose and parse FORMAT.MC
Expand Down
Loading

0 comments on commit d7a28db

Please sign in to comment.