Add support for Drone (#4382)

* Add overall config for drone.io support

* Update docs

* Configure basic CI setup

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix python image version for tests step

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Shayan Karimi 2023-07-28 15:33:47 +03:30 committed by GitHub
parent 4e7aff306e
commit 40ddc4b6af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 1 deletions

View File

@ -39,7 +39,7 @@
"use_sentry": "n", "use_sentry": "n",
"use_whitenoise": "n", "use_whitenoise": "n",
"use_heroku": "n", "use_heroku": "n",
"ci_tool": ["None", "Travis", "Gitlab", "Github"], "ci_tool": ["None", "Travis", "Gitlab", "Github", "Drone"],
"keep_local_envs_in_vcs": "y", "keep_local_envs_in_vcs": "y",
"debug": "n" "debug": "n"
} }

View File

@ -135,6 +135,7 @@ ci_tool:
2. `Travis CI`_ 2. `Travis CI`_
3. `Gitlab CI`_ 3. `Gitlab CI`_
4. `Github Actions`_ 4. `Github Actions`_
5. `Drone CI`_
keep_local_envs_in_vcs: keep_local_envs_in_vcs:
Indicates whether the project's ``.envs/.local/`` should be kept in VCS Indicates whether the project's ``.envs/.local/`` should be kept in VCS
@ -196,4 +197,6 @@ debug:
.. _GitLab CI: https://docs.gitlab.com/ee/ci/ .. _GitLab CI: https://docs.gitlab.com/ee/ci/
.. _Drone CI: https://docs.drone.io/pipeline/overview/
.. _Github Actions: https://docs.github.com/en/actions .. _Github Actions: https://docs.github.com/en/actions

View File

@ -238,6 +238,10 @@ def remove_dotgithub_folder():
shutil.rmtree(".github") shutil.rmtree(".github")
def remove_dotdrone_file():
os.remove(".drone.yml")
def generate_random_string(length, using_digits=False, using_ascii_letters=False, using_punctuation=False): def generate_random_string(length, using_digits=False, using_ascii_letters=False, using_punctuation=False):
""" """
Example: Example:
@ -491,6 +495,9 @@ def main():
if "{{ cookiecutter.ci_tool }}" != "Github": if "{{ cookiecutter.ci_tool }}" != "Github":
remove_dotgithub_folder() remove_dotgithub_folder()
if "{{ cookiecutter.ci_tool }}" != "Drone":
remove_dotdrone_file()
if "{{ cookiecutter.use_drf }}".lower() == "n": if "{{ cookiecutter.use_drf }}".lower() == "n":
remove_drf_starter_files() remove_drf_starter_files()

View File

@ -127,6 +127,7 @@ SUPPORTED_COMBINATIONS = [
{"ci_tool": "Travis"}, {"ci_tool": "Travis"},
{"ci_tool": "Gitlab"}, {"ci_tool": "Gitlab"},
{"ci_tool": "Github"}, {"ci_tool": "Github"},
{"ci_tool": "Drone"},
{"keep_local_envs_in_vcs": "y"}, {"keep_local_envs_in_vcs": "y"},
{"keep_local_envs_in_vcs": "n"}, {"keep_local_envs_in_vcs": "n"},
{"debug": "y"}, {"debug": "y"},

View File

@ -0,0 +1,48 @@
kind: pipeline
name: default
environment:
POSTGRES_USER: '{{ cookiecutter.project_slug }}'
POSTGRES_PASSWORD: ''
POSTGRES_DB: 'test_{{ cookiecutter.project_slug }}'
POSTGRES_HOST_AUTH_METHOD: trust
{%- if cookiecutter.use_celery == 'y' %}
CELERY_BROKER_URL: 'redis://redis:6379/0'
{%- endif %}
steps:
- name: lint
pull: if-not-exists
image: python:3.11
environment:
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
volumes:
- name: pre-commit cache
path: ${PRE_COMMIT_HOME}
commands:
- export PRE_COMMIT_HOME=$CI_PROJECT_DIR/.cache/pre-commit
- pip install -q pre-commit
- pre-commit run --show-diff-on-failure --color=always --all-files
- name: test
pull: if-not-exists
{%- if cookiecutter.use_docker == 'y' %}
image: docker/compose:1.29.2
environment:
DATABASE_URL: pgsql://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres/$POSTGRES_DB
commands:
- docker-compose -f local.yml build
- docker-compose -f local.yml run --rm django python manage.py migrate
- docker-compose -f local.yml up -d
- docker-compose -f local.yml run django pytest
{%- else %}
image: python:3.11
commands:
- pip install -r requirements/local.txt
- pytest
{%- endif%}
volumes:
- name: pre-commit cache
host:
path: /tmp/drone/cache/pre-commit