You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/11/23 00:41:30 UTC

[GitHub] [tvm] driazati opened a new pull request #9554: Implement [skip ci] for Jenkins

driazati opened a new pull request #9554:
URL: https://github.com/apache/tvm/pull/9554


   GitHub Actions already respects this ([link](https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/)), this implements it for Jenkins as well. When `[skip ci]` is in the commit message of the head commit, the only things that will run are the sanity check + lint, so CI should be much quicker if someone manually sets this.
   
   This is useful for PRs that need to get landed quickly and the outcome is pretty well known, such as reverts.
   
   Thanks for contributing to TVM!   Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @ them in the pull request thread.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] areusch commented on a change in pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
areusch commented on a change in pull request #9554:
URL: https://github.com/apache/tvm/pull/9554#discussion_r768041428



##########
File path: tests/python/unittest/test_ci.py
##########
@@ -0,0 +1,116 @@
+# 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 pathlib
+import subprocess
+import sys
+import tempfile
+
+import pytest
+
+REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent.parent.parent
+
+
+def test_skip_ci():
+    skip_ci_script = REPO_ROOT / "tests" / "scripts" / "git_skip_ci.py"
+
+    class TempGit:
+        def __init__(self, cwd):
+            self.cwd = cwd
+
+        def run(self, *args):
+            proc = subprocess.run(["git"] + list(args), cwd=self.cwd)
+            if proc.returncode != 0:
+                raise RuntimeError(f"git command failed: '{args}'")
+
+    def test(commands, should_skip, why):
+        with tempfile.TemporaryDirectory() as dir:
+            git = TempGit(dir)
+            # Jenkins git is too old and doesn't have 'git init --initial-branch'
+            git.run("init")
+            git.run("checkout", "-b", "main")
+            git.run("remote", "add", "origin", "https://github.com/apache/tvm.git")
+            git.run("config", "user.name", "ci")
+            git.run("config", "user.email", "email@example.com")
+            git.run("commit", "--allow-empty", "--message", "base commit")
+            for command in commands:
+                git.run(*command)
+            pr_number = "1234"
+            proc = subprocess.run(
+                [str(skip_ci_script), "--pr", pr_number, "--pr-title", "[skip ci] test"], cwd=dir
+            )
+            expected = 0 if should_skip else 1
+            assert proc.returncode == expected, why
+
+    test(
+        commands=[],
+        should_skip=False,
+        why="ci should not be skipped",
+    )
+
+    test(
+        commands=[
+            ["commit", "--allow-empty", "--message", "[skip ci] commit 1"],
+        ],
+        should_skip=False,
+        why="ci should not be skipped on main",
+    )
+
+    test(
+        commands=[
+            ["checkout", "-b", "some_new_branch"],
+            ["commit", "--allow-empty", "--message", "[skip ci] commit 1"],
+        ],
+        should_skip=True,
+        why="ci should be skipped on a branch with [skip ci] in the last commit",

Review comment:
       do we have a test for when `[skip ci]` is in a commit but not in PR title? i don't think we should allow only the commit to have `[skip ci]`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] leandron commented on a change in pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
leandron commented on a change in pull request #9554:
URL: https://github.com/apache/tvm/pull/9554#discussion_r755580132



##########
File path: tests/scripts/git_skip_ci.sh
##########
@@ -0,0 +1,40 @@
+#!/usr/bin/env 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.
+
+set -eux
+
+# This implements the skip commands found here:
+# https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
+
+# The script will return 1 if any of these are found in the HEAD commit message
+# headline
+
+if git log --format='%s' HEAD~1..HEAD | grep --quiet \
+    --regexp='\[skip ci\]' \

Review comment:
       As this is something new we are introducing, we could start with only one documented pattern rather than all these option variants, which makes a bit harder to manually grep on which commits in history didn’t run a full CI.
   
   I am also a bit concerned on how we make sure that only exceptional changes that don’t really need CI will make use of this. As an extension, I wonder if Jenkins could somehow tag the PR with something when it detects the “skip ci” tag, so that it is obvious for reviewers that this didn’t run any checks, apart from lint.
   
   Any idea on how to tackle these?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] driazati commented on pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
driazati commented on pull request #9554:
URL: https://github.com/apache/tvm/pull/9554#issuecomment-990221297


   There are some test usages here showing how skip is triggered (i.e. the CI on the first commit in that PR takes only a few minutes): https://github.com/apache/tvm/pull/9686


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] areusch commented on pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
areusch commented on pull request #9554:
URL: https://github.com/apache/tvm/pull/9554#issuecomment-1011441655


   looks like the branch failed due to a flaky test. given passing tests linked from https://github.com/apache/tvm/pull/9686, i think we can merge and be confident we aren't going to break the Jenkinsfile


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] driazati commented on a change in pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
driazati commented on a change in pull request #9554:
URL: https://github.com/apache/tvm/pull/9554#discussion_r762279573



##########
File path: Jenkinsfile
##########
@@ -157,6 +157,16 @@ stage('Sanity Check') {
           script: "${docker_run} ${ci_lint}  ./tests/scripts/task_lint.sh",
           label: "Run lint",
         )
+        skip_ci = sh (
+          returnStatus: true,
+          script: './tests/scripts/git_skip_ci.sh',
+          label: "Check if CI should be skipped",
+        )
+        // if (skip_ci == 1) {

Review comment:
       sorry this was some work-in-progress code, I should have marked this as a draft since I'm still working on implementing the PR labeling aspect




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] driazati commented on a change in pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
driazati commented on a change in pull request #9554:
URL: https://github.com/apache/tvm/pull/9554#discussion_r768049498



