Commit 9a98f164 authored by Peter Hutterer's avatar Peter Hutterer Committed by Benjamin Tissoires
Browse files

gitlab CI: run flake8 as part of the CI



And fix the various complaints while we're at it
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 96b621fe
......@@ -157,6 +157,16 @@ pytest ci-fairy:
junit: results.xml
flake8 ci-fairy:
extends: .pip_install
script:
- pip3 install flake8
# 501: line too long
# 504: line break after binary operator
# 741: ambiguous variable name
- flake8 --ignore=W501,E501,W504,W741,E741
pages:
extends: .pip_install
stage: pages
......
......@@ -28,7 +28,7 @@ author = 'see the git log for author information'
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinxcontrib.autoyaml'
'sphinxcontrib.autoyaml'
]
# Add any paths that contain templates here, relative to this directory.
......
......@@ -32,5 +32,5 @@ setup(name='ci-fairy',
'GitPython',
'pyyaml',
'jinja2',
],
],
)
#!/bin/env python3
import jinja2
import os
import yaml
from pathlib import Path
......@@ -21,8 +20,7 @@ if __name__ == '__main__':
Loader=yaml.Loader)['globals']
for distrib in [x for x in src_folder.iterdir()
if (x.name.endswith('.yml')
and x.name not in 'defaults.yml')]:
if (x.name.endswith('.yml') and x.name not in 'defaults.yml')]:
with open(distrib) as fd:
data = yaml.load(fd, Loader=yaml.Loader)
......@@ -93,7 +91,7 @@ if __name__ == '__main__':
# genereate the bootstrap file
template_bootstrap = env.get_template('bootstrap.tmpl')
dest = f'bootstrap/bootstrap.yml'
dest = 'bootstrap/bootstrap.yml'
print(f'generating {dest}')
with open(dest, 'w') as out_stream:
template_bootstrap.stream(globs).dump(out_stream)
......@@ -102,7 +100,7 @@ if __name__ == '__main__':
template_general_ci = env.get_template('gitlab-ci.tmpl')
distribs = [d for d in sorted(config_data.keys()) if d not in ('defaults', 'globals')]
dest = f'.gitlab-ci.yml'
dest = '.gitlab-ci.yml'
config = {'distribs': distribs}
config.update(globs)
......
......@@ -101,6 +101,16 @@ pytest ci-fairy:
junit: results.xml
flake8 ci-fairy:
extends: .pip_install
script:
- pip3 install flake8
# 501: line too long
# 504: line break after binary operator
# 741: ambiguous variable name
- flake8 --ignore=W501,E501,W504,W741,E741
pages:
extends: .pip_install
stage: pages
......
......@@ -72,7 +72,7 @@ def mock_gitlab(gitlab):
def mrlist(state=None, per_page=None, order_by='created_at'):
# order_by is ignored for our tests
return [m for m in mrs if state == None or m.state == state]
return [m for m in mrs if state is None or m.state == state]
project.mergerequests.list = MagicMock(side_effect=mrlist)
project.mergerequests.get = MagicMock(side_effect=mrget)
......@@ -752,6 +752,7 @@ def test_merge_request_fdo_upstream_repo(gitlab, caplog, gitlab_default_env):
result = runner.invoke(ci_fairy.ci_fairy, args)
assert result.exit_code == 0
@patch('ci_fairy.Gitlab')
def test_merge_request_already_merged(gitlab, caplog, gitlab_default_env):
args = ['-vv', 'check-merge-request', '--require-allow-collaboration']
......@@ -759,7 +760,7 @@ def test_merge_request_already_merged(gitlab, caplog, gitlab_default_env):
env = gitlab_default_env
env['FDO_UPSTREAM_REPO'] = GITLAB_TEST_PROJECT_ID
env['CI_PROJECT_ID'] = '9999'
env['CI_COMMIT_SHA'] = 'dead00000002' # MRs 2 and 3 are 'merged'
env['CI_COMMIT_SHA'] = 'dead00000002' # MRs 2 and 3 are 'merged'
# mock_gitlab sets allow_collaboration off for every second MR
gitlab, project, _ = mock_gitlab(gitlab)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment