Skip to content

Commit

Permalink
Merge pull request #11 from PennChopMicrobiomeProgram/10-update-ci-an…
Browse files Browse the repository at this point in the history
…d-docs

Update CI workflows and docs
  • Loading branch information
Ulthran authored Jun 5, 2024
2 parents dd85c65 + b6bf0fd commit a14eb26
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 155 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/codecov.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/linter.yml

This file was deleted.

14 changes: 14 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Tests

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

workflow_dispatch:

jobs:
run-tests:
uses: ./.github/workflows/test.yml
secrets: inherit
39 changes: 0 additions & 39 deletions .github/workflows/python-publish.yml

This file was deleted.

104 changes: 104 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Release Package

on:
release:
types: [published]

workflow_dispatch:

jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install Library
run: |
python -m pip install .
python -m pip install setuptools
- id: get_version
uses: battila7/get-version-action@v2

- name: Check version
run: |
LIBRARY_VERSION=$(unassign --version)
GITHUB_VERSION=${{ steps.get_version.outputs.version-without-v }}
if [[ $LIBRARY_VERSION == $GITHUB_VERSION ]]; then
echo "Versions match, continuing..."
else
echo "Versions don't match, exiting..."
echo "Library version: $LIBRARY_VERSION"
echo "GitHub version: $GITHUB_VERSION"
exit 1
fi
run-tests:
uses: ./.github/workflows/test.yml
secrets: inherit

build-and-publish-to-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [run-tests, check-version]

permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build

- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

build-and-push-to-dockerhub:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: [run-tests, check-version]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ctbushman/unassigner

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
90 changes: 90 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Tests

on:
workflow_call:

workflow_dispatch:

jobs:
tests-with-coverage:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: setup-conda
uses: s-weigand/setup-conda@v1.1.0

- name: Install dependencies
run: |
conda install -c bioconda vsearch
python -m pip install --upgrade pip
python -m pip install pytest pytest-cov
python -m pip install .
- name: Run tests and collect coverage
run: pytest --cov tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

tests:
name: Run Tests
strategy:
fail-fast: false
matrix:
python-version: ['3.12']
os: [ubuntu-latest] # setup-conda action currently doesn't work with latest macOS runners
include:
- python-version: '3.11'
os: ubuntu-latest
- python-version: '3.10'
os: ubuntu-latest
- python-version: '3.9'
os: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: setup-conda
uses: s-weigand/setup-conda@v1.1.0

- name: Install dependencies
run: |
conda install -c bioconda vsearch
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install .
- name: Run tests
run: pytest -s -vvvv -l --tb=long tests

lint:
name: Lint Code Base
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Dependencies
run: pip install black

- name: Lint Code Base
run: |
black --check .
45 changes: 0 additions & 45 deletions .github/workflows/tests.yml

This file was deleted.

21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM condaforge/mambaforge:latest

# Setup
WORKDIR /home

COPY . .

# Install environment
RUN mamba create --name primertrim -c conda-forge -c bioconda vsearch

ENV PATH="/opt/conda/envs/primertrim/bin/:${PATH}"

# "Activate" the environment
SHELL ["conda", "run", "--no-capture-output", "-n", "primertrim", "/bin/bash", "-c"]

RUN pip install /home/

RUN echo "Python: $(python --version), Conda: $(conda --version), Vsearch: $(vsearch -v)" > installed_packages.txt

# Run
CMD "bash"
Loading

0 comments on commit a14eb26

Please sign in to comment.