##########
File path: tests/python/unittest/test_ci.py
##########
@@ -0,0 +1,116 @@
+# 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 pathlib
+import subprocess
+import sys
+import tempfile
+
+import pytest
+
+REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent.parent.parent
+
+
+def test_skip_ci():
+    skip_ci_script = REPO_ROOT / "tests" / "scripts" / "git_skip_ci.py"
+
+    class TempGit:
+        def __init__(self, cwd):
+            self.cwd = cwd
+
+        def run(self, *args):
+            proc = subprocess.run(["git"] + list(args), cwd=self.cwd)
+            if proc.returncode != 0:
+                raise RuntimeError(f"git command failed: '{args}'")
+
+    def test(commands, should_skip, why):
+        with tempfile.TemporaryDirectory() as dir:
+            git = TempGit(dir)
+            # Jenkins git is too old and doesn't have 'git init --initial-branch'
+            git.run("init")
+            git.run("checkout", "-b", "main")
+            git.run("remote", "add", "origin", "https://github.com/apache/tvm.git")
+            git.run("config", "user.name", "ci")
+            git.run("config", "user.email", "email@example.com")
+            git.run("commit", "--allow-empty", "--message", "base commit")
+            for command in commands:
+                git.run(*command)
+            pr_number = "1234"
+            proc = subprocess.run(
+                [str(skip_ci_script), "--pr", pr_number, "--pr-title", "[skip ci] test"], cwd=dir
+            )
+            expected = 0 if should_skip else 1
+            assert proc.returncode == expected, why
+
+    test(
+        commands=[],
+        should_skip=False,
+        why="ci should not be skipped",
+    )
+
+    test(
+        commands=[
+            ["commit", "--allow-empty", "--message", "[skip ci] commit 1"],
+        ],
+        should_skip=False,
+        why="ci should not be skipped on main",
+    )
+
+    test(
+        commands=[
+            ["checkout", "-b", "some_new_branch"],
+            ["commit", "--allow-empty", "--message", "[skip ci] commit 1"],
+        ],
+        should_skip=True,
+        why="ci should be skipped on a branch with [skip ci] in the last commit",

Review comment:
       added one in https://github.com/apache/tvm/pull/9554/commits/0710915b5936563278e809e0c4326033a184553f




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] areusch commented on pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
areusch commented on pull request #9554:
URL: https://github.com/apache/tvm/pull/9554#issuecomment-977454618


   couple thoughts:
   1. i think we should add unit tests for something like this so we can be sure it works correctly. it would be great to consider the cases of:
      - main has `[skip ci]` commit
      - PR branch has `[skip ci]` commit
      - no `[skip ci]` commit exists
   2. we might consider submitting this for RFC considering as it's a change to the development process.
   
   i'm also curious about @leandron's comment about flagging skipped PRs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] driazati commented on a change in pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
driazati commented on a change in pull request #9554:
URL: https://github.com/apache/tvm/pull/9554#discussion_r756457589



##########
File path: tests/scripts/git_skip_ci.sh
##########
@@ -0,0 +1,40 @@
+#!/usr/bin/env 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.
+
+set -eux
+
+# This implements the skip commands found here:
+# https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
+
+# The script will return 1 if any of these are found in the HEAD commit message
+# headline
+
+if git log --format='%s' HEAD~1..HEAD | grep --quiet \
+    --regexp='\[skip ci\]' \

Review comment:
       Agreed on consolidating on a single trigger message like `[skip ci]` for now. At some level we'd need to rely on committers / mergers knowing that `[skip ci]` should only be applied to quick fixes and reverts to unbreak master which seems do-able. We could make it easier to tell without clicking by add a label like `CI was skipped` to the PR (through [GitHub Actions](https://github.com/actions/labeler) or (ideally) directly from Jenkins)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] areusch merged pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
areusch merged pull request #9554:
URL: https://github.com/apache/tvm/pull/9554


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] leandron commented on a change in pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
leandron commented on a change in pull request #9554:
URL: https://github.com/apache/tvm/pull/9554#discussion_r757039515



##########
File path: tests/scripts/git_skip_ci.sh
##########
@@ -0,0 +1,40 @@
+#!/usr/bin/env 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.
+
+set -eux
+
+# This implements the skip commands found here:
+# https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
+
+# The script will return 1 if any of these are found in the HEAD commit message
+# headline
+
+if git log --format='%s' HEAD~1..HEAD | grep --quiet \
+    --regexp='\[skip ci\]' \

Review comment:
       Agreed. To me, that is a _must_ to have this PR in.
   
   Another point, just to mention, is that we ideally would like to document it somewhere, so that it is clear for the community this is available and how to use it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] driazati commented on pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
driazati commented on pull request #9554:
URL: https://github.com/apache/tvm/pull/9554#issuecomment-992791257


   Confirming sounds good, it should be ready to push now


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] shingjan commented on a change in pull request #9554: Implement [skip ci] for Jenkins

Posted by GitBox <gi...@apache.org>.
shingjan commented on a change in pull request #9554:
URL: https://github.com/apache/tvm/pull/9554#discussion_r761695800



##########
File path: Jenkinsfile
##########
@@ -157,6 +157,16 @@ stage('Sanity Check') {
           script: "${docker_run} ${ci_lint}  ./tests/scripts/task_lint.sh",
           label: "Run lint",
         )
+        skip_ci = sh (
+          returnStatus: true,
+          script: './tests/scripts/git_skip_ci.sh',
+          label: "Check if CI should be skipped",
+        )
+        // if (skip_ci == 1) {

Review comment:
       Should these comments be removed as they are duplicated below?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org