You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by dr...@apache.org on 2022/11/14 23:30:28 UTC
[tvm] branch main updated: [CI] Do not merge before running CI on main (#13372)
This is an automated email from the ASF dual-hosted git repository.
driazati pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 41a2243260 [CI] Do not merge before running CI on main (#13372)
41a2243260 is described below
commit 41a22432608e5d1176f697848a06e87d3fe5c849
Author: Florin Blanaru <fl...@gmail.com>
AuthorDate: Tue Nov 15 00:30:22 2022 +0100
[CI] Do not merge before running CI on main (#13372)
This PR does not merge `main` if CI is running already on `main`. It aims to avoid a case where a race happens between two subsequent commits, and one of them merges the other.
Fixes #12392.
---
Jenkinsfile | 42 ++++++++++++++++++++++++++++--------------
ci/jenkins/Prepare.groovy.j2 | 42 ++++++++++++++++++++++++++++--------------
2 files changed, 56 insertions(+), 28 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 079fb06889..9fd926430b 100755
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -129,21 +129,13 @@ def init_git() {
)
// Determine merge commit to use for all stages
- sh (
- script: 'git fetch origin main',
- label: 'Fetch upstream',
- )
- if (upstream_revision == null) {
- upstream_revision = sh(
- script: 'git log -1 FETCH_HEAD --format=\'%H\'',
- label: 'Determine upstream revision',
- returnStdout: true,
- ).trim()
+ if (env.BRANCH_NAME == 'main') {
+ // Only set upstream_revision to HEAD and skip merging to avoid a race with another commit merged to main.
+ update_upstream_revision("HEAD")
+ } else {
+ // This is PR branch so merge with latest main.
+ merge_with_main()
}
- sh (
- script: "git -c user.name=TVM-Jenkins -c user.email=jenkins@tvm.apache.org merge ${upstream_revision}",
- label: 'Merge to origin/main'
- )
sh(
script: """
@@ -156,6 +148,28 @@ def init_git() {
checkout_trusted_files()
}
+def update_upstream_revision(git_ref) {
+ if (upstream_revision == null) {
+ upstream_revision = sh(
+ script: "git log -1 ${git_ref} --format=\'%H\'",
+ label: 'Determine upstream revision',
+ returnStdout: true,
+ ).trim()
+ }
+}
+
+def merge_with_main() {
+ sh (
+ script: 'git fetch origin main',
+ label: 'Fetch upstream',
+ )
+ update_upstream_revision("FETCH_HEAD")
+ sh (
+ script: "git -c user.name=TVM-Jenkins -c user.email=jenkins@tvm.apache.org merge ${upstream_revision}",
+ label: 'Merge to origin/main'
+ )
+}
+
def docker_init(image) {
// Clear out all Docker images that aren't going to be used
sh(
diff --git a/ci/jenkins/Prepare.groovy.j2 b/ci/jenkins/Prepare.groovy.j2
index 4fd5e66e2f..6a82a887ed 100644
--- a/ci/jenkins/Prepare.groovy.j2
+++ b/ci/jenkins/Prepare.groovy.j2
@@ -15,21 +15,13 @@ def init_git() {
)
// Determine merge commit to use for all stages
- sh (
- script: 'git fetch origin main',
- label: 'Fetch upstream',
- )
- if (upstream_revision == null) {
- upstream_revision = sh(
- script: 'git log -1 FETCH_HEAD --format=\'%H\'',
- label: 'Determine upstream revision',
- returnStdout: true,
- ).trim()
+ if (env.BRANCH_NAME == 'main') {
+ // Only set upstream_revision to HEAD and skip merging to avoid a race with another commit merged to main.
+ update_upstream_revision("HEAD")
+ } else {
+ // This is PR branch so merge with latest main.
+ merge_with_main()
}
- sh (
- script: "git -c user.name=TVM-Jenkins -c user.email=jenkins@tvm.apache.org merge ${upstream_revision}",
- label: 'Merge to origin/main'
- )
sh(
script: """
@@ -42,6 +34,28 @@ def init_git() {
checkout_trusted_files()
}
+def update_upstream_revision(git_ref) {
+ if (upstream_revision == null) {
+ upstream_revision = sh(
+ script: "git log -1 ${git_ref} --format=\'%H\'",
+ label: 'Determine upstream revision',
+ returnStdout: true,
+ ).trim()
+ }
+}
+
+def merge_with_main() {
+ sh (
+ script: 'git fetch origin main',
+ label: 'Fetch upstream',
+ )
+ update_upstream_revision("FETCH_HEAD")
+ sh (
+ script: "git -c user.name=TVM-Jenkins -c user.email=jenkins@tvm.apache.org merge ${upstream_revision}",
+ label: 'Merge to origin/main'
+ )
+}
+
def docker_init(image) {
// Clear out all Docker images that aren't going to be used
sh(