mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-15 09:24: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)[.](.*?)}}"
|
||||
RE_OBJ = re.compile(PATTERN)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def context():
|
||||
return {
|
||||
|
@ -226,12 +227,11 @@ def test_gitlab_invokes_flake8_and_pytest(
|
|||
pytest.fail(e)
|
||||
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
["use_docker", "expected_test_script"],
|
||||
[
|
||||
("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(
|
||||
|
@ -245,12 +245,20 @@ def test_github_invokes_flake8_and_pytest(
|
|||
assert result.project.basename == context["project_slug"]
|
||||
assert result.project.isdir()
|
||||
|
||||
|
||||
with open(f"{result.project}/.github/workflows/ci.yml", "r") as github_yml:
|
||||
try:
|
||||
github_config = yaml.safe_load(github_yml)
|
||||
assert github_config["flake8"]["script"] == ["flake8"]
|
||||
assert github_config["pytest"]["script"] == [expected_test_script]
|
||||
flake8_present = False
|
||||
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:
|
||||
pytest.fail(e)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ on:
|
|||
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
flake8:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
|
@ -43,7 +43,7 @@ jobs:
|
|||
|
||||
- name: Checkout Code Repository
|
||||
uses: actions/checkout@v2
|
||||
{% if cookiecutter.use_docker == 'y' -%}
|
||||
{% if cookiecutter.use_docker == 'y' -%}
|
||||
|
||||
- name: Build the Stack
|
||||
run: docker-compose -f local.yml build
|
||||
|
@ -55,12 +55,12 @@ jobs:
|
|||
run: docker-compose -f local.yml up -d
|
||||
|
||||
- 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
|
||||
run: docker-compose down
|
||||
|
||||
{%- else %}
|
||||
{%- else %}
|
||||
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v2
|
||||
|
@ -72,7 +72,7 @@ jobs:
|
|||
run: |
|
||||
echo "::set-output name=dir::$(pip cache dir)"
|
||||
|
||||
{% raw %}
|
||||
{% raw %}
|
||||
- name: Cache pip Project Dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
|
@ -82,7 +82,7 @@ jobs:
|
|||
key: ${{ runner.os }}-pip-${{ hashFiles('**/local.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
{% endraw %}
|
||||
{% endraw %}
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
|
@ -92,4 +92,4 @@ jobs:
|
|||
- name: Test with pytest
|
||||
run: pytest
|
||||
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user