From fdb12f0ed030ccbd3ec80fa7b16c55260eba7ed8 Mon Sep 17 00:00:00 2001 From: muralinimmagadda <53462187+muralinimmagadda@users.noreply.github.com> Date: Thu, 23 Jan 2020 10:52:09 -0800 Subject: [PATCH 1/3] Fixes PYT-900 : Initial migration: Write pre commit action --- .github/workflows/pre-commit.yml | 93 +++++++++++++++++++ common/setup.py | 2 +- libs/setup.py | 2 +- platform/setup.py | 2 +- .../python/dlpx/virtualization/test_plugin.py | 2 +- 5 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..b02e2d32 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,93 @@ +name: Pre-commit actions for Delphix Virtualization Platform SDK + +on: [pull_request] + +jobs: + pytest: + name: Test ${{ matrix.package }} on ${{ matrix.os }} using pytest + runs-on: ${{ matrix.os }} + strategy: + max-parallel: 4 + matrix: + python-version: [2.7] + os: [ubuntu-latest, macos-latest] + package: [common, libs, platform, tools] + + steps: + - name: Checkout ${{ matrix.package }} project + uses: actions/checkout@v1 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Install ${{ matrix.package }} dependencies + working-directory: ${{ matrix.package }} + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt --index-url https://pypi.org/simple --extra-index-url https://test.pypi.org/simple + + - name: Install ${{ matrix.package }} project in editable mode + working-directory: ${{ matrix.package }} + run: | + pip install -e . --index-url https://pypi.org/simple --extra-index-url https://test.pypi.org/simple + + - name: Test ${{ matrix.package }} project with pytest + working-directory: ${{ matrix.package }} + run: | + pip install pytest + python -m pytest src/test/python + + lint: + name: Lint ${{ matrix.package }} + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + package: [tools] + + steps: + - name: Checkout ${{ matrix.package }} + uses: actions/checkout@v1 + + - name: Set up Python 2.7 + uses: actions/setup-python@v1 + with: + python-version: 2.7 + + - name: Install flake8 + run: | + python -m pip install --upgrade pip + pip install flake8 + + - name: Run flake8 on src directory + working-directory: ${{ matrix.package }} + run: python -m flake8 src/main/python --max-line-length 88 + + - name: Run flake8 on test directory + working-directory: ${{ matrix.package }} + run: python -m flake8 test/main/python --max-line-length 88 + + #format: + #name: Check format ${{ matrix.package}} + + #runs-on: ubuntu-latest + #strategy: + #max-parallel: 4 + #matrix: + #package: [common, libs, platform, tools] + + #steps: + #- uses: actions/checkout@v1 + + #- name: Check src format + #uses: lgeiger/black-action@v1.0.1 + #with: + #args: "${{ matrix.package }}/src/main/python -t py27 --check" + + #- name: Check test format + #uses: lgeiger/black-action@v1.0.1 + #with: + #args: "${{ matrix.package }}/src/test/python -t py27 --check" diff --git a/common/setup.py b/common/setup.py index 1aa23666..9beab27f 100644 --- a/common/setup.py +++ b/common/setup.py @@ -4,7 +4,7 @@ PYTHON_SRC = 'src/main/python' install_requires = [ - "dvp-api == 1.1.0-master-003", + "dvp-api == 1.1.0.dev3", ] with open(os.path.join(PYTHON_SRC, 'dlpx/virtualization/common/VERSION')) as version_file: diff --git a/libs/setup.py b/libs/setup.py index f99b4146..a8ceec1b 100644 --- a/libs/setup.py +++ b/libs/setup.py @@ -7,7 +7,7 @@ version = version_file.read().strip() install_requires = [ - "dvp-api == 1.1.0-master-003", + "dvp-api == 1.1.0.dev3", "dvp-common == {}".format(version) ] diff --git a/platform/setup.py b/platform/setup.py index 916d281c..8b6b8722 100644 --- a/platform/setup.py +++ b/platform/setup.py @@ -7,7 +7,7 @@ version = version_file.read().strip() install_requires = [ - "dvp-api == 1.1.0-master-003", + "dvp-api == 1.1.0.dev3", "dvp-common == {}".format(version), "enum34;python_version < '3.4'", ] diff --git a/platform/src/test/python/dlpx/virtualization/test_plugin.py b/platform/src/test/python/dlpx/virtualization/test_plugin.py index 3b1c9bde..594725fb 100755 --- a/platform/src/test/python/dlpx/virtualization/test_plugin.py +++ b/platform/src/test/python/dlpx/virtualization/test_plugin.py @@ -284,7 +284,7 @@ def virtual_source(connection, mount): virtual_source.guid = TEST_GUID virtual_source.connection.CopyFrom(connection) virtual_source.parameters.json = TEST_VIRTUAL_SOURCE_JSON - virtual_source.mounts.MergeFrom([mount]) + virtual_source.mounts.extend([mount]) return virtual_source @staticmethod From ece9fd57f9639d39dee3ea35b82e627607ada77e Mon Sep 17 00:00:00 2001 From: muralinimmagadda <53462187+muralinimmagadda@users.noreply.github.com> Date: Tue, 28 Jan 2020 13:11:59 -0800 Subject: [PATCH 2/3] Addressed review comments and fixed a failing testcase --- .github/workflows/pre-commit.yml | 7 +++---- .../dlpx/virtualization/_internal/test_package_util.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index b02e2d32..57d0a0f0 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -26,17 +26,16 @@ jobs: working-directory: ${{ matrix.package }} run: | python -m pip install --upgrade pip - pip install -r requirements.txt --index-url https://pypi.org/simple --extra-index-url https://test.pypi.org/simple + pip install -r requirements.txt --find-links https://test.pypi.org/simple/dvp-api/ - - name: Install ${{ matrix.package }} project in editable mode + - name: Install ${{ matrix.package }} project working-directory: ${{ matrix.package }} run: | - pip install -e . --index-url https://pypi.org/simple --extra-index-url https://test.pypi.org/simple + pip install . --find-links https://test.pypi.org/simple/dvp-api/ - name: Test ${{ matrix.package }} project with pytest working-directory: ${{ matrix.package }} run: | - pip install pytest python -m pytest src/test/python lint: diff --git a/tools/src/test/python/dlpx/virtualization/_internal/test_package_util.py b/tools/src/test/python/dlpx/virtualization/_internal/test_package_util.py index d75bbfa2..111b915c 100644 --- a/tools/src/test/python/dlpx/virtualization/_internal/test_package_util.py +++ b/tools/src/test/python/dlpx/virtualization/_internal/test_package_util.py @@ -43,7 +43,7 @@ def test_get_engine_api_version_json(): @staticmethod def test_get_internal_package_root(): assert package_util.get_internal_package_root().endswith( - 'main/python/dlpx/virtualization/_internal') + 'dlpx/virtualization/_internal') @staticmethod @pytest.mark.parametrize('version_string', [ From 74986df1edea8c54f50f3e1462157dabb09a8e2c Mon Sep 17 00:00:00 2001 From: muralinimmagadda <53462187+muralinimmagadda@users.noreply.github.com> Date: Wed, 29 Jan 2020 13:18:22 -0800 Subject: [PATCH 3/3] Addressed review comments --- .github/workflows/pre-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 57d0a0f0..a7625c63 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,4 +1,4 @@ -name: Pre-commit actions for Delphix Virtualization Platform SDK +name: Pre-commit actions for Delphix Virtualization SDK on: [pull_request]