Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up all CI to use GH actions #1443

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[run]
omit = /tmp/*
relative_files = True
15 changes: 15 additions & 0 deletions .github/workflows/flake8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lint with flake8

on: [pull_request]

jobs:
flake8:
name: Flake8 for Python 3
runs-on: ubuntu-latest

steps:
- name: Check out repo
uses: actions/checkout@v2

- name: Run flake8 for Python 3
uses: containerbuildsystem/actions/flake8@master
15 changes: 15 additions & 0 deletions .github/workflows/markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: markdownlint

on: [pull_request]

jobs:
markdownlint:
name: markdownlint
runs-on: ubuntu-latest

steps:
- name: Check out repo
uses: actions/checkout@v2

- name: Run markdownlint
uses: containerbuildsystem/actions/markdownlint@master
15 changes: 15 additions & 0 deletions .github/workflows/shellcheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Shellcheck

on: [pull_request]

jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest

steps:
- name: Check out repo
uses: actions/checkout@v2

- name: Run ShellCheck
uses: containerbuildsystem/actions/shellcheck@master
109 changes: 109 additions & 0 deletions .github/workflows/test_sh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Run tests using test.sh

on: [pull_request]

jobs:
test:
name: Python ${{ matrix.os.python }} tests on ${{ matrix.os.name }}-${{ matrix.os.version }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
os:
- name: centos
version: 7
python: 2
engine: docker

- name: fedora
version: 30
python: 3
engine: docker

- name: fedora
version: 31
python: 3
engine: docker

steps:
- name: Check out repo
uses: actions/checkout@v2

- name: test.sh
env:
OS: ${{ matrix.os.name }}
OS_VERSION: ${{ matrix.os.version }}
PYTHON_VERSION: ${{ matrix.os.python }}
ENGINE: ${{ matrix.os.engine }}
run: ./test.sh

- name: Coveralls Python parallel
uses: AndreMiras/coveralls-python-action@master
with:
parallel: true

coveralls_finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Python finish
uses: AndreMiras/coveralls-python-action@master
with:
parallel-finished: true

pylint:
name: Pylint analyzer for Python ${{ matrix.os.python }}
runs-on: ubuntu-latest

strategy:
matrix:
os:
- name: fedora
version: 29
python: 2
engine: docker

- name: fedora
version: 31
python: 3
engine: docker

steps:
- uses: actions/checkout@v2

- run: ./test.sh
env:
OS: ${{ matrix.os.name }}
OS_VERSION: ${{ matrix.os.version }}
PYTHON_VERSION: ${{ matrix.os.python }}
ENGINE: ${{ matrix.os.engine }}
ACTION: pylint

bandit:
name: Bandit analyzer for Python ${{ matrix.os.python }}
runs-on: ubuntu-latest

strategy:
matrix:
os:
- name: centos
version: 7
python: 2
engine: docker

- name: fedora
version: 31
python: 3
engine: docker

steps:
- uses: actions/checkout@v1

- run: ./test.sh
env:
OS: ${{ matrix.os.name }}
OS_VERSION: ${{ matrix.os.version }}
PYTHON_VERSION: ${{ matrix.os.python }}
ENGINE: ${{ matrix.os.engine }}
ACTION: bandit
5 changes: 0 additions & 5 deletions .stickler.yml

This file was deleted.

50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions atomic_reactor/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def run(self, keep_going=False, buildstep_phase=False):
self.plugins_results[plugin.plugin_class.key] = plugin_response
break

except AutoRebuildCanceledException as ex:
except AutoRebuildCanceledException:
# if auto rebuild is canceled, then just reraise
# NOTE: We need to catch and reraise explicitly, so that the below except clause
# doesn't catch this and make PluginFailedException out of it in the end
Expand Down Expand Up @@ -375,7 +375,7 @@ def _translate_special_values(self, obj_to_translate):
translation_dict = {
'BUILT_IMAGE_ID': self.workflow.builder.image_id,
'BUILD_DOCKERFILE_PATH': self.workflow.builder.source.dockerfile_path,
'BUILD_SOURCE_PATH': self.workflow.builder.source.path,
'BUILD_SOURCE_PATH': self.workflow.builder.source.path,
}

if self.workflow.builder.base_image:
Expand Down
1 change: 0 additions & 1 deletion atomic_reactor/plugins/post_tag_and_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def __init__(self, tasker, workflow, registries=None, koji_target=None):
self.group = get_group_manifests(self.workflow, False)
self.koji_target = koji_target


def need_skopeo_push(self):
if len(self.workflow.exported_image_sequence) > 0:
last_image = self.workflow.exported_image_sequence[-1]
Expand Down
2 changes: 1 addition & 1 deletion atomic_reactor/utils/yum.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def filename(self):
if not basename.endswith(REPO_SUFFIX):
basename += REPO_SUFFIX
if self.add_hash:
suffix = '-' + md5(self.repourl.encode('utf-8')).hexdigest()[:5] # nosec
suffix = '-' + md5(self.repourl.encode('utf-8')).hexdigest()[:5] # nosec
else:
suffix = ''
final_name = suffix.join(os.path.splitext(basename))
Expand Down
4 changes: 3 additions & 1 deletion docs/manpage/generate_manpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def __init__(self,
ext_sections=None,
):

super(ManPageFormatter, self).__init__(prog, width=width, max_help_position=max_help_position)
super(ManPageFormatter, self).__init__(prog, width=width,
max_help_position=max_help_position)

self._prog = prog
self._section = section
Expand Down Expand Up @@ -198,5 +199,6 @@ def _format_action_invocation(self, action):

return ', '.join(parts)


mg = ManPageGenerator()
mg.run()
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,25 @@
],
}


def _get_requirements(path):
try:
with open(path) as f:
packages = f.read().splitlines()
except (IOError, OSError) as ex:
raise RuntimeError("Can't open file with requirements: %s", ex)
packages = (p.strip() for p in packages if not re.match("^\s*#", p))
packages = (p.strip() for p in packages if not re.match(r'^\s*#', p))
packages = list(filter(None, packages))
return packages


def _install_requirements():
requirements = _get_requirements('requirements.txt')
if sys.version_info[0] < 3:
requirements += _get_requirements('requirements-py2.txt')
return requirements


setup(
name='atomic-reactor',
version='1.6.52',
Expand All @@ -55,4 +58,3 @@ def _install_requirements():
package_data={'atomic_reactor': ['schemas/*.json']},
data_files=data_files.items(),
)

16 changes: 4 additions & 12 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ ACTION=${ACTION:="test"}
IMAGE="$OS:$OS_VERSION"
CONTAINER_NAME="atomic-reactor-$OS-$OS_VERSION-py$PYTHON_VERSION"

if [[ $ACTION == "markdownlint" ]]; then
IMAGE="ruby"
CONTAINER_NAME="atomic-reactor-$ACTION-$IMAGE"
RUN="$ENGINE exec -ti $CONTAINER_NAME"
fi

# Use arrays to prevent globbing and word splitting
engine_mounts=(-v "$PWD":"$PWD":z)
for dir in ${EXTRA_MOUNT:-}; do
Expand Down Expand Up @@ -43,7 +37,7 @@ function setup_osbs() {

# PIP_PREFIX: osbs-client provides input templates that must be copied into /usr/share/...
ENVS='-e PIP_PREFIX=/usr'
RUN="$ENGINE exec -ti ${ENVS} $CONTAINER_NAME"
RUN="$ENGINE exec -i ${ENVS} $CONTAINER_NAME"
PYTHON="python$PYTHON_VERSION"
if [[ $OS == "fedora" ]]; then
PIP_PKG="python$PYTHON_VERSION-pip"
Expand Down Expand Up @@ -73,6 +67,7 @@ function setup_osbs() {
# Install dependencies
PKG_COMMON_EXTRA="git gcc krb5-devel python-devel popt-devel"
PKG_EXTRA="$PKG_EXTRA $PKG_COMMON_EXTRA"
# shellcheck disable=SC2086
$RUN $PKG $ENABLE_REPO install -y $PKG_EXTRA
[[ ${PYTHON_VERSION} == '3' ]] && WITH_PY3=1 || WITH_PY3=0
$RUN $BUILDDEP --define "with_python3 ${WITH_PY3}" -y atomic-reactor.spec
Expand Down Expand Up @@ -143,7 +138,7 @@ function setup_osbs() {
case ${ACTION} in
"test")
setup_osbs
TEST_CMD="pytest tests --cov atomic_reactor --cov-report html"
TEST_CMD="coverage run --source=atomic_reactor -m pytest --color=yes tests"
;;
"pylint")
setup_osbs
Expand All @@ -158,17 +153,14 @@ case ${ACTION} in
$RUN "${PIP_INST[@]}" bandit
TEST_CMD="bandit-baseline -r atomic_reactor -ll -ii"
;;
"markdownlint")
$RUN gem install mdl
TEST_CMD="mdl -g ."
;;
*)
echo "Unknown action: ${ACTION}"
exit 2
;;
esac

# Run tests
# shellcheck disable=SC2086
$RUN ${TEST_CMD} "$@"

echo "To run tests again:"
Expand Down
1 change: 0 additions & 1 deletion tests/plugins/test_compare_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def test_compare_components_plugin(tmpdir, caplog, base_from_scratch, mismatch,
assert log_msg in caplog.text



def test_no_components(tmpdir):
workflow = mock_workflow(tmpdir)
worker_metadatas = mock_metadatas()
Expand Down
3 changes: 2 additions & 1 deletion tests/plugins/test_fetch_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def mock_env(tmpdir, docker_tasker, scratch=False, orchestrator=False, koji_buil
plugin_conf[0]['args'] = {
'koji_build_id': koji_build_id,
'koji_build_nvr': koji_build_nvr
}
}

flexmock(atomic_reactor.source.GitSource, get=str(tmpdir))
runner = PreBuildPluginsRunner(docker_tasker, workflow, plugin_conf)
Expand Down Expand Up @@ -221,6 +221,7 @@ def body_remote_callback(request, context):
requests_mock.register_uri('GET', get_remote_url(KOJI_BUILD), body=body_remote_callback)
requests_mock.register_uri('GET', get_remote_url(KOJI_PARENT_BUILD), body=body_remote_callback)


class TestFetchSources(object):
@pytest.mark.parametrize('retries', (0, 1, constants.HTTP_MAX_RETRIES + 1))
@pytest.mark.parametrize('custom_rcm', (None, BASE_CONFIG_MAP))
Expand Down
Loading