Skip to content

Commit

Permalink
Merge pull request #78 from cloudify-cosmo/replace-wagon-builder-to-p…
Browse files Browse the repository at this point in the history
…y2py3-builder

Replace wagon builder to py2py3 builder
  • Loading branch information
AdarShaked authored Jun 22, 2020
2 parents a4a11af + f91a513 commit 13ba8d2
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 19 deletions.
188 changes: 178 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2
version: 2.1

checkout:
post:
Expand All @@ -9,20 +9,30 @@ checkout:
git checkout -qf FETCH_HEAD
fi
jobs:
flake8:
executors:
py27:
docker:
- image: circleci/python:2.7

py36:
docker:
- image: circleci/python:3.6

wagon_generator:
machine:
image: ubuntu-1604:201903-01

commands:

flake8:
steps:
- checkout
- run: pip install flake8 --user
- run:
name: Run flake8
command: flake8 fabric_plugin

unittests:
docker:
- image: circleci/python:2.7
run_unittests:
steps:
- checkout
- run:
Expand All @@ -40,9 +50,167 @@ jobs:
- store_test_results:
path: test-results

check_py3_compat:
steps:
- run:
name: install futurize
command: pip install future --user
- run:
# those modules contain code that futurize would want to change,
# so let's just remove them so that it doesn't report on them
# (there's no "exclude" functionality in futurize)
name: remove compat modules
command: |
rm fabric_plugin/_compat.py
- run:
name: find python3-incompatible code
command: |
FUTURIZE="futurize ."
while read line; do
[[ "$line" =~ ^#.* ]] && continue
FUTURIZE="${FUTURIZE} ${line}"
done<.circleci/py3fixers
echo "Running: $FUTURIZE"
$FUTURIZE>futurize_diffs
- run:
name: check that there is no python3-incompatible code
command: |
if [[ -s futurize_diffs ]]; then
echo "Python-3-incompatible code found"
cat futurize_diffs
exit 1
fi
generate_py27py36_wagon:
steps:
- run:
name: Create Workspace Build directory.
command: mkdir -p workspace/build
- run:
name: Build py27py36 Wagon
command: |
git clone https://github.com/cloudify-cosmo/cloudify-wagon-build-containers.git
docker build -t cloudify-centos-7-wagon-builder cloudify-wagon-build-containers/centos_7_py2py3
docker run -v ~/project/:/packaging cloudify-centos-7-wagon-builder
- run:
name: copy wagon to workspace
command: cp *.wgn workspace/build/
- persist_to_workspace:
root: workspace
paths:
- build/*

generate_rhel_py27py36_wagon:
steps:
- run:
name: Create Workspace Build directory.
command: mkdir -p workspace/build
- run:
name: Build RHEL py27py36 Wagon
command: |
git clone https://github.com/cloudify-cosmo/cloudify-wagon-build-containers.git
docker build -t cloudify-redhat-7-wagon-builder cloudify-wagon-build-containers/redhat_7_py2py3 --build-arg USERNAME="$USERNAME" --build-arg PASSWORD="$PASSWORD"
docker run -v ~/project/:/packaging cloudify-redhat-7-wagon-builder
- run:
name: copy wagon to workspace
command: cp *.wgn workspace/build/
- persist_to_workspace:
root: workspace
paths:
- build/*

release_plugin:
steps:
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update --remote --recursive
- run:
name: Download pip
command: curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
- run:
name: Install pip
command: sudo python get-pip.py
- run:
name: Install virtualenv
command: pip install --user virtualenv
- run:
name: Init virtualenv
command: virtualenv env
- run:
name: install tox
command: pip install --user pygithub pyyaml==3.10
- run:
name: upgrade setuptools
command: pip install --upgrade setuptools
- run:
name: install local project
command: pip install https://github.com/cloudify-incubator/cloudify-ecosystem-test/archive/latest.zip
- attach_workspace:
at: workspace
- run: python .circleci/package_release.py
jobs:

unittests_py27:
executor: py27
steps:
- checkout
- flake8
- run_unittests

unittests_py36:
executor: py36
steps:
- checkout
- flake8
- run_unittests

py3_compat:
executor: py27
steps:
- checkout
- check_py3_compat

wagon:
executor: wagon_generator
steps:
- checkout
- generate_py27py36_wagon

rhel_wagon:
executor: wagon_generator
steps:
- checkout
- generate_rhel_py27py36_wagon

release:
executor: py27
steps:
- checkout
- release_plugin

workflows:
version: 2
version: 2.1
tests:
jobs:
- flake8
- unittests
jobs: &all_jobs
- py3_compat
- unittests_py27
- unittests_py36
- wagon:
filters:
branches:
only: /([0-9\.]*\-build|master|dev)/
- rhel_wagon:
filters:
branches:
only: /([0-9\.]*\-build|master|dev)/
- release:
filters:
branches:
only: /master/
requires:
- wagon
- rhel_wagon
- unittests_py27
- unittests_py36

12 changes: 12 additions & 0 deletions .circleci/package_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from os import path, pardir
from ecosystem_cicd_tools.release import (
plugin_release_with_latest, find_version)

setup_py = path.join(
path.abspath(path.join(path.dirname(__file__), pardir)),
'setup.py')


if __name__ == '__main__':
plugin_release_with_latest(
'cloudify-fabric-plugin', find_version(setup_py))
21 changes: 21 additions & 0 deletions .circleci/py3fixers
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--stage1
-f lib2to3.fixes.fix_getcwdu
-f lib2to3.fixes.fix_long
-f lib2to3.fixes.fix_nonzero
-f lib2to3.fixes.fix_input
-f lib2to3.fixes.fix_raw_input
-f lib2to3.fixes.fix_itertools
-f lib2to3.fixes.fix_itertools_imports
-f lib2to3.fixes.fix_exec
-f lib2to3.fixes.fix_operator
-f libfuturize.fixes.fix_execfile
-f libpasteurize.fixes.fix_newstyle
-f lib2to3.fixes.fix_filter
-f lib2to3.fixes.fix_map
-f lib2to3.fixes.fix_zip
-f lib2to3.fixes.fix_xrange
-f lib2to3.fixes.fix_basestring
-f libfuturize.fixes.fix_cmp
-f libfuturize.fixes.fix_division_safe
-f lib2to3.fixes.fix_metaclass
-f libfuturize.fixes.fix_unicode_keep_u
1 change: 0 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
git+https://github.com/cloudify-cosmo/cloudify-common@master#egg=cloudify-common==master
1 change: 1 addition & 0 deletions fabric_plugin/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def exec_(code, globs):
""")

else:
import builtins
from io import StringIO
exec_ = getattr(builtins, 'exec')

Expand Down
4 changes: 2 additions & 2 deletions fabric_plugin/tests/test_fabric_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def test_missing_tasks_file(self):
self._execute('test.run_task', tasks_file='missing.py')

def test_bad_tasks_file(self):
with self.assertRaisesRegexp(NonRecoverableError,
"ImportError: No module named module"):

with self.assertRaisesRegexp(NonRecoverableError, "No module named"):
self._execute('test.run_task', tasks_file='corrupted_file.py')

def test_missing_task(self):
Expand Down
4 changes: 2 additions & 2 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
plugins:
fabric:
executor: central_deployment_agent
source: https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/2.0.1.zip
source: https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/2.0.3.zip
package_name: cloudify-fabric-plugin
package_version: '2.0.1'
package_version: '2.0.3'
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

setup(
name='cloudify-fabric-plugin',
version='2.0.2',
version='2.0.3',
author='Cloudify',
author_email='[email protected]',
packages=['fabric_plugin'],
license='LICENSE',
description='Plugin for remotely running fabric tasks and commands',
install_requires=[
'cloudify-common>=5.1.0.dev1',
'cloudify-common>=4.5.5',
'fabric==2.5.0',
]
)

0 comments on commit 13ba8d2

Please sign in to comment.