You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by pa...@apache.org on 2020/08/30 18:29:50 UTC

[beam] branch master updated: [BEAM-10775] Added a typescript precommit job

This is an automated email from the ASF dual-hosted git repository.

pabloem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 024f1d6  [BEAM-10775] Added a typescript precommit job
     new 9aa6c39  Merge pull request #12699 from [BEAM-10775] Added a typescript precommit job
024f1d6 is described below

commit 024f1d61db5a92d97ed5fe8c0485db8355fa1b8f
Author: Ning Kang <ni...@google.com>
AuthorDate: Thu Aug 20 16:02:08 2020 -0700

    [BEAM-10775] Added a typescript precommit job
    
    1. The job runs 2 checks: jest for unit tests; eslint for lint and
       format.
    2. The job is triggered on change under
       sdks/python/apache_beam/runners/interactive/extensions. Any
       typescript code outside this directory needs to be explicitly added
       to the trigger pattern and the copyTsSource task.
---
 .../jenkins/job_PreCommit_Typescript.groovy        | 29 ++++++++++++++
 build.gradle                                       |  5 +++
 sdks/python/scripts/run_eslint.sh                  | 44 ++++++++++++++++++++++
 sdks/python/scripts/run_jest.sh                    | 43 +++++++++++++++++++++
 sdks/python/test-suites/tox/py38/build.gradle      | 17 +++++++++
 sdks/python/tox.ini                                | 14 +++++++
 6 files changed, 152 insertions(+)

diff --git a/.test-infra/jenkins/job_PreCommit_Typescript.groovy b/.test-infra/jenkins/job_PreCommit_Typescript.groovy
new file mode 100644
index 0000000..29cb93e
--- /dev/null
+++ b/.test-infra/jenkins/job_PreCommit_Typescript.groovy
@@ -0,0 +1,29 @@
+/*
+ * 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 PrecommitJobBuilder
+
+PrecommitJobBuilder builder = new PrecommitJobBuilder(
+    scope: this,
+    nameBase: 'Typescript',
+    gradleTask: ':typescriptPreCommit',
+    triggerPathPatterns: [
+      '^sdks/python/apache_beam/runners/interactive/extensions/.*$',
+    ]
+    )
+builder.build()
diff --git a/build.gradle b/build.gradle
index fb06850..f96b030 100644
--- a/build.gradle
+++ b/build.gradle
@@ -325,6 +325,11 @@ task whitespacePreCommit() {
   dependsOn ":sdks:python:test-suites:tox:py38:whitespacelint"
 }
 
+task typescriptPreCommit() {
+  dependsOn ":sdks:python:test-suites:tox:py38:eslint"
+  dependsOn ":sdks:python:test-suites:tox:py38:jest"
+}
+
 // Configure the release plugin to do only local work; the release manager determines what, if
 // anything, to push. On failure, the release manager can reset the branch without pushing.
 release {
diff --git a/sdks/python/scripts/run_eslint.sh b/sdks/python/scripts/run_eslint.sh
new file mode 100755
index 0000000..9be31ef
--- /dev/null
+++ b/sdks/python/scripts/run_eslint.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+#    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.
+#
+
+# The script runs eslint checks for all known typescript projects in the Beam
+# repo.
+
+set -e
+
+echo "Running eslint checks..."
+
+# Source needed to run tests are copied to this build dir by the copyTsSource
+# task.
+pushd ../../../ts
+
+# Root dir for all Beam jupyterlab extensions.
+LAB_EXT_DIR="sdks/python/apache_beam/runners/interactive/extensions"
+
+known_test_dirs=( \
+  "$LAB_EXT_DIR/apache-beam-jupyterlab-sidepanel" \
+)
+
+for dir in $known_test_dirs; do
+  pushd $dir
+  jlpm
+  jlpm eslint:check
+  popd
+done
+
+popd
diff --git a/sdks/python/scripts/run_jest.sh b/sdks/python/scripts/run_jest.sh
new file mode 100755
index 0000000..243663e
--- /dev/null
+++ b/sdks/python/scripts/run_jest.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+#    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.
+#
+
+# The script runs jest tests for all known typescript projects in the Beam repo.
+
+set -e
+
+echo "Running jest tests..."
+
+# Source needed to run tests are copied to this build dir by copySourceForJest
+# task.
+pushd ../../../ts
+
+# Root dir for all Beam jupyterlab extensions.
+LAB_EXT_DIR="sdks/python/apache_beam/runners/interactive/extensions"
+
+known_test_dirs=( \
+  "$LAB_EXT_DIR/apache-beam-jupyterlab-sidepanel" \
+)
+
+for dir in $known_test_dirs; do
+  pushd $dir
+  jlpm
+  jlpm jest
+  popd
+done
+
+popd
diff --git a/sdks/python/test-suites/tox/py38/build.gradle b/sdks/python/test-suites/tox/py38/build.gradle
index c0d003d..36fd5c6 100644
--- a/sdks/python/test-suites/tox/py38/build.gradle
+++ b/sdks/python/test-suites/tox/py38/build.gradle
@@ -55,3 +55,20 @@ task unpackFilesToLint(type: Copy) {
 whitespacelint.dependsOn archiveFilesToLint, unpackFilesToLint
 unpackFilesToLint.dependsOn archiveFilesToLint
 archiveFilesToLint.dependsOn cleanPython
+
+toxTask "jest", "jest"
+
+toxTask "eslint", "eslint"
+
+task copyTsSource(type: Copy) {
+  from ("$rootProject.projectDir") {
+    include "sdks/python/apache_beam/runners/interactive/extensions/**/*"
+    exclude "sdks/python/apache_beam/runners/interactive/extensions/**/lib/*"
+    exclude "sdks/python/apache_beam/runners/interactive/extensions/**/node_modules/*"
+  }
+  into "$buildDir/ts"
+}
+
+jest.dependsOn copyTsSource
+eslint.dependsOn copyTsSource
+copyTsSource.dependsOn cleanPython
diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini
index 93c7e6e..ae1e51d 100644
--- a/sdks/python/tox.ini
+++ b/sdks/python/tox.ini
@@ -333,3 +333,17 @@ extras = test,gcp,aws,interactive,interactive_test
 passenv = WORKSPACE
 commands =
   time {toxinidir}/scripts/run_dependency_check.sh
+
+[testenv:jest]
+setenv =
+deps =
+  jupyterlab==2.2.5
+commands =
+  time {toxinidir}/scripts/run_jest.sh
+
+[testenv:eslint]
+setenv =
+deps =
+  jupyterlab==2.2.5
+commands =
+  time {toxinidir}/scripts/run_eslint.sh