Skip to content

Commit

Permalink
Initial rewrite of common-nb-preprocessors
Browse files Browse the repository at this point in the history
  • Loading branch information
kai-tub committed Jul 10, 2022
0 parents commit ab4a087
Show file tree
Hide file tree
Showing 37 changed files with 3,586 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .auto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Auto scripts

These scripts are used to build the release automatically.
The [auto](https://intuit.github.io/auto/) tool bumps the tag version and publishes the release on GitHub.
The configuration file is the [.autorc](../.autorc) file in the root project folder.
During the release process, `auto` will trigger the [update_version](update_version.sh) script.
This script replaces the version specification in the `pyproject.toml` file with the newest release.
It will use PDM to bump the version inside the `pyproject.toml` file.
6 changes: 6 additions & 0 deletions .auto/run_auto.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# Download and run the `auto` tool -> With the provided .autorc file,
# it will trigger a call to update_package_versioning.sh
curl -kL -o - https://github.com/intuit/auto/releases/latest/download/auto-linux.gz | gunzip > ~/auto
chmod a+x ~/auto
~/auto shipit
35 changes: 35 additions & 0 deletions .auto/update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# Script is triggered by `auto` beforeCommitChangelog
# should include any changes that are
# Assumes current dir is the project root

set -e

# Print on stderr to not pollute function return echo
function error {
echo "::error::$1" >& 2
exit 1
}

# https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself
# scriptFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

echo "$ARG_0"
bumpType=$(echo "$ARG_0" | jq -r '.bump')
echo "bump type: $bumpType"


if [[ -z "$(command -v pdm)" ]]; then
error "requires PDM to bump version!"
fi

# Until https://github.com/carstencodes/pdm-bump/pull/2 is merged
if [[ "$bumpType" = "patch" ]]; then
bumpType="micro"
fi
# bump version
poetry version "$bumpType"


# Files will be commited via `auto` tool
git add .
17 changes: 17 additions & 0 deletions .autorc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"plugins": [
"git-tag",
"all-contributors",
"first-time-contributor",
[
"exec",
{
"beforeCommitChangelog": "bash .auto/update_version.sh"
}
]
],
"owner": "kai-tub",
"repo": "common-nb-preprocessors",
"name": "Kai Norman Clasen",
"email": "k.clasen@protonmail.com"
}
128 changes: 128 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible 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.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

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

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders 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, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
k.clasen@protonmail.com.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

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

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
30 changes: 30 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Contributing to the Common NB Preprocessors library
This project is a community effort, and everyone is welcome to contribute!

If you are interested in contributing, there are many ways to help out:
1. It would help us very much if you could
- Report issues you're facing
- Give a :+1: on issues that others reported and that are relevant to you
- Spread the word about the project or simply :star: to say "I use it!"
1. You would like to improve the documentation. Improving the documentation is no less important than improving the library itself!
If you find a typo in the documentation, do not hesitate to submit a GitHub pull request.
1. You would like to propose a new feature and implement it
- Open an issue and tell us about your goal and a rough sketch on how you would like to implement it. Once we agree that the plan looks good, feel free to start working on your first *pull request*.

## PR guide
1. Install the development dependencies via `pdm install`
1. Update the code/tests
1. Run all tests via `pytest tests/` or `pdm run test`

If anything is unclear, feel free to start the PR and mention the part that is hard to understand. I am happy to help. :)

If everything is OK, and all the tests are passing for the PR, your contribution will be merged.

If you are not familiar with creating a Pull Request, here are some guides:
- http://stackoverflow.com/questions/14680711/how-to-do-a-github-pull-request
- https://help.github.com/articles/creating-a-pull-request/

Afterwards, you will be added to the list of contributors.

Thanks for your hard work and for sticking around until
the end of the guide! :tada::tada::tada:
17 changes: 17 additions & 0 deletions .github/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# config for the welcome-bot
newIssueWelcomeComment: |
Thanks for opening your first issue here! 💖
# Be sure to follow the issue template.
# Then the issue will be worked on in no time. 👍
# Comment to be posted on PRs from first time contributors in your repository
newPRWelcomeComment: |
Thanks for opening a pull request! 💖
Please check out the [code of conduct](https://github.com/kai-tub/common-nb-preprocessors//blob/main/.github/CODE_OF_CONDUCT.md) and the [contributing guidelines](https://github.com/kai-tub/common-nb-preprocessors//blob/main/.github/CONTRIBUTING.md).
Although, you probably have read it already. 😎
# Comment to be posted on PR merges from first time contributors in your repository
firstPRMergeComment: |
Congrats on merging your first pull request! 🎉🎉🎉
We are proud of you and your accomplishment 🏆.
![thanks-for-pr-image](https://github.com/kai-tub/common-nb-preprocessors//blob/main/.github/thanks_for_pr.jpg)
Binary file added .github/thanks_for_pr.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
# Here I am assuming that the tests have been run on the PR
# Otherwise it could be possible that a direct push to main
# would not run the test code and still publish to PyPI
documentation-and-publish:
name: Build documentation and publish
runs-on: ubuntu-latest
# Always try to build the documentation!
# if: ${{ github.event_name == 'push' }}
steps:
- name: Set up Git
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python and PDM
uses: pdm-project/setup-pdm@main
with:
python-version: 3.8
- name: Install dependencies
run: |
pdm sync --dev --group docs
pdm run build-docs
# Must be run BEFORE GitHub Pages Deploy
# as the GitHub Pages action would check out a different
# branch; the error you would see is "no canary release available"
# It also requires checkout with all associated tags, i.e.,
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
- name: Run release script
if: ${{ github.event_name == 'push' }}
run: bash .auto/run_auto.sh
env:
# To be able to trigger publish event
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
# always deploy github-pages if pushed to main
- name: Deploy 🚀
if: ${{ github.event_name == 'push' }}
uses: JamesIves/github-pages-deploy-action@v4.2.5
with:
branch: gh-pages # The branch the action should deploy to.
# This should be set via `just build`
folder: docs/_build
36 changes: 36 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish to PyPI

on:
release:
types: [published]

# required since it is started from a previous workflow
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# TODO: Update this to PDM
jobs:
upload_assets:
name: Create/Upload assets
runs-on: ubuntu-latest
steps:
- name: Set up Git
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- uses: extractions/setup-just@v1
- name: Install node dependencies
run: |
just install
- name: Build package
run: poetry build
- name: Publish
run: poetry publish --username ${{ secrets.PYPI_USER }} --password ${{ secrets.PYPI_PWD }}
16 changes: 16 additions & 0 deletions .github/workflows/skip_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Test
on:
push:
branches: [main]
paths-ignore:
- "common_nb_preprocessors/**"
pull_request:
branches: [main]
paths-ignore:
- "common_nb_preprocessors/**"

jobs:
test:
runs-on: ubuntu-latest
steps:
- run: 'echo "No build required"'
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test
on:
push:
branches: [main]
paths:
- "common_nb_preprocessors/**"
pull_request:
branches: [main]
paths:
- "common_nb_preprocessors/**"

jobs:
test:
strategy:
fail-fast: true
matrix:
python-version: ["3.8","3.9","3.10"]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python and PDM
uses: pdm-project/setup-pdm@main
with:
python-version: 3.8
- name: Check precommit
run: |
pdm run pre-commit run --all-files
- name: Test mypy
run: |
pdm run mypy common_nb_preprocessors
- name: Run tests from within PDM
run: |
pdm run tests
Loading

0 comments on commit ab4a087

Please sign in to comment.