You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/07/02 16:21:06 UTC

[GitHub] [flink] rmetzger commented on a change in pull request #12708: [FLINK-18125][Azure] Skip e2e execution on docs-only-PRs

rmetzger commented on a change in pull request #12708:
URL: https://github.com/apache/flink/pull/12708#discussion_r449130729



##########
File path: tools/azure-pipelines/build_properties.sh
##########
@@ -0,0 +1,55 @@
+#!/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.
+
+
+#
+# Returns 0 if the change is a documentation-only pull request
+#
+function is_docs_only_pullrequest() {
+	# check if it is a pull request branch, as generated by ci-bot:
+	if [[ ! $BUILD_SOURCEBRANCHNAME == ci_* ]] ; then
+		echo "INFO: Branch name mismatch";
+		return 1
+	fi
+	PR_ID=`echo "$BUILD_SOURCEBRANCHNAME" | cut -f2 -d_`
+	if ! [[ "$PR_ID" =~ ^[0-9]+$ ]] ; then
+		echo "ERROR: Extracted PR_ID is not a number, but this: '$PR_ID'"
+	 	return 1
+	fi
+	# check if it is docs only pull request
+	# 1. Get PR details
+	GITHUB_PULL_DETAIL=`curl --silent "https://api.github.com/repos/apache/flink/pulls/$PR_ID"`
+
+	# 2. Check if this build is in sync with the PR
+	GITHUB_PULL_HEAD_SHA=`echo $GITHUB_PULL_DETAIL | jq -r ".head.sha"`
+	THIS_BRANCH_SHA=`git rev-parse HEAD`
+
+	if [[ "$GITHUB_PULL_HEAD_SHA" != "$THIS_BRANCH_SHA" ]] ; then
+		echo "INFO: SHA mismatch: GITHUB_PULL_HEAD_SHA=$GITHUB_PULL_HEAD_SHA != THIS_BRANCH_SHA=$THIS_BRANCH_SHA";
+		# sha mismatch. There's some timing issue, and we can't trust the result
+		return 1
+	fi
+
+	# 3. Get number of commits in PR
+	GITHUB_NUM_COMMITS=`echo $GITHUB_PULL_DETAIL | jq -r ".commits"`
+
+	if [[ $(git diff --name-only $GITHUB_PULL_HEAD_SHA..$GITHUB_PULL_HEAD_SHA~$GITHUB_NUM_COMMITS | grep -v "docs/") == "" ]] ; then
+		echo "INFO: This is a docs only change. Changed files:"
+		git diff --name-only $GITHUB_PULL_HEAD_SHA..$GITHUB_PULL_HEAD_SHA~$GITHUB_NUM_COMMITS

Review comment:
       Somehow, it didn't work. I could not reproduce it locally, but I didn't want to spend more time trying this on CI, because setting up a matching PR is not that simple :) 




----------------------------------------------------------------
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.

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