Skip to content

Commit

Permalink
Packaging scaffolding (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamjameshandley authored Oct 16, 2023
1 parent 1c21471 commit 0a4c2f9
Show file tree
Hide file tree
Showing 33 changed files with 1,152 additions and 2 deletions.
76 changes: 76 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behaviour that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behaviour by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behaviour and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behaviour.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviours that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behaviour may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
24 changes: 24 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Thank you for considering contributing to lsbi.

If you have a new feature/bug report, make sure you create an [issue](https://github.com/handley-lab/lsbi/issues), and consult existing ones first, in case your suggestion is already being addressed.

If you want to go ahead and create the feature yourself, you should fork the repository to you own github account and create a new branch with an appropriate name. Commit any code modifications to that branch, push to GitHub, and then create a pull request via your forked repository. More detail can be found [here](https://gist.github.com/Chaser324/ce0505fbed06b947d962).

Note that a [code of conduct](https://github.com/handley-lab/lsbi/blob/master/CODE_OF_CONDUCT.md) applies to all spaces managed by the lsbi project, including issues and pull requests.

## Contributing - `pre-commit`

lsbi uses flake8 and pydocstyle to maintain a consistent style. To speed up linting, contributors can optionally use pre-commit to ensure their commits comply.

First, ensure that pre-commit, flake8 and pydocstyle are installed:
```
pip install pre-commit flake8 pydocstyle
```
Then install the pre-commit to the .git folder:
```
pre-commit install
```
This will check changed files, and abort the commit if they do not comply. To uninstall, run:
```
pre-commit uninstall
```
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Bug report
about: Create a report to help us improve
labels:

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behaviour.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Feature request
about: Suggest an idea for this project
labels:

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
14 changes: 14 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Fixes # (issue)

# Checklist:

- [ ] I have performed a self-review of my own code
- [ ] My code is PEP8 compliant (`flake8 lsbi tests`)
- [ ] My code contains compliant docstrings (`pydocstyle --convention=numpy lsbi`)
- [ ] New and existing unit tests pass locally with my changes (`python -m pytest`)
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have appropriately incremented the [semantic version number](https://semver.org/) in both README.rst and lsbi/_version.py
84 changes: 84 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: "0 0 * * *"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Upgrade pip and install linters
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pydocstyle packaging
- name: flake8 PEP compliance checks
run: python -m flake8 lsbi tests
- name: pydocstyle documentation style checks
run: python -m pydocstyle --convention=numpy lsbi

sphinx:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Upgrade pip and install doc requirements
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[all,docs]"
- name: build documentation
run: |
cd docs
make clean
make html SPHINXOPTS="-W --keep-going -n"
pip:
env:
ZENODO_SANDBOX_TOKEN: ${{ secrets.ZENODO_SANDBOX_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[test]"
- name: Test with pytest
run: python -m pytest --cov=lsbi tests

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

test-build-n-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install pypa/build
run: python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
continue-on-error: true
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
85 changes: 85 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build and push to PyPI on merging to master
on:
push:
branches:
- master
jobs:
git-tag-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get version number
run: |
VERSION="$(grep ':Version:' README.rst | awk '{print $2}')"
echo "DIST_VERSION=v${VERSION}" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
const {DIST_VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${DIST_VERSION}`,
sha: context.sha
})
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
name: "${{ env.DIST_VERSION }}"
tag: "${{ env.DIST_VERSION }}"
generateReleaseNotes: true
token: ${{ secrets.GITHUB_TOKEN }}

pypi-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install pypa/build
run: python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}

aur-release:
needs: pypi-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tomli
- name: Generate PKGBUILD
run: python ./bin/gen_PKGBUILD.py > ./PKGBUILD
- name: Get version number
run: |
VERSION="$(cat ./PKGBUILD | grep pkgver= | awk -F= '{print $2}')"
echo "DIST_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Wait for PyPi
uses: nev7n/wait_for_response@v1
with:
url: "https://files.pythonhosted.org/packages/source/u/lsbi/lsbi-${{ env.DIST_VERSION }}.tar.gz"
responseCode: 200
timeout: 600000
interval: 10000
- name: Publish AUR package
uses: KSXGitHub/[email protected]
with:
pkgname: python-lsbi
pkgbuild: ./PKGBUILD
updpkgsums: True
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
18 changes: 18 additions & 0 deletions .github/workflows/version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PR checks

on:
pull_request:
branches: [master]

jobs:
version-is-unit-incremented:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Upgrade pip and install linters
run: |
python -m pip install --upgrade pip
python -m pip install packaging
- name: Check version number
run: python ./bin/check_version.py
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
__pycache__
*.pyc
.eggs
.ipynb_checkpoints
dist
*.egg-info/
build
*~
.pytest_cache/*
.coverage
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: local
hooks:
- id: flake8
name: flake8
entry: python -m flake8
language: system
types: [python]
files: "anesthetic/|tests/"
- id: pydocstyle
name: pydocstyle
entry: python -m pydocstyle --convention=numpy
language: system
types: [python]
files: "anesthetic/"
Loading

0 comments on commit 0a4c2f9

Please sign in to comment.