Skip to content

Commit

Permalink
Merge pull request #1 from broadinstitute/jg/setup
Browse files Browse the repository at this point in the history
Setup gnomAD toolbox repository
  • Loading branch information
jkgoodrich authored Jul 24, 2024
2 parents 1ab8332 + e8863a1 commit 8bde073
Show file tree
Hide file tree
Showing 30 changed files with 1,165 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- Thank you for submitting a pull request.
To make sure that this change is included in release notes, please:
- Use a descriptive title for the pull request.
- Apply one of the "Changelog" labels (if applicable).
-->
17 changes: 17 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
changelog:
exclude:
labels:
- "Changelog: ignore"
categories:
- title: Breaking Changes
labels:
- "Changelog: breaking change"
- title: Bug fixes
labels:
- "Changelog: bug fix"
- title: New Features
labels:
- "Changelog: new feature"
- title: Other Changes
labels:
- "*"
99 changes: 99 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
pylint:
name: Pylint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Use pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
pip-
- name: Install dependencies
run: |
pip install wheel
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Check formatting
run: black --check gnomad_toolbox tests
- name: Check imports
run: isort --check-only gnomad_toolbox tests
- name: Check comment formatting
run: autopep8 --exit-code --diff gnomad_toolbox tests
- name: Run Pylint
run: ./lint --disable=W
- name: Check docstrings
run: pydocstyle gnomad_toolbox tests
- name: Run tests
run: python -m pytest
docs:
name: Build documentation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Use pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
pip-
- name: Install dependencies
run: |
pip install wheel
pip install -r requirements.txt
pip install -r docs/requirements.docs.txt
- name: Build docs
run: ./docs/build.sh
- name: Publish to GitHub Pages
if: github.event_name == 'push'
run: |
# Create empty gh-pages branch
git checkout --orphan gh-pages
# Remove files other than docs
git rm -rf .
find . -name __pycache__ | xargs rm -r
# Move docs to root
mv docs/html/* ./
rm -r docs
# Tell GitHub not to treat this as a Jekyll site
touch .nojekyll
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit --allow-empty -m "Update docs"
git push --force origin gh-pages
# Restore the original working tree by checking out the
# commit that triggered the workflow.
# This restores requirements.txt so that @actions/cache
# can use it for determining the cache key.
git checkout ${GITHUB_SHA}
75 changes: 75 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This workflow publishes the package to PyPI when a version tag is pushed to GitHub.
name: Publish to PyPI
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
jobs:
publish-release:
name: Publish release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Validate version
run: |
package_version=$(grep 'version' setup.py | sed -E 's|.*([0-9]+\.[0-9]+\.[0-9]+).*|\1|')
tag_version=$(echo "$GITHUB_REF" | sed -E 's|.*([0-9]+\.[0-9]+\.[0-9]+).*|\1|')
if [ "$package_version" != "$tag_version" ]; then
echo "Tag version (${tag_version}) does not match package version (${package_version})"
exit 1
fi
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Use pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
pip-
- name: Install dependencies
run: |
pip install --upgrade setuptools
pip install wheel
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Run Pylint
run: ./lint
- name: Run tests
run: python -m pytest
- name: Create distributions
run: python setup.py sdist bdist_wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Create GitHub Release
uses: actions/github-script@v5
with:
script: |
// Get repository and tag from workflow context
// https://docs.github.com/en/actions/learn-github-actions/contexts
const repo = "${{ github.event.repository.name }}"
const owner = "${{ github.event.repository.owner.name }}"
const tag = "${{ github.ref }}".replace(/^refs\/tags\//, "")
// Create a GitHub Release for the tag if one doesn't already exist
try {
await github.rest.repos.getReleaseByTag({ owner, repo, tag })
console.log("Release already exists")
} catch (error) {
if (error.status === 404) {
console.log("Creating release")
await github.rest.repos.createRelease({
owner, repo,
tag_name: tag,
generate_release_notes: true
})
} else {
throw error
}
}
105 changes: 105 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
.DS_Store
.idea

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject

.Rproj.user
.RData
.Rhistory
*.Rproj

*.pdf
*.png

# Data
*.gz
*.bgz
*.tsv
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 24.4.2 # This should be kept in sync with the version in requirements-dev.in
hooks:
- id: black
language_version: python3
files: gnomad_toolbox
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.2 # This should be kept in sync with the version in requirements-dev.in
hooks:
- id: autopep8
args: ["--exit-code", "--in-place"]
files: gnomad_toolbox
- repo: https://github.com/pycqa/isort
rev: 5.12.0 # This should be kept in sync with the version in requirements-dev.in
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
files: gnomad_toolbox
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0 # This should be kept in sync with the version in requirements-dev.in
hooks:
- id: pydocstyle
exclude: ^docs/
6 changes: 6 additions & 0 deletions .pydocstylerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[pydocstyle]
convention = pep257
match = .*\.py
add-ignore =
D105, # Ignore missing docstring for magic methods.
D107 # Ignore missing docstring for __init__ method. Parameters are documented in the class docstring.
10 changes: 10 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[MESSAGES CONTROL]

disable=
# Disable because ~ is used in a lot of hail code where it is not an error
invalid-unary-operand-type,
# Ignore unnecessary-lambda because it has many false positives from hl.ArrayExpression.map, etc.
unnecessary-lambda,
# Ignore refactor and convention categories
R,
C
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changes

[See release notes on GitHub](https://github.com/broadinstitute/gnomad-toolbox/releases).
Loading

0 comments on commit 8bde073

Please sign in to comment.