From 170399faf05431483d6be33cadcae020438c5b9b Mon Sep 17 00:00:00 2001 From: Dorian Turba <froggit.commit.z3jqj@simplelogin.com> Date: Tue, 10 Oct 2023 16:52:36 +0200 Subject: [PATCH] rename depandabot to requirements-compile --- .gitlab-ci.yml | 6 +-- r2_metadata/depandabot.r2.yml | 15 ------- r2_metadata/requirements-compile.r2.yml | 16 +++++++ .../depandabot/README.md | 40 ----------------- .../CHANGELOG.md | 0 .../requirements-compile/README.md | 44 +++++++++++++++++++ .../requirements-compile.yml} | 10 ++--- .../requirements.in | 0 .../test_requirements.in | 0 9 files changed, 68 insertions(+), 63 deletions(-) delete mode 100644 r2_metadata/depandabot.r2.yml create mode 100644 r2_metadata/requirements-compile.r2.yml delete mode 100644 templates/python/dependency_management/depandabot/README.md rename templates/python/dependency_management/{depandabot => requirements-compile}/CHANGELOG.md (100%) create mode 100644 templates/python/dependency_management/requirements-compile/README.md rename templates/python/dependency_management/{depandabot/depandabot.yml => requirements-compile/requirements-compile.yml} (84%) rename tests/{depandabot_project => requirements-compile_project}/requirements.in (100%) rename tests/{depandabot_project => requirements-compile_project}/test_requirements.in (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 830b4e3..ac219a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ include: - 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/dependency_management/depandabot/depandabot.yml' + - local: 'templates/python/dependency_management/requirements-compile/requirements-compile.yml' python_install: extends: @@ -59,10 +59,10 @@ ruff: variables: PROJECT_PATH: "tests/ruff_project" -depandabot: +requirements-compile: stage: templates needs: [ "python_install" ] variables: - PROJECT_PATH: "tests/depandabot_project" + PROJECT_PATH: "tests/requirements-compile_project" REQUIREMENTS_FILE_PATH: "${PROJECT_PATH}/requirements.in" OUTPUT_FILE_PATH: "${PROJECT_PATH}/requirements.txt" diff --git a/r2_metadata/depandabot.r2.yml b/r2_metadata/depandabot.r2.yml deleted file mode 100644 index 021b5c5..0000000 --- a/r2_metadata/depandabot.r2.yml +++ /dev/null @@ -1,15 +0,0 @@ -files: - template: ../templates/python/dependency_management/depandabot/depandabot.yml - documentation: ../templates/python/dependency_management/depandabot/README.md - changelog: ../templates/python/dependency_management/depandabot/CHANGELOG.md -data: - description: "Run pip-compile to generate a requirements.txt and create a merge request on your repository with the updated requirements.txt" - icon: âš« - public: true - labels: - - Utilities - - Dependency management - - Gitlab - - Python - license: MIT - deprecated: false diff --git a/r2_metadata/requirements-compile.r2.yml b/r2_metadata/requirements-compile.r2.yml new file mode 100644 index 0000000..729ed0f --- /dev/null +++ b/r2_metadata/requirements-compile.r2.yml @@ -0,0 +1,16 @@ +files: + template: ../templates/python/dependency_management/requirements-compile/requirements-compile.yml + documentation: ../templates/python/dependency_management/requirements-compile/README.md + changelog: ../templates/python/dependency_management/requirements-compile/CHANGELOG.md +data: + description: "Run pip-compile to generate a requirements.txt and create a merge + request on your repository with the updated requirements.txt" + icon: âš« + public: true + labels: + - Utilities + - Dependency management + - Gitlab + - Python + license: MIT + deprecated: false diff --git a/templates/python/dependency_management/depandabot/README.md b/templates/python/dependency_management/depandabot/README.md deleted file mode 100644 index 63a62aa..0000000 --- a/templates/python/dependency_management/depandabot/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# depandabot template - -## Objective - -The objective of the `depandabot` job is to provide a way to update the requirements.txt file and create a merge request on a Gitlab instance. This reusable job can help speed up other jobs creation and ensure consistent configuration across CI jobs. - -## How to use it - -1. Include the depandabot template in your CI/CD configuration (see quick use above). -2. Create a job that extend the `depandabot` job template. -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. | `"."` | -| `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"` | -| `GITLAB_API_URL` | The host name of the GitLab instance | `${CI_SERVER_HOST}` | - -## Example of use - -```yaml -include: - # Include the python_install job template (don't forget to replace the version tag) - - remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/r2_metadata/depandabot@0.1.0.yaml' - -requirements311: - extends: - - .depandabot # extends the python_install job template - stage: dependency_management - variables: - REQUIREMENTS_FILE_PATH: "${PROJECT_PATH}/requirements-py311.txt" # override the default REQUIREMENTS_FILE_PATH variable - IMAGE_TAG: "3.11" # override the default IMAGE_TAG variable - GITLAB_API_URL: "gitlab.example.com" # override the default GITLAB_API_URL - script: - - !reference [script] # reuse the script from the depandabot job template -``` diff --git a/templates/python/dependency_management/depandabot/CHANGELOG.md b/templates/python/dependency_management/requirements-compile/CHANGELOG.md similarity index 100% rename from templates/python/dependency_management/depandabot/CHANGELOG.md rename to templates/python/dependency_management/requirements-compile/CHANGELOG.md diff --git a/templates/python/dependency_management/requirements-compile/README.md b/templates/python/dependency_management/requirements-compile/README.md new file mode 100644 index 0000000..45497f5 --- /dev/null +++ b/templates/python/dependency_management/requirements-compile/README.md @@ -0,0 +1,44 @@ +# requirements-compile template + +## Objective + +The objective of the `requirements-compile` job is to provide a way to update the +requirements.txt file and create a merge request on a Gitlab instance. This reusable job +can help speed up other jobs creation and ensure consistent configuration across CI +jobs. + +## How to use it + +1. Include the requirements-compile template in your CI/CD configuration (see quick use + above). +2. Create a job that extend the `requirements-compile` job template. +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. | `"."` | +| `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"` | +| `GITLAB_API_URL` | The host name of the GitLab instance | `${CI_SERVER_HOST}` | + +## Example of use + +```yaml +include: + # Include the python_install job template (don't forget to replace the version tag) + - remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/r2_metadata/requirements-compile@0.1.0.yaml' + +requirements311: + extends: + - .requirements-compile # extends the python_install job template + stage: dependency_management + variables: + REQUIREMENTS_FILE_PATH: "${PROJECT_PATH}/requirements-py312.txt" # override the default REQUIREMENTS_FILE_PATH variable + IMAGE_TAG: "3.12" # override the default IMAGE_TAG variable + GITLAB_API_URL: "gitlab.example.com" # override the default GITLAB_API_URL + script: + - !reference [ script ] # reuse the script from the requirements-compile job template +``` diff --git a/templates/python/dependency_management/depandabot/depandabot.yml b/templates/python/dependency_management/requirements-compile/requirements-compile.yml similarity index 84% rename from templates/python/dependency_management/depandabot/depandabot.yml rename to templates/python/dependency_management/requirements-compile/requirements-compile.yml index e0630de..c2b1b38 100644 --- a/templates/python/dependency_management/depandabot/depandabot.yml +++ b/templates/python/dependency_management/requirements-compile/requirements-compile.yml @@ -1,7 +1,7 @@ include: - remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/r2_metadata/python_install@latest.yaml' -depandabot: +requirements-compile: extends: - .python_install stage: build @@ -16,19 +16,19 @@ depandabot: script: - !reference [.python_install, script] - - DEPS_BRANCH="depandabot/requirements-txt/$(date +%s)" + - DEPS_BRANCH="requirements-compile/requirements-txt/$(date +%s)" - | COMMIT_MESSAGE="build(deps): bump new versions" - $([ -f ${OUTPUT_FILE_PATH} ]) && ACTION="update" || ACTION="create" - pip-compile --quiet --strip-extras -o ${OUTPUT_FILE_PATH} ${REQUIREMENTS_FILE_PATH} - if [ -n "$(git status --porcelain ${OUTPUT_FILE_PATH})" ]; then - | - curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \ + curl --header "Authorization: Bearer ${REQUIREMENTS_COMPILE_TOKEN}" \ --form "branch=$DEPS_BRANCH" \ --form "ref=${CI_DEFAULT_BRANCH}" \ "https://${GITLAB_API_URL}/api/v4/projects/${CI_PROJECT_ID}/repository/branches" - | - curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \ + curl --header "Authorization: Bearer ${REQUIREMENTS_COMPILE_TOKEN}" \ --form "branch=$DEPS_BRANCH" \ --form "commit_message=$COMMIT_MESSAGE" \ --form "actions[][action]=$ACTION" \ @@ -38,7 +38,7 @@ depandabot: - requirements_compare ${OUTPUT_FILE_PATH} # Debug - requirements_compare ${OUTPUT_FILE_PATH} > description.md - | - curl --header "Authorization: Bearer ${DEPANDABOT_TOKEN}" \ + curl --header "Authorization: Bearer ${REQUIREMENTS_COMPILE_TOKEN}" \ --form "source_branch=$DEPS_BRANCH" \ --form "target_branch=${CI_DEFAULT_BRANCH}" \ --form "title=$COMMIT_MESSAGE" \ diff --git a/tests/depandabot_project/requirements.in b/tests/requirements-compile_project/requirements.in similarity index 100% rename from tests/depandabot_project/requirements.in rename to tests/requirements-compile_project/requirements.in diff --git a/tests/depandabot_project/test_requirements.in b/tests/requirements-compile_project/test_requirements.in similarity index 100% rename from tests/depandabot_project/test_requirements.in rename to tests/requirements-compile_project/test_requirements.in -- GitLab