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:
Arnav Choudhury 2020-09-19 03:37:06 +05:30
parent 8c89d895b4
commit de2de6a90d
2 changed files with 20 additions and 12 deletions

View File

@ -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)

View File

@ -16,7 +16,7 @@ on:
jobs:
lint:
flake8:
runs-on: ubuntu-latest
steps:
@ -55,7 +55,7 @@ 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