mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 17:47:08 +03:00
Merge pull request #2539 from Andrew-Chen-Wang/ci
This commit is contained in:
commit
f01ff95c51
|
@ -172,8 +172,12 @@ def test_black_passes(cookies, context_override):
|
|||
pytest.fail(e.stdout.decode())
|
||||
|
||||
|
||||
def test_travis_invokes_pytest(cookies, context):
|
||||
context.update({"ci_tool": "Travis"})
|
||||
@pytest.mark.parametrize(
|
||||
["use_docker", "expected_test_script"],
|
||||
[("n", "pytest"), ("y", "docker-compose -f local.yml run django pytest"),],
|
||||
)
|
||||
def test_travis_invokes_pytest(cookies, context, use_docker, expected_test_script):
|
||||
context.update({"ci_tool": "Travis", "use_docker": use_docker})
|
||||
result = cookies.bake(extra_context=context)
|
||||
|
||||
assert result.exit_code == 0
|
||||
|
@ -183,13 +187,21 @@ def test_travis_invokes_pytest(cookies, context):
|
|||
|
||||
with open(f"{result.project}/.travis.yml", "r") as travis_yml:
|
||||
try:
|
||||
assert yaml.load(travis_yml, Loader=yaml.FullLoader)["script"] == ["pytest"]
|
||||
yml = yaml.load(travis_yml, Loader=yaml.FullLoader)["jobs"]["include"]
|
||||
assert yml[0]["script"] == ["flake8"]
|
||||
assert yml[1]["script"] == [expected_test_script]
|
||||
except yaml.YAMLError as e:
|
||||
pytest.fail(e)
|
||||
pytest.fail(str(e))
|
||||
|
||||
|
||||
def test_gitlab_invokes_flake8_and_pytest(cookies, context):
|
||||
context.update({"ci_tool": "Gitlab"})
|
||||
@pytest.mark.parametrize(
|
||||
["use_docker", "expected_test_script"],
|
||||
[("n", "pytest"), ("y", "docker-compose -f local.yml run django pytest"),],
|
||||
)
|
||||
def test_gitlab_invokes_flake8_and_pytest(
|
||||
cookies, context, use_docker, expected_test_script
|
||||
):
|
||||
context.update({"ci_tool": "Gitlab", "use_docker": use_docker})
|
||||
result = cookies.bake(extra_context=context)
|
||||
|
||||
assert result.exit_code == 0
|
||||
|
@ -201,7 +213,7 @@ def test_gitlab_invokes_flake8_and_pytest(cookies, context):
|
|||
try:
|
||||
gitlab_config = yaml.load(gitlab_yml, Loader=yaml.FullLoader)
|
||||
assert gitlab_config["flake8"]["script"] == ["flake8"]
|
||||
assert gitlab_config["pytest"]["script"] == ["pytest"]
|
||||
assert gitlab_config["pytest"]["script"] == [expected_test_script]
|
||||
except yaml.YAMLError as e:
|
||||
pytest.fail(e)
|
||||
|
||||
|
|
|
@ -22,8 +22,21 @@ flake8:
|
|||
pytest:
|
||||
stage: test
|
||||
image: python:3.7
|
||||
{% if cookiecutter.use_docker == 'y' -%}
|
||||
tags:
|
||||
- docker
|
||||
services:
|
||||
- docker
|
||||
before_script:
|
||||
- docker-compose -f local.yml build
|
||||
# Ensure celerybeat does not crash due to non-existent tables
|
||||
- docker-compose -f local.yml run --rm django python manage.py migrate
|
||||
- docker-compose -f local.yml up -d
|
||||
script:
|
||||
- docker-compose -f local.yml run django pytest
|
||||
{%- else %}
|
||||
tags:
|
||||
- python
|
||||
services:
|
||||
- postgres:11
|
||||
variables:
|
||||
|
@ -34,4 +47,5 @@ pytest:
|
|||
|
||||
script:
|
||||
- pytest
|
||||
{%- endif %}
|
||||
|
||||
|
|
|
@ -1,17 +1,45 @@
|
|||
dist: xenial
|
||||
services:
|
||||
- postgresql
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq build-essential gettext python-dev zlib1g-dev libpq-dev xvfb
|
||||
- sudo apt-get install -qq libjpeg8-dev libfreetype6-dev libwebp-dev
|
||||
- sudo apt-get install -qq graphviz-dev python-setuptools python3-dev python-virtualenv python-pip
|
||||
- sudo apt-get install -qq firefox automake libtool libreadline6 libreadline6-dev libreadline-dev
|
||||
- sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm
|
||||
|
||||
language: python
|
||||
python:
|
||||
- "3.8"
|
||||
install:
|
||||
- pip install -r requirements/local.txt
|
||||
script:
|
||||
- "pytest"
|
||||
|
||||
services:
|
||||
- {% if cookiecutter.use_docker == 'y' %}docker{% else %}postgresql{% endif %}
|
||||
jobs:
|
||||
include:
|
||||
- name: "Linter"
|
||||
before_script:
|
||||
- pip install -q flake8
|
||||
script:
|
||||
- "flake8"
|
||||
|
||||
- name: "Django Test"
|
||||
{%- if cookiecutter.use_docker == 'y' %}
|
||||
before_script:
|
||||
- docker-compose -v
|
||||
- docker -v
|
||||
- docker-compose -f local.yml build
|
||||
# Ensure celerybeat does not crash due to non-existent tables
|
||||
- docker-compose -f local.yml run --rm django python manage.py migrate
|
||||
- docker-compose -f local.yml up -d
|
||||
script:
|
||||
- "docker-compose -f local.yml run django pytest"
|
||||
after_failure:
|
||||
- docker-compose -f local.yml logs
|
||||
{%- else %}
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq build-essential gettext python-dev zlib1g-dev libpq-dev xvfb
|
||||
- sudo apt-get install -qq libjpeg8-dev libfreetype6-dev libwebp-dev
|
||||
- sudo apt-get install -qq graphviz-dev python-setuptools python3-dev python-virtualenv python-pip
|
||||
- sudo apt-get install -qq firefox automake libtool libreadline6 libreadline6-dev libreadline-dev
|
||||
- sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm
|
||||
language: python
|
||||
python:
|
||||
- "3.8"
|
||||
install:
|
||||
- pip install -r requirements/local.txt
|
||||
script:
|
||||
- "pytest"
|
||||
{%- endif %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user