From 50a3fc877fe0b28110fddd3fb16fc35b96ad1af7 Mon Sep 17 00:00:00 2001 From: Dorian Turba <froggit.commit.z3jqj@simplelogin.com> Date: Tue, 29 Aug 2023 14:16:19 +0200 Subject: [PATCH] update all README.md to add variables --- .gitlab-ci.yml | 28 +++++++++---------- templates/python/code_quality/black/README.md | 8 ++++++ .../python/code_quality/flake8/README.md | 26 +++++++++++++---- templates/python/code_quality/isort/README.md | 8 ++++++ templates/python/code_quality/mypy/README.md | 8 ++++++ templates/python/code_quality/ruff/README.md | 8 ++++++ .../python/partial/python_install/README.md | 12 ++++---- templates/python/testing/pytest/README.md | 13 +++++---- templates/python/testing/pytest/pytest.yml | 1 - 9 files changed, 79 insertions(+), 33 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ccabee..8592640 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,13 +2,13 @@ stages: - templates include: - - local: 'templates/python/partial/python_install/python_install.yml' - - local: 'templates/python/testing/pytest/pytest.yml' - - local: 'templates/python/code_quality/flake8/flake8.yml' - - local: 'templates/python/code_quality/black/black.yml' - - local: 'templates/python/code_quality/isort/isort.yml' - - local: 'templates/python/code_quality/mypy/mypy.yml' - - local: 'templates/python/code_quality/ruff/ruff.yml' + - local: 'templates/python/partial/python_install/python_install.yml' + - local: 'templates/python/testing/pytest/pytest.yml' + - local: 'templates/python/code_quality/flake8/flake8.yml' + - local: 'templates/python/code_quality/black/black.yml' + - local: 'templates/python/code_quality/isort/isort.yml' + - local: 'templates/python/code_quality/mypy/mypy.yml' + - local: 'templates/python/code_quality/ruff/ruff.yml' python_install: extends: @@ -18,7 +18,7 @@ python_install: PROJECT_PATH: "tests/python_install_project" PYTHON_SETUP: "pip install ${PROJECT_PATH}" script: - - !reference [.python_install, script] + - !reference [ .python_install, script ] only: changes: - .gitlab-ci.yml @@ -28,7 +28,7 @@ python_install: pytest: stage: templates - needs: ["python_install"] + needs: [ "python_install" ] variables: PROJECT_PATH: "tests/pytest_project" PYTHON_SETUP: "pip install ${PROJECT_PATH}[TESTS]" @@ -41,7 +41,7 @@ pytest: flake8: stage: templates - needs: ["python_install"] + needs: [ "python_install" ] variables: PROJECT_PATH: "tests/flake8_project" only: @@ -53,7 +53,7 @@ flake8: black: stage: templates - needs: ["python_install"] + needs: [ "python_install" ] variables: PROJECT_PATH: "tests/black_project" only: @@ -66,7 +66,7 @@ black: isort: stage: templates - needs: ["python_install"] + needs: [ "python_install" ] variables: PROJECT_PATH: "tests/isort_project" only: @@ -78,7 +78,7 @@ isort: mypy: stage: templates - needs: ["python_install"] + needs: [ "python_install" ] variables: PROJECT_PATH: "tests/mypy_project" only: @@ -90,7 +90,7 @@ mypy: ruff: stage: templates - needs: ["python_install"] + needs: [ "python_install" ] variables: PROJECT_PATH: "tests/ruff_project" only: diff --git a/templates/python/code_quality/black/README.md b/templates/python/code_quality/black/README.md index b35a176..df6162a 100644 --- a/templates/python/code_quality/black/README.md +++ b/templates/python/code_quality/black/README.md @@ -12,6 +12,14 @@ style guide. Black is configured with `--check --diff --quiet` rules. 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 black"` | + ## Global Configuration of Black To add configuration to `black` shared with any other usage of black (such as manual run, diff --git a/templates/python/code_quality/flake8/README.md b/templates/python/code_quality/flake8/README.md index 835eb06..6da44b4 100644 --- a/templates/python/code_quality/flake8/README.md +++ b/templates/python/code_quality/flake8/README.md @@ -1,25 +1,39 @@ ## Objective -Run [Flake8](https://flake8.pycqa.org/en/latest/) and its plugins on your Python code to ensure it adheres to PEP8 -standards and to detect various errors such as syntax errors, semantic errors, and complex code. +Run [Flake8](https://flake8.pycqa.org/en/latest/) and its plugins on your Python code to +ensure it adheres to PEP8 +standards and to detect various errors such as syntax errors, semantic errors, and +complex code. Flake8 is a Python tool that glues together pycodestyle, pyflakes, and McCabe. ## How to use it -1. Configure the `.flake8` file in your repository's root directory with your desired rules. +1. Configure the `.flake8` file in your repository's root directory with your desired + rules. 2. Include the flake8 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 flake8"` | + ## Global Configuration of Flake8 -To add configuration to `flake8` shared with any other usage of flake8 (such as manual run, +To add configuration to `flake8` shared with any other usage of flake8 (such as manual +run, pre-commit, etc), you can use `.flake8` configuration file. Learn more -about [flake8 configuration](https://flake8.pycqa.org/en/latest/user/configuration.html) files. +about [flake8 configuration](https://flake8.pycqa.org/en/latest/user/configuration.html) +files. ## Add a [](https://flake8.pycqa.org/) badge to your project README.md -To display the use of Flake8 in your project, you can add the following badge to your README.md: +To display the use of Flake8 in your project, you can add the following badge to your +README.md: ```markdown [](https://flake8.pycqa.org/) diff --git a/templates/python/code_quality/isort/README.md b/templates/python/code_quality/isort/README.md index e3275d7..d387150 100644 --- a/templates/python/code_quality/isort/README.md +++ b/templates/python/code_quality/isort/README.md @@ -12,6 +12,14 @@ your code remains clean and readable. 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"` | + ## Global Configuration of isort To add configuration to `isort` shared with any other usage of isort (such as manual run, diff --git a/templates/python/code_quality/mypy/README.md b/templates/python/code_quality/mypy/README.md index d776265..38cd45e 100644 --- a/templates/python/code_quality/mypy/README.md +++ b/templates/python/code_quality/mypy/README.md @@ -12,6 +12,14 @@ types of variables, function return values, and more. 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 mypy"` | + ## Global Configuration of mypy To add configuration to `mypy` shared with any other usage of mypy (such as manual run, pre-commit, diff --git a/templates/python/code_quality/ruff/README.md b/templates/python/code_quality/ruff/README.md index 825fc8e..ef8c7f3 100644 --- a/templates/python/code_quality/ruff/README.md +++ b/templates/python/code_quality/ruff/README.md @@ -11,6 +11,14 @@ various syntax and stylistic errors. 3. If you need to customize the job, refer to the [jobs customization](https://docs.r2devops.io/get-started/use-templates/#job-templates-customization) documentation. +4. +## 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 ruff"` | ### Global Configuration of Ruff diff --git a/templates/python/partial/python_install/README.md b/templates/python/partial/python_install/README.md index 59b9819..c814754 100644 --- a/templates/python/partial/python_install/README.md +++ b/templates/python/partial/python_install/README.md @@ -13,12 +13,12 @@ consistent configuration across CI jobs that rely on a python environment. ## Variables -| Name | Description | Default | -|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------| -| `PROJECT_PATH` | The path to the project root directory. | `"."` | -| `REQUIREMENTS_FILE` | the path to the requirements file. | `"${PROJECT_PATH}/requirements.txt"` | -| `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. Default rely on `requirements.txt` to install all dependencies. | `"pip install -r ${PROJECT_PATH}/requirements.txt"` | +| Name | Description | Default | +|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------| +| `PROJECT_PATH` | The path to the project root directory. | `"."` | +| `REQUIREMENTS_FILE_PATH` | the path to the requirements file. | `"${PROJECT_PATH}/requirements.txt"` | +| `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. Default rely on `requirements.txt` to install all dependencies. | `"pip install -r ${REQUIREMENTS_FILE_PATH}"` | ## Example of use diff --git a/templates/python/testing/pytest/README.md b/templates/python/testing/pytest/README.md index 9adbf09..513169c 100644 --- a/templates/python/testing/pytest/README.md +++ b/templates/python/testing/pytest/README.md @@ -14,12 +14,13 @@ automation, modular fixtures, parameterized testing, and many other features. ## 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. Default rely on `requirements.txt` to install project and test dependencies. | `"pip install -r ${PROJECT_PATH}/requirements.txt"` | -| `PYTEST_RUN_CMD` | Bash command to run pytest. | `"pytest ${PROJECT_PATH}"` | +| Name | Description | Default | +|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------| +| `PROJECT_PATH` | The path to the project root directory. | `"."` | +| `REQUIREMENTS_FILE_PATH` | the path to the requirements file. | `"${PROJECT_PATH}/requirements.txt"` | +| `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. Default rely on `requirements.txt` to install all dependencies. | `"pip install -r ${REQUIREMENTS_FILE_PATH}"` | +| `PYTEST_RUN_CMD` | Bash command to run pytest. | `"pytest ${PROJECT_PATH}"` | ## Global Configuration of pytest diff --git a/templates/python/testing/pytest/pytest.yml b/templates/python/testing/pytest/pytest.yml index 5293720..c42f295 100644 --- a/templates/python/testing/pytest/pytest.yml +++ b/templates/python/testing/pytest/pytest.yml @@ -6,7 +6,6 @@ pytest: - .python_install stage: test variables: - PYTHON_SETUP: "pip install -r ${PROJECT_PATH}/requirements.txt" PYTEST_RUN_CMD: "pytest ${PROJECT_PATH}" script: - !reference [.python_install, script] -- GitLab