From 792eafa811d3d57856f3ebfe083b64b6e2ce64b4 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 14:45:45 +0200 Subject: [PATCH 01/15] Docs: Added more TODOs --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 58e190e..ea45274 100644 --- a/README.md +++ b/README.md @@ -84,3 +84,9 @@ tox -p - [ ] Versioning of docs in Read the Docs - [ ] Refactor documentation to avoid full links in docs (have `BadRequestError` instead of `flask_utils.errors.BadRequestError`) - [ ] Add usage examples to documentation in the Usage section +- [ ] (Automatic?) changelog +- [ ] Add a CONTRIBUTING.md +- [ ] Add a CODE_OF_CONDUCT.md +- [ ] Add pull request template +- [ ] Add issue template +- https://sphinx-notfound-page.readthedocs.io/en/latest/ From 786a708aa2193d7b46921f3f11f34f0528f729c0 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 14:46:12 +0200 Subject: [PATCH 02/15] CI/CD: Moved publish of new release to manual trigger --- .github/workflows/publish.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e9ac365..adba117 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,9 +1,7 @@ name: Publish Python Package on: - push: - branches: - - main + workflow_dispatch: jobs: deploy: From 7f5037aa4b2ccb50eccda73134003fd798c7dbf2 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 14:54:45 +0200 Subject: [PATCH 03/15] Docs: Moved TODO from README to GH issues --- README.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/README.md b/README.md index ea45274..11d0150 100644 --- a/README.md +++ b/README.md @@ -72,21 +72,3 @@ Run the tests multi-threaded ```bash tox -p ``` - -# TODO - -- [ ] Move todo-list to GitHub issues -- [ ] Badges -- [ ] Automatic build/deployment (https://github.com/pypa/cibuildwheel) -- [ ] [cibuildwheel](https://github.com/pypa/cibuildwheel) -- [ ] https://github.com/PyCQA/flake8-bugbear -- [ ] [flake8-bugbear](https://github.com/PyCQA/flake8-bugbear) -- [ ] Versioning of docs in Read the Docs -- [ ] Refactor documentation to avoid full links in docs (have `BadRequestError` instead of `flask_utils.errors.BadRequestError`) -- [ ] Add usage examples to documentation in the Usage section -- [ ] (Automatic?) changelog -- [ ] Add a CONTRIBUTING.md -- [ ] Add a CODE_OF_CONDUCT.md -- [ ] Add pull request template -- [ ] Add issue template -- https://sphinx-notfound-page.readthedocs.io/en/latest/ From d2cd87652ba75104f3bf881ce6eedc76aca074b0 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 15:00:14 +0200 Subject: [PATCH 04/15] Docs: Added sphinx-notfound-page plugin --- docs/requirements.txt | 1 + docs/source/conf.py | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/requirements.txt b/docs/requirements.txt index 7638152..4a1dd95 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,4 @@ flask>=2.0.0 sphinx==7.1.2 +sphinx-notfound-page sphinx-rtd-theme==1.3.0rc1 diff --git a/docs/source/conf.py b/docs/source/conf.py index 450c4ed..ac6e889 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -24,6 +24,7 @@ "sphinx.ext.autosummary", "sphinx.ext.intersphinx", "sphinx.ext.viewcode", + "notfound.extension", ] autodoc_default_options = { From 11df6618484cf97d05c27f1f9b2c938de53e46a6 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 15:13:31 +0200 Subject: [PATCH 05/15] Docs: Added CODE_OF_CONDUCT Fixes #14 --- CODE_OF_CONDUCT.md | 116 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..a044a88 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,116 @@ +# Code of Conduct - Flask-Utils + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to make 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 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 +* 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 + +## Our Responsibilities + +Project maintainers 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. + +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, 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 . +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](https://contributor-covenant.org/), version +[1.4](https://www.contributor-covenant.org/version/1/4/code-of-conduct/code_of_conduct.md) and +[2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct/code_of_conduct.md), +and was generated by [contributing-gen](https://github.com/bttger/contributing-gen). From 2f9a42b5876fbba7530d99f640a747d5c1be5d72 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 15:13:50 +0200 Subject: [PATCH 06/15] Docs: Added CONTRIBUTING Fixes #13 --- CONTRIBUTING.md | 189 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b939162 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,189 @@ + +# Contributing to Flask-Utils + +First off, thanks for taking the time to contribute! ❤️ + +All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉 + +> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: +> - Star the project +> - Tweet about it +> - Refer this project in your project's readme +> - Mention the project at local meetups and tell your friends/colleagues + + +## Table of Contents + +- [Code of Conduct](#code-of-conduct) +- [I Have a Question](#i-have-a-question) +- [I Want To Contribute](#i-want-to-contribute) + - [Reporting Bugs](#reporting-bugs) + - [Suggesting Enhancements](#suggesting-enhancements) + - [Your First Code Contribution](#your-first-code-contribution) + - [Improving The Documentation](#improving-the-documentation) +- [Styleguides](#styleguides) + - [Commit Messages](#commit-messages) +- [Join The Project Team](#join-the-project-team) + + +## Code of Conduct + +This project and everyone participating in it is governed by the +[Flask-Utils Code of Conduct](https://github.com/Seluj78/flask-utilsblob/master/CODE_OF_CONDUCT.md). +By participating, you are expected to uphold this code. Please report unacceptable behavior +to . + + +## I Have a Question + +> If you want to ask a question, we assume that you have read the available [Documentation](https://flask-utils.readthedocs.io/en/latest/). + +Before you ask a question, it is best to search for existing [Issues](https://github.com/Seluj78/flask-utils/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first. + +If you then still feel the need to ask a question and need clarification, we recommend the following: + +- Open an [Issue](https://github.com/Seluj78/flask-utils/issues/new). +- Provide as much context as you can about what you're running into. +- Provide project and platform versions (pip, python, OS), depending on what seems relevant. + +We will then take care of the issue as soon as possible. + +## I Want To Contribute + +> ### Legal Notice +> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license. + +### Reporting Bugs + + +#### Before Submitting a Bug Report + +A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible. + +- Make sure that you are using the latest version. +- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://flask-utils.readthedocs.io/en/latest/). If you are looking for support, you might want to check [this section](#i-have-a-question)). +- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/Seluj78/flask-utilsissues?q=label%3Abug). +- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue. +- Collect information about the bug: + - Stack trace (Traceback) + - OS, Platform and Version (Windows, Linux, macOS, x86, ARM) + - Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant. + - Possibly your input and the output + - Can you reliably reproduce the issue? And can you also reproduce it with older versions? + + +#### How Do I Submit a Good Bug Report? + +> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to . + + +We use GitHub issues to track bugs and errors. If you run into an issue with the project: + +- Open an [Issue](https://github.com/Seluj78/flask-utils/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.) +- Explain the behavior you would expect and the actual behavior. +- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case. +- Provide the information you collected in the previous section. + +Once it's filed: + +- The project team will label the issue accordingly. +- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. +- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution). + + + + +### Suggesting Enhancements + +This section guides you through submitting an enhancement suggestion for Flask-Utils, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions. + + +#### Before Submitting an Enhancement + +- Make sure that you are using the latest version. +- Read the [documentation](https://flask-utils.readthedocs.io/en/latest/) carefully and find out if the functionality is already covered, maybe by an individual configuration. +- Perform a [search](https://github.com/Seluj78/flask-utils/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. +- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library. + + +#### How Do I Submit a Good Enhancement Suggestion? + +Enhancement suggestions are tracked as [GitHub issues](https://github.com/Seluj78/flask-utils/issues). + +- Use a **clear and descriptive title** for the issue to identify the suggestion. +- Provide a **step-by-step description of the suggested enhancement** in as many details as possible. +- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you. +- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. +- **Explain why this enhancement would be useful** to most Flask-Utils users. You may also want to point out the other projects that solved it better and which could serve as inspiration. + + + +### Your First Code Contribution + +First of all, you'll need to fork the project. Head on to https://github.com/Seluj78/flask-utils/fork and click the `Create fork` button. This will create a copy of the project in your GitHub account. + +Next, you'll need to clone the project to your local machine. You can do this by running the following command in your terminal: + +```bash +git clone https://github.com/Seluj78/flask-utils.git +``` +or if you have set up SSH keys with GitHub: +```bash +git clone git@github.com:Seluj78/flask-utils.git +``` + +Next, you can create a virtual environment and install the project's dependencies: + +```bash +cd flask-utils +python -m venv venv +source venv/bin/activate +pip install -r requirements-dev.txt +``` + +We recommend using any version of Python 3.8 or higher. + +Once the requirements are installed, you can activate `pre-commit` which will run some checks before you commit your changes: + +```bash +pre-commit install +pre-commit install --hook-type commit-msg +``` + +Now you can make your changes. Once you're done, you can run the tests to make sure everything is working as expected: + +```bash +tox +``` + +If the tests pass, you can commit your changes in a branch and create a pull request. + +### Improving The Documentation + +Improving the documentation is a great way to contribute to the project. The documentation is hosted on Read the Docs and is written in reStructuredText. You can find the documentation in the `docs` directory, as well as in the code docstrings. +Don't hesitate to open issues or pull requests to improve the documentation ! + +## Styleguides +### Commit Messages + +You can find the rules [here](https://github.com/Seluj78/flask-utils/blob/main/scripts/lint-commit.sh) but the gist of it is: + +``` +Prefix: My message no longer than 72 characters +``` + +You can add as much text as you want in the body of the commit message. The prefix could, for example, be one of the following: + +- `Tests`: for changes to the test suite +- `Docs`: for changes to the documentation +- `Decorators`: for changes to the decorators +- `CI/CD`: for changes to the CI/CD pipeline + +etc... We will let you know anyway if a commit is not following the guidelines. + +## Join The Project Team + +If you are interested in becoming a member of the project team, please contact us at jules lasne flask-utils gmail com. + +## Attribution +This guide is based on the **contributing-gen**. [Make your own](https://github.com/bttger/contributing-gen)! From abd9a296c1bf1805acaf5b6099c92fae3028c09e Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 15:37:14 +0200 Subject: [PATCH 07/15] Docs: Added badged to the README Fixes #7 --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 11d0150..65c1e34 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,17 @@ [![Documentation Status](https://readthedocs.org/projects/flask-utils/badge/?version=latest)](https://flask-utils.readthedocs.io/en/latest/?badge=latest) +![GitHub commit activity](https://img.shields.io/github/commit-activity/m/Seluj78/flask-utils) +![GitHub commits since latest release](https://img.shields.io/github/commits-since/seluj78/flask-utils/latest) +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/seluj78/flask-utils/tests.yml?label=tests) +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/seluj78/flask-utils/linting.yml?label=linting) +![GitHub License](https://img.shields.io/github/license/seluj78/flask-utils) + +[//]: # (TODO: Uncomment when flask-utils had been freed from pypi) +[//]: # (![PyPI - Downloads](https://img.shields.io/pypi/dm/flask-utils)) +[//]: # (![PyPI - Implementation](https://img.shields.io/pypi/implementation/flask-utils)) +[//]: # (![PyPI - Python Version](https://img.shields.io/pypi/pyversions/flask-utils)) +[//]: # (![PyPI - Versions from Framework Classifiers](https://img.shields.io/pypi/frameworkversions/:frameworkName/flask-utils)) +[//]: # (![PyPI - Wheel](https://img.shields.io/pypi/wheel/flask-utils)) +[//]: # (![PyPI - Version](https://img.shields.io/pypi/v/flask-utils)) # Flask-Utils From 4472db6f4f63b750e6fa2069fa5198b1ccd62e18 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 15:41:42 +0200 Subject: [PATCH 08/15] Docs: Fixed incorrect email links in CONTRIBUTING --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b939162..516205a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,7 @@ All types of contributions are encouraged and valued. See the [Table of Contents This project and everyone participating in it is governed by the [Flask-Utils Code of Conduct](https://github.com/Seluj78/flask-utilsblob/master/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior -to . +to `jules lasne conduct gmail com`. ## I Have a Question @@ -74,7 +74,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform #### How Do I Submit a Good Bug Report? -> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to . +> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to `jules lasne security gmail com`. We use GitHub issues to track bugs and errors. If you run into an issue with the project: @@ -183,7 +183,7 @@ etc... We will let you know anyway if a commit is not following the guidelines. ## Join The Project Team -If you are interested in becoming a member of the project team, please contact us at jules lasne flask-utils gmail com. +If you are interested in becoming a member of the project team, please contact us at `jules lasne flask-utils gmail com`. ## Attribution This guide is based on the **contributing-gen**. [Make your own](https://github.com/bttger/contributing-gen)! From 091f511770d168ebc97cb29d6efd0579d93c2514 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 15:58:39 +0200 Subject: [PATCH 09/15] CI/CD: Added coverage --- .github/workflows/coverage.yml | 36 ++++++++++++++++++++++++++++++++++ README.md | 1 + requirements-dev.txt | 2 ++ tox.ini | 20 +++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..b14a77a --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,36 @@ +name: Coverage + +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + + - name: Run tests + run: | + tox -e coverage + tox -e report + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 65c1e34..6f4187b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/seluj78/flask-utils/tests.yml?label=tests) ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/seluj78/flask-utils/linting.yml?label=linting) ![GitHub License](https://img.shields.io/github/license/seluj78/flask-utils) +[![codecov](https://codecov.io/gh/Seluj78/flask-utils/graph/badge.svg?token=ChUOweAp4b)](https://codecov.io/gh/Seluj78/flask-utils) [//]: # (TODO: Uncomment when flask-utils had been freed from pypi) [//]: # (![PyPI - Downloads](https://img.shields.io/pypi/dm/flask-utils)) diff --git a/requirements-dev.txt b/requirements-dev.txt index 81ee991..ba4a28a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,10 +1,12 @@ -r requirements.txt black +coverage flake8 mypy packaging pre-commit pytest +pytest-cov pytest-flask reorder-python-imports sphinx-lint diff --git a/tox.ini b/tox.ini index 689022d..3795f1f 100644 --- a/tox.ini +++ b/tox.ini @@ -11,3 +11,23 @@ deps = flask30: Flask==3.* flasklatest: Flask commands = pytest + +[testenv:clean] +deps = coverage +skip_install = true +commands = coverage erase + +[testenv:coverage] +commands = pytest --cov --cov-report=term-missing +deps = + pytest + pytest-cov + coverage + flask + +[testenv:report] +commands = + coverage report + coverage html +deps = coverage +skip_install = true From d56c028d02fc1b3ee42e8bae5b096f031ef73ce0 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 16:03:47 +0200 Subject: [PATCH 10/15] CI/CD: Added codecov config file --- codecov.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..746ec0c --- /dev/null +++ b/codecov.yml @@ -0,0 +1,8 @@ +comment: + after_n_builds: 4 + +codecov: + disable_default_path_fixes: true # Automatic detection does not discover all files + +fixes: + - "::flask_utils/" From cf29e8db4f8ec79eba4a2963cf14a4a959666e7a Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 16:07:04 +0200 Subject: [PATCH 11/15] CI/CD: Fixed tox config for coverage --- tox.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 3795f1f..f36d49e 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ skip_install = true commands = coverage erase [testenv:coverage] -commands = pytest --cov --cov-report=term-missing +commands = pytest --cov=flask_utils --cov-report=term-missing deps = pytest pytest-cov @@ -29,5 +29,7 @@ deps = commands = coverage report coverage html + coverage xml + deps = coverage skip_install = true From 7da4ebf75f77d613d2ce9385b129fc6fcc89d30e Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 16:12:46 +0200 Subject: [PATCH 12/15] CI/CD: Testing codecov components --- codecov.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/codecov.yml b/codecov.yml index 746ec0c..04ea103 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,3 +6,19 @@ codecov: fixes: - "::flask_utils/" + +component_management: + default_rules: + statuses: + - type: project + target: auto + +individual_components: + - component_id: module_decorators + name: decorators + paths: + - flask_utils/decorators.py + - component_id: module_errors + name: errors + paths: + - flask_utils/errors/** From 417807588dfbb1229d89c01aa43de332ce7cc1da Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 16:19:13 +0200 Subject: [PATCH 13/15] CI/CD: Added PR comment for codecov conf --- codecov.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/codecov.yml b/codecov.yml index 04ea103..556238d 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,5 +1,11 @@ comment: after_n_builds: 4 + layout: " diff, flags, files" + behavior: default + require_changes: false # if true: only post the comment if coverage changes + require_base: false # [true :: must have a base report to post] + require_head: false # [true :: must have a head report to post] + hide_project_coverage: false # [true :: only show coverage on the git diff] codecov: disable_default_path_fixes: true # Automatic detection does not discover all files From 12c8e2bd048ae30254325aaacae75cd203e86369 Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 16:21:42 +0200 Subject: [PATCH 14/15] CI/CD: Added commit-linter workflow --- .github/workflows/lint-commits.yml | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/lint-commits.yml diff --git a/.github/workflows/lint-commits.yml b/.github/workflows/lint-commits.yml new file mode 100644 index 0000000..c992a48 --- /dev/null +++ b/.github/workflows/lint-commits.yml @@ -0,0 +1,72 @@ +name: Commit linter + +on: + pull_request: + branches: + - main + +jobs: + lint_commits: + runs-on: ubuntu-20.04 + if: always() + + steps: + - name: Lint PR commits + uses: actions/github-script@v7 + with: + script: | + const rules = [ + { + pattern: /^[^\r]*$/, + error: "Commit message contains CRLF line breaks (only unix-style LF linebreaks are allowed)", + }, + { + pattern: /^.+(\r?\n(\r?\n.*)*)?$/, + error: "Empty line between commit title and body is missing", + }, + { + pattern: /^.{0,72}(?:\r?\n(?:(.{0,72})|(.*?([a-z]+:\/\/)?(([a-zA-Z0-9_]|-)+\.)+[a-z]{2,}(:\d+)?([a-zA-Z_0-9@:%\+.~\?&/=]|-)+).*?))*$/, + error: "Commit message lines are too long (maximum allowed is 72 characters, except for URLs)", + }, + { + pattern: /^\S.*?\S: .+/, + error: "Missing category in commit title (if this is a fix up of a previous commit, it should be squashed)", + }, + { + pattern: /^\S.*?: [A-Z0-9]/, + error: "First word of commit after the subsystem is not capitalized", + }, + { + pattern: /^.+[^.\n](\r?\n.*)*$/, + error: "Commit title ends in a period", + }, + ]; + + const { repository, pull_request } = context.payload; + + // NOTE: This maxes out at 250 commits. If this becomes a problem, see: + // https://octokit.github.io/rest.js/v18#pulls-list-commits + const opts = github.rest.pulls.listCommits.endpoint.merge({ + owner: repository.owner.login, + repo: repository.name, + pull_number: pull_request.number, + }); + const commits = await github.paginate(opts); + + const errors = []; + for (const { sha, commit: { message } } of commits) { + const commitErrors = []; + for (const { pattern, error } of rules) { + if (!pattern.test(message)) { + commitErrors.push(error); + } + } + if (commitErrors.length > 0) { + const title = message.split("\n")[0]; + errors.push([`${title} (${sha}):`, ...commitErrors].join("\n ")); + } + } + + if (errors.length > 0) { + core.setFailed(`One or more of the commits in this PR do not match the code submission policy:\n\n${errors.join("\n")}`); + } From 2cb807ea5ec4c97c71bdd7490477c7bc9e44234d Mon Sep 17 00:00:00 2001 From: Jules Lasne Date: Mon, 10 Jun 2024 16:22:04 +0200 Subject: [PATCH 15/15] Chore: Version update --- flask_utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flask_utils/__init__.py b/flask_utils/__init__.py index c5fcf4f..4ecf9f6 100644 --- a/flask_utils/__init__.py +++ b/flask_utils/__init__.py @@ -1,5 +1,5 @@ # Increment versions here according to SemVer -__version__ = "0.2.5" +__version__ = "0.3.0" from flask_utils.errors import ConflictError from flask_utils.errors import ForbiddenError