[ 
https://issues.apache.org/jira/browse/BEAM-3257?focusedWorklogId=87840&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-87840
 ]

ASF GitHub Bot logged work on BEAM-3257:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Apr/18 00:51
            Start Date: 05/Apr/18 00:51
    Worklog Time Spent: 10m 
      Work Description: lukecwik closed pull request #5010: [BEAM-3257] Add 
Python precommit gradle config
URL: https://github.com/apache/beam/pull/5010
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.test-infra/jenkins/job_beam_PreCommit_Python_GradleBuild.groovy 
b/.test-infra/jenkins/job_beam_PreCommit_Python_GradleBuild.groovy
new file mode 100644
index 00000000000..d2fdef72ad3
--- /dev/null
+++ b/.test-infra/jenkins/job_beam_PreCommit_Python_GradleBuild.groovy
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import common_job_properties
+
+// This is the Python precommit which runs a Gradle build, and the current set
+// of precommit tests.
+job('beam_PreCommit_Python_GradleBuild') {
+  description('Runs Python PreCommit tests for the current GitHub Pull 
Request.')
+
+  // Execute concurrent builds if necessary.
+  concurrentBuild()
+
+  // Set common parameters.
+  common_job_properties.setTopLevelMainJobProperties(
+    delegate,
+    'master',
+    90)
+
+  def gradle_switches = [
+    // Gradle log verbosity enough to diagnose basic build issues
+    "--info",
+    // Continue the build even if there is a failure to show as many potential 
failures as possible.
+    '--continue',
+    // Until we verify the build cache is working appropriately, force 
rerunning all tasks
+    '--rerun-tasks',
+  ]
+
+  def gradle_command_line = './gradlew ' + gradle_switches.join(' ') + ' 
:pythonPreCommit'
+  // Sets that this is a PreCommit job.
+  common_job_properties.setPreCommit(delegate, gradle_command_line, 'Run 
Python Gradle PreCommit')
+  steps {
+    gradle {
+      rootBuildScriptDir(common_job_properties.checkoutDir)
+      tasks(':pythonPreCommit')
+      for (String gradle_switch : gradle_switches) {
+        switches(gradle_switch)
+      }
+    }
+  }
+}
diff --git a/build.gradle b/build.gradle
index 602f8e11a33..7b8c60c169e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -126,3 +126,9 @@ task goPreCommit() {
   dependsOn ":rat"
   dependsOn ":sdks:go:test"
 }
+
+task pythonPreCommit() {
+  dependsOn ":rat"
+  dependsOn ":sdks:python:check"
+}
+
diff --git a/sdks/python/build.gradle b/sdks/python/build.gradle
index 2c6637a5373..be17644e8d3 100644
--- a/sdks/python/build.gradle
+++ b/sdks/python/build.gradle
@@ -25,75 +25,123 @@ apply plugin: "base"
 task test {}
 check.dependsOn test
 
-task setupTest {
+def envdir = "${project.buildDir}/gradleenv"
+
+task setupVirtualenv {
   doLast {
+    exec {
+      commandLine 'virtualenv', "${envdir}"
+    }
     exec {
       executable 'sh'
-      args '-c', 'which tox || pip install --user --upgrade tox'
+      args '-c', ". ${envdir}/bin/activate && pip install --upgrade tox"
     }
   }
+  outputs.files("${envdir}/bin/tox")
 }
 
-task sdist {
+task sdist(dependsOn: 'setupVirtualenv') {
   doLast {
     exec {
-      commandLine 'python', 'setup.py', 'sdist', '--formats', 'zip,gztar', 
'--dist-dir', project.buildDir
+      executable 'sh'
+      args '-c', ". ${envdir}/bin/activate && python setup.py sdist --formats 
zip,gztar --dist-dir ${project.buildDir}"
     }
   }
 }
 
-task cleanPython {
+task cleanPython(dependsOn: 'setupVirtualenv') {
   doLast {
     exec {
-      commandLine 'python', 'setup.py', 'clean'
+      executable 'sh'
+      args '-c', ". ${envdir}/bin/activate && python setup.py clean"
     }
   }
 }
 clean.dependsOn cleanPython
 
-task buildPython {
+task buildPython(dependsOn: 'setupVirtualenv') {
   doLast {
     println 'Building Python Dependencies'
     exec {
-      commandLine 'python', 'setup.py', 'build', '--build-base', 
project.buildDir
+      executable 'sh'
+      args '-c', ". ${envdir}/bin/activate && python setup.py build 
--build-base ${project.buildDir}"
     }
   }
 }
 build.dependsOn buildPython
 
-task lint (dependsOn: 'setupTest') {
+task lint {}
+check.dependsOn lint
+
+task lintPy27(dependsOn: 'setupVirtualenv') {
   doLast {
     exec {
-      commandLine 'tox', '-e', '{py27,py3}-lint', '-c', 'tox.ini'
+      executable 'sh'
+      args '-c', ". ${envdir}/bin/activate && tox -e py27-lint -c tox.ini"
     }
   }
 }
-check.dependsOn lint
+lint.dependsOn lintPy27
 
-// Ensure that testCython runs exclusively to other tests.
-task testCython (dependsOn: ['setupTest', 'testPython', 'testGcp']) {
+task lintPy3(dependsOn: 'setupVirtualenv') {
   doLast {
     exec {
-      commandLine 'tox', '-e', 'py27-cython2', '-c', 'tox.ini'
+      executable 'sh'
+      args '-c', ". ${envdir}/bin/activate && tox -e py3-lint -c tox.ini"
     }
   }
 }
-test.dependsOn testCython
+lint.dependsOn lintPy3
 
-task testGcp (dependsOn: 'setupTest') {
+task testGcp(dependsOn: 'setupVirtualenv') {
   doLast {
     exec {
-      commandLine 'tox', '-e', 'py27-gcp', '-c', 'tox.ini'
+      executable 'sh'
+      args '-c', ". ${envdir}/bin/activate && tox -e py27-gcp -c tox.ini"
     }
   }
 }
 test.dependsOn testGcp
 
-task testPython (dependsOn: 'setupTest') {
+task testPython(dependsOn: 'setupVirtualenv') {
   doLast {
-         exec {
-           commandLine 'tox', '-e', 'ALL', '-c', 'tox.ini'
-         }
+    exec {
+      executable 'sh'
+      args '-c', ". ${envdir}/bin/activate && tox -e py27 -c tox.ini"
+    }
   }
 }
 test.dependsOn testPython
+
+task testCython(dependsOn: 'setupVirtualenv') {
+  doLast {
+    exec {
+      executable 'sh'
+      args '-c', ". ${envdir}/bin/activate && tox -e py27-cython2 -c tox.ini"
+    }
+  }
+}
+test.dependsOn testCython
+// Ensure that testCython runs exclusively to other tests. This line is not
+// actually required, since gradle doesn't do parallel execution within a
+// project.
+testCython.mustRunAfter testPython, testGcp
+
+task docs(dependsOn: 'setupVirtualenv') {
+  doLast {
+    exec {
+      executable 'sh'
+      args '-c', ". ${envdir}/bin/activate && tox -e docs -c tox.ini"
+    }
+  }
+}
+assemble.dependsOn docs
+
+task cover(dependsOn: 'setupVirtualenv') {
+  doLast {
+    exec {
+      executable 'sh'
+      args '-c', ". ${envdir}/bin/activate && tox -e cover -c tox.ini"
+    }
+  }
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 87840)
    Time Spent: 3h  (was: 2h 50m)

> Migrate Python Jenkins PreCommits to Gradle
> -------------------------------------------
>
>                 Key: BEAM-3257
>                 URL: https://issues.apache.org/jira/browse/BEAM-3257
>             Project: Beam
>          Issue Type: Sub-task
>          Components: build-system, testing
>            Reporter: Luke Cwik
>            Assignee: Udi Meiri
>            Priority: Major
>          Time Spent: 3h
>  Remaining Estimate: 0h
>
> Code is here: 
> https://github.com/apache/beam/blob/master/.test-infra/jenkins/job_beam_PreCommit_Python_MavenInstall.groovy



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to