mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-15 17:34:52 +03:00
Made CI file follow the same names as other CI files. Also fixed a bug with the test file to test the CI config
This commit is contained in:
parent
8c89d895b4
commit
de2de6a90d
|
@ -10,6 +10,7 @@ from binaryornot.check import is_binary
|
||||||
PATTERN = r"{{(\s?cookiecutter)[.](.*?)}}"
|
PATTERN = r"{{(\s?cookiecutter)[.](.*?)}}"
|
||||||
RE_OBJ = re.compile(PATTERN)
|
RE_OBJ = re.compile(PATTERN)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def context():
|
def context():
|
||||||
return {
|
return {
|
||||||
|
@ -226,12 +227,11 @@ def test_gitlab_invokes_flake8_and_pytest(
|
||||||
pytest.fail(e)
|
pytest.fail(e)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
["use_docker", "expected_test_script"],
|
["use_docker", "expected_test_script"],
|
||||||
[
|
[
|
||||||
("n", "pytest"),
|
("n", "pytest"),
|
||||||
("y", "docker-compose -f local.yml run django pytest"),
|
("y", "docker-compose -f local.yml exec -T django pytest"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_github_invokes_flake8_and_pytest(
|
def test_github_invokes_flake8_and_pytest(
|
||||||
|
@ -245,12 +245,20 @@ def test_github_invokes_flake8_and_pytest(
|
||||||
assert result.project.basename == context["project_slug"]
|
assert result.project.basename == context["project_slug"]
|
||||||
assert result.project.isdir()
|
assert result.project.isdir()
|
||||||
|
|
||||||
|
|
||||||
with open(f"{result.project}/.github/workflows/ci.yml", "r") as github_yml:
|
with open(f"{result.project}/.github/workflows/ci.yml", "r") as github_yml:
|
||||||
try:
|
try:
|
||||||
github_config = yaml.safe_load(github_yml)
|
github_config = yaml.safe_load(github_yml)
|
||||||
assert github_config["flake8"]["script"] == ["flake8"]
|
flake8_present = False
|
||||||
assert github_config["pytest"]["script"] == [expected_test_script]
|
for action_step in github_config["jobs"]["flake8"]["steps"]:
|
||||||
|
if action_step.get('run') == 'flake8':
|
||||||
|
flake8_present = True
|
||||||
|
assert flake8_present
|
||||||
|
|
||||||
|
expected_test_script_present = False
|
||||||
|
for action_step in github_config["jobs"]["pytest"]["steps"]:
|
||||||
|
if action_step.get('run') == expected_test_script:
|
||||||
|
expected_test_script_present = True
|
||||||
|
assert expected_test_script_present
|
||||||
except yaml.YAMLError as e:
|
except yaml.YAMLError as e:
|
||||||
pytest.fail(e)
|
pytest.fail(e)
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ on:
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
flake8:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ jobs:
|
||||||
|
|
||||||
- name: Checkout Code Repository
|
- name: Checkout Code Repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
{% if cookiecutter.use_docker == 'y' -%}
|
{% if cookiecutter.use_docker == 'y' -%}
|
||||||
|
|
||||||
- name: Build the Stack
|
- name: Build the Stack
|
||||||
run: docker-compose -f local.yml build
|
run: docker-compose -f local.yml build
|
||||||
|
@ -55,12 +55,12 @@ jobs:
|
||||||
run: docker-compose -f local.yml up -d
|
run: docker-compose -f local.yml up -d
|
||||||
|
|
||||||
- name: Run Django Tests
|
- name: Run Django Tests
|
||||||
run: docker-compose exec -T django pytest
|
run: docker-compose -f local.yml exec -T django pytest
|
||||||
|
|
||||||
- name: Tear down the Stack
|
- name: Tear down the Stack
|
||||||
run: docker-compose down
|
run: docker-compose down
|
||||||
|
|
||||||
{%- else %}
|
{%- else %}
|
||||||
|
|
||||||
- name: Set up Python 3.8
|
- name: Set up Python 3.8
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
|
@ -72,7 +72,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=dir::$(pip cache dir)"
|
echo "::set-output name=dir::$(pip cache dir)"
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
- name: Cache pip Project Dependencies
|
- name: Cache pip Project Dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
|
@ -82,7 +82,7 @@ jobs:
|
||||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/local.txt') }}
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/local.txt') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pip-
|
${{ runner.os }}-pip-
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
|
@ -92,4 +92,4 @@ jobs:
|
||||||
- name: Test with pytest
|
- name: Test with pytest
|
||||||
run: pytest
|
run: pytest
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user