Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • swepy/osoc/r2devops_catalog
1 result
Show changes
Commits on Source (10)
Showing
with 109 additions and 61 deletions
repos:
- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.13.3
hooks:
- id: pymarkdown
=======
Credits
=======
Development Lead
----------------
* Dorian Turba <contact.ykiob@8shield.net>
Contributors
------------
None yet. Why not be the first?
# Contributing to r2devops_catalog
## Development environment
### Quality Standards
#### Style Guide
#### Pre-commit hooks
Please use the pre-commit hooks provided in this repository to maintain consistency in
the codebase.
```bash
pip install --upgrade pip
pip install -e .[QUALITY]
pre-commit install
```
You can manually run the pre-commit hooks on all files:
```bash
pre-commit autoupdate
pre-commit run --all-files
```
This will run the following hooks:
- `pymarkdown`
# CI templates for R2DevOps open source catalog
This repository contains CI templates dedicated to Python software testing for the R2DevOps open source catalog.
[![Latest Release](https://lab.frogg.it/dorianturba/r2devops_catalog/-/badges/release.svg?order_by=release_at)](https://lab.frogg.it/r2devops_catalog/fake_session_maker/-/releases)
[![Pipeline](https://lab.frogg.it/dorianturba/r2devops_catalog/badges/main/pipeline.svg)](https://lab.frogg.it/dorianturba/r2devops_catalog/-/pipelines)
[![Markdown: pymarkdown](https://img.shields.io/badge/%20markdown-pymarkdown-%231674b1?style=flat&labelColor=ef8336)](https://github.com/jackdewinter/pymarkdown)
This repository contains CI templates dedicated to Python software testing for the
R2DevOps open source catalog.
## Purpose
The CI templates in this repository are intended for integrating Python software testing tools with your GitLab projects. They provide streamlined configurations for tools like `pytest` and `mypy`.
The CI templates in this repository are intended for integrating Python software testing
tools with your GitLab projects. They provide streamlined configurations for tools
like `pytest` and `mypy`.
## Usage
To utilize these templates in your GitLab projects:
1. Navigate to the [r2devops template marketplace](https://r2devops.io/dashboard/marketplace?search=r2_metadata),
1. Navigate to
the [r2devops template marketplace](https://r2devops.io/dashboard/marketplace?search=r2_metadata),
2. Choose the template you want,
3. Paste the "Quick use" snippet into your GitLab CI configuration (`.gitlab-ci.yml`).
......@@ -16,20 +26,24 @@ For example, to use the `pytest` template:
```yaml
stages:
- test
- test
include:
- remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/r2_metadata/pytest@latest.yaml'
- remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/r2_metadata/pytest@latest.yaml'
```
## Contributions
We welcome contributions from the community! For guidelines on contributing, please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file.
We welcome contributions from the community! For guidelines on contributing, please
refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file.
## Prerequisites
To use the templates from this repository, ensure that you have at least GitLab version `15.10.7`.
To use the templates from this repository, ensure that you have at least GitLab
version `15.10.7`.
## Directory Structure
- `r2_metadata` - Contains the R2DevOps metadata files.
- `templates` - Contains the CI templates.
- `test` - Contains test projects used to test each template.
k
\ No newline at end of file
......@@ -19,3 +19,13 @@ dependencies = [
"pytest_project @ {root:uri}/tests/pytest_project",
"mypy_project @ {root:uri}/tests/mypy_project",
]
[project.optional-dependencies]
QUALITY = [
"pre-commit",
]
[tool.pymarkdown]
strict-config = true
plugins.line-length.enabled = false
[![Black Logo](https://raw.githubusercontent.com/psf/black/main/docs/_static/logo2-readme.png)](https://black.readthedocs.io/en/stable/)
# black template
## Objective
......
......@@ -10,8 +10,3 @@ black:
script:
- !reference [.python_install, script]
- black ${PROJECT_PATH} --check --diff --quiet
only:
changes:
- ${PROJECT_PATH}/**/*.py
- .gitlab-ci.yml
- ${PROJECT_PATH}/pyproject.toml
# flake8 template
## Objective
Run [Flake8](https://flake8.pycqa.org/en/latest/) and its plugins on your Python code to
......
......@@ -10,9 +10,3 @@ flake8:
script:
- !reference [.python_install, script]
- flake8 ${PROJECT_PATH} -v
only:
changes:
- ${PROJECT_PATH}/**/*.py
- .gitlab-ci.yml
- ${PROJECT_PATH}/pyproject.toml
- ${PROJECT_PATH}/.flake8
# isort Template
## Objective
Run [isort](https://pycqa.github.io/isort/) on your Python code to automatically sort and organize
your imports. isort separates imports into sections and by type. It's a helpful tool to ensure that
your code remains clean and readable.
Run [isort](https://pycqa.github.io/isort/) on your Python code to automatically sort
and organize your imports. isort separates imports into sections and by type. It's a
helpful tool to ensure that your code remains clean and readable.
## How to use it
1. Configure the `pyproject.toml` or `.isort.cfg` file in your repository's root directory with your
desired rules.
1. Configure the `pyproject.toml` or `.isort.cfg` file in your repository's root
directory with your desired rules.
2. Include the isort template in your CI/CD configuration (see quick use above).
3. If you need to customize the job, check
the [jobs customization](https://docs.r2devops.io/get-started/use-templates/#job-templates-customization).
## Variables
| Name | Description | Default |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------|
| `PROJECT_PATH` | The path to the project root directory. | `"."` |
| `IMAGE_TAG` | The default tag for the docker image. See [Python Docker Official Image](https://hub.docker.com/_/python) for supported tags and respective Dockerfile links. | `"latest"` |
| `PYTHON_SETUP` | Bash commands to setup your python environment. | `"pip install isort"` |
| Name | Description | Default |
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|
| `PROJECT_PATH` | The path to the project root directory. | `"."` |
| `IMAGE_TAG` | The default tag for the docker image. See [Python Docker Official Image](https://hub.docker.com/_/python) for supported tags and respective Dockerfile links. | `"latest"` |
| `PYTHON_SETUP` | Bash commands to setup your python environment. | `"pip install isort"` |
## Global Configuration of isort
To add configuration to `isort` shared with any other usage of isort (such as manual run,
pre-commit, etc), you can use `pyproject.toml` configuration file or a dedicated `.isort.cfg`. Learn
more about [isort configuration](https://pycqa.github.io/isort/docs/configuration/config_files.html)
To add configuration to `isort` shared with any other usage of isort (such as manual
run, pre-commit, etc), you can use `pyproject.toml` configuration file or a
dedicated `.isort.cfg`. Learn more
about [isort configuration](https://pycqa.github.io/isort/docs/configuration/config_files.html)
files.
## Add a [![Imports: isort](https://img.shields.io/badge/imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/) badge to your project README.md
To display the use of isort in your project, you can add the following badge to your README.md:
To display the use of isort in your project, you can add the following badge to your
README.md:
```markdown
[![Imports: isort](https://img.shields.io/badge/imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
......
......@@ -10,8 +10,3 @@ isort:
script:
- !reference [.python_install, script]
- isort . --check-only --verbose
only:
changes:
- ${PROJECT_PATH}/**/*.py
- .gitlab-ci.yml
- ${PROJECT_PATH}/pyproject.toml
# mypy template
## Objective
Run [mypy](https://mypy.readthedocs.io/en/stable/) on your Python code to perform static typing
......
......@@ -10,13 +10,6 @@ mypy:
script:
- !reference [.python_install, script]
- mypy ${PROJECT_PATH}
only:
changes:
- ${PROJECT_PATH}/**/*.py
- .gitlab-ci.yml
- ${PROJECT_PATH}/pyproject.toml
- ${PROJECT_PATH}/mypy.ini
- ${PROJECT_PATH}/.mypy.ini
- ${PROJECT_PATH}/setup.cfg
# ruff template
## Objective
Run [Ruff](https://github.com/astral-sh/ruff), an extremely fast Python linter, on your Python
......
......@@ -10,10 +10,3 @@ ruff:
script:
- !reference [.python_install, script]
- ruff check ${PROJECT_PATH}
only:
changes:
- ${PROJECT_PATH}/**/*.py
- .gitlab-ci.yml
- ${PROJECT_PATH}/pyproject.toml
- ${PROJECT_PATH}/.ruff.toml
- ${PROJECT_PATH}/ruff.toml
# python install template
## Objective
The objective of the `python_install` job is to provide a Python environment with all requirements
......
# pytest template
## Objective
Run [pytest](https://docs.pytest.org/en/latest/) on your Python code to ensure all unit tests pass.
......@@ -48,7 +50,7 @@ pytest_3.10:
IMAGE_TAG: "3.10"
```
https://docs.r2devops.io/get-started/use-templates/#multiple-usage-of-the-same-job-template-in-your-pipeline
[docs.r2devops: 🎶 Multiple usage of the same job template in your pipeline](https://docs.r2devops.io/get-started/use-templates/#multiple-usage-of-the-same-job-template-in-your-pipeline)
## Add a [![Tested with pytest](https://img.shields.io/badge/Tested%20with-pytest-green)](https://docs.pytest.org/en/latest/) badge to your project README.md
......
......@@ -10,9 +10,3 @@ pytest:
script:
- !reference [.python_install, script]
- ${PYTEST_RUN_CMD}
only:
changes:
- ${PROJECT_PATH}/**/*.py
- .gitlab-ci.yml
- ${PROJECT_PATH}/pyproject.toml
- ${PROJECT_PATH}/pytest.ini