Skip to content

[ZEPPELIN-2162] [ZEPPELIN-2142] Make travis_check.py work with fork under organization, and show guidance if travis is not configured#2094

Closed
Leemoonsoo wants to merge 1 commit into
apache:masterfrom
Leemoonsoo:minor_update_travis_check
Closed

[ZEPPELIN-2162] [ZEPPELIN-2142] Make travis_check.py work with fork under organization, and show guidance if travis is not configured#2094
Leemoonsoo wants to merge 1 commit into
apache:masterfrom
Leemoonsoo:minor_update_travis_check

Conversation

@Leemoonsoo
Copy link
Copy Markdown
Member

What is this PR for?

When contributor uses zeppelin fork under organization, Jenkins can't check it with current travis_check.py.

This PR updates travis_check.py to distinguish error 1 when it fails with build fail, error 2 when it can't find build.

When it fails with 2, jenkins configuration can retry travis_check.py with organization repo.

Even though it tried again, still get 2 in return, then print instruction how to configure travis-ci.

Jenkins configuration is updated

from

if [ -f "travis_check.py" ]; then
  git log -n 1
  STATUS=$(curl -s $BUILD_URL | grep -e "GitHub pull request.*from.*" | sed 's/.*GitHub pull request <a href=\"\(https[^"]*\).*from[^"]*.\(https[^"]*\).*/\1 \2/g')
  AUTHOR=$(echo $STATUS | sed 's/.*[/]\(.*\)$/\1/g')
  PR=$(echo $STATUS | awk '{print $1}' | sed 's/.*[/]\(.*\)$/\1/g')
  COMMIT=$(git log -n 1 | grep "^Merge:" | awk '{print $3}')
  if [ -z $COMMIT ]; then
    COMMIT=$(curl -s https://api.github.com/repos/apache/zeppelin/pulls/$PR | grep -e "\"ref\":" -e "\"sha\":" | tr '\n' ' ' | sed 's/\(.*sha[^,]*,\)\(.*ref.*\)/\1 = \2/g' | tr = '\n' | grep -v master | sed 's/.*sha.[^"]*["]\([^"]*\).*/\1/g')
  fi
  sleep 30 # sleep few moment to wait travis starts the build
  python ./travis_check.py ${AUTHOR} ${COMMIT}
else
  echo "travis_check.py does not exists"
  echo "assume it's gh-pages branch"
  echo "return okay"
fi

to

if [ -f "travis_check.py" ]; then
  git log -n 1
  STATUS=$(curl -s $BUILD_URL | grep -e "GitHub pull request.*from.*" | sed 's/.*GitHub pull request <a href=\"\(https[^"]*\).*from[^"]*.\(https[^"]*\).*/\1 \2/g')
  AUTHOR=$(echo $STATUS | sed 's/.*[/]\(.*\)$/\1/g')
  PR=$(echo $STATUS | awk '{print $1}' | sed 's/.*[/]\(.*\)$/\1/g')
  COMMIT=$(git log -n 1 | grep "^Merge:" | awk '{print $3}')
  if [ -z $COMMIT ]; then
    COMMIT=$(curl -s https://api.github.com/repos/apache/zeppelin/pulls/$PR | grep -e "\"ref\":" -e "\"sha\":" | tr '\n' ' ' | sed 's/\(.*sha[^,]*,\)\(.*ref.*\)/\1 = \2/g' | tr = '\n' | grep -v master | sed 's/.*sha.[^"]*["]\([^"]*\).*/\1/g')
  fi
  sleep 30 # sleep few moment to wait travis starts the build
  python ./travis_check.py ${AUTHOR} ${COMMIT}
  RET_CODE=$?
  if [ $RET_CODE -eq 2 ]; then # try with repository name when travis-ci is not available in the account
    AUTHOR=$(curl -s https://api.github.com/repos/apache/zeppelin/pulls/$PR | grep '"full_name":' | grep -v "apache/zeppelin" | sed 's/.*[:][^"]*["]\([^/]*\).*/\1/g')
 	python ./travis_check.py ${AUTHOR} ${COMMIT}
    RET_CODE=$?
  fi
  
  if [ $RET_CODE -eq 2 ]; then # fail with can't find build information in the travis
    echo "Looks like travis-ci is not configured for your fork."
    echo "Please setup by swich on 'zeppelin' repository at https://travis-ci.org/profile and travis-ci."
    echo "And then make sure 'Build pushes' option is enabled in the settings https://travis-ci.org/${AUTHOR}/zeppelin/settings."
    echo "See http://zeppelin.apache.org/contribution/contributions.html#continuous-integration."
  fi
  
  exit $RET_CODE
else
  echo "travis_check.py does not exists"
  echo "assume it's gh-pages branch"
  echo "return okay"
fi

What type of PR is it?

Improvement

Todos

  • - distinguish error code travis_check.py
  • - Update jenkins configuration

What is the Jira issue?

https://issues.apache.org/jira/browse/ZEPPELIN-2162
https://issues.apache.org/jira/browse/ZEPPELIN-2142

Questions:

  • Does the licenses files need update? no
  • Is there breaking changes for older versions? no
  • Does this needs documentation? no

@Leemoonsoo
Copy link
Copy Markdown
Member Author

Merge to master and branch-0.7 if no more comments.

asfgit pushed a commit that referenced this pull request Mar 7, 2017
…nder organization, and show guidance if travis is not configured

### What is this PR for?

When contributor uses zeppelin fork under organization, Jenkins can't check it with current travis_check.py.

This PR updates travis_check.py to distinguish error 1 when it fails with build fail, error 2 when it can't find build.

When it fails with 2, jenkins configuration can retry travis_check.py with organization repo.

Even though it tried again, still get 2 in return, then print instruction how to configure travis-ci.

Jenkins configuration is updated

from
```bash
if [ -f "travis_check.py" ]; then
  git log -n 1
  STATUS=$(curl -s $BUILD_URL | grep -e "GitHub pull request.*from.*" | sed 's/.*GitHub pull request <a href=\"\(https[^"]*\).*from[^"]*.\(https[^"]*\).*/\1 \2/g')
  AUTHOR=$(echo $STATUS | sed 's/.*[/]\(.*\)$/\1/g')
  PR=$(echo $STATUS | awk '{print $1}' | sed 's/.*[/]\(.*\)$/\1/g')
  COMMIT=$(git log -n 1 | grep "^Merge:" | awk '{print $3}')
  if [ -z $COMMIT ]; then
    COMMIT=$(curl -s https://api.github.com/repos/apache/zeppelin/pulls/$PR | grep -e "\"ref\":" -e "\"sha\":" | tr '\n' ' ' | sed 's/\(.*sha[^,]*,\)\(.*ref.*\)/\1 = \2/g' | tr = '\n' | grep -v master | sed 's/.*sha.[^"]*["]\([^"]*\).*/\1/g')
  fi
  sleep 30 # sleep few moment to wait travis starts the build
  python ./travis_check.py ${AUTHOR} ${COMMIT}
else
  echo "travis_check.py does not exists"
  echo "assume it's gh-pages branch"
  echo "return okay"
fi
```

to
```bash
if [ -f "travis_check.py" ]; then
  git log -n 1
  STATUS=$(curl -s $BUILD_URL | grep -e "GitHub pull request.*from.*" | sed 's/.*GitHub pull request <a href=\"\(https[^"]*\).*from[^"]*.\(https[^"]*\).*/\1 \2/g')
  AUTHOR=$(echo $STATUS | sed 's/.*[/]\(.*\)$/\1/g')
  PR=$(echo $STATUS | awk '{print $1}' | sed 's/.*[/]\(.*\)$/\1/g')
  COMMIT=$(git log -n 1 | grep "^Merge:" | awk '{print $3}')
  if [ -z $COMMIT ]; then
    COMMIT=$(curl -s https://api.github.com/repos/apache/zeppelin/pulls/$PR | grep -e "\"ref\":" -e "\"sha\":" | tr '\n' ' ' | sed 's/\(.*sha[^,]*,\)\(.*ref.*\)/\1 = \2/g' | tr = '\n' | grep -v master | sed 's/.*sha.[^"]*["]\([^"]*\).*/\1/g')
  fi
  sleep 30 # sleep few moment to wait travis starts the build
  python ./travis_check.py ${AUTHOR} ${COMMIT}
  RET_CODE=$?
  if [ $RET_CODE -eq 2 ]; then # try with repository name when travis-ci is not available in the account
    AUTHOR=$(curl -s https://api.github.com/repos/apache/zeppelin/pulls/$PR | grep '"full_name":' | grep -v "apache/zeppelin" | sed 's/.*[:][^"]*["]\([^/]*\).*/\1/g')
 	python ./travis_check.py ${AUTHOR} ${COMMIT}
    RET_CODE=$?
  fi

  if [ $RET_CODE -eq 2 ]; then # fail with can't find build information in the travis
    echo "Looks like travis-ci is not configured for your fork."
    echo "Please setup by swich on 'zeppelin' repository at https://travis-ci.org/profile and travis-ci."
    echo "And then make sure 'Build pushes' option is enabled in the settings https://travis-ci.org/${AUTHOR}/zeppelin/settings."
    echo "See http://zeppelin.apache.org/contribution/contributions.html#continuous-integration."
  fi

  exit $RET_CODE
else
  echo "travis_check.py does not exists"
  echo "assume it's gh-pages branch"
  echo "return okay"
fi
```

### What type of PR is it?
Improvement

### Todos
* [x] - distinguish error code travis_check.py
* [x] - Update jenkins configuration

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-2162
https://issues.apache.org/jira/browse/ZEPPELIN-2142

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Lee moon soo <moon@apache.org>

Closes #2094 from Leemoonsoo/minor_update_travis_check and squashes the following commits:

5e3ade4 [Lee moon soo] use different error code when can't find build in travis, to distinguish with build fail

(cherry picked from commit 80e09eb)
Signed-off-by: Lee moon soo <moon@apache.org>
@asfgit asfgit closed this in 80e09eb Mar 7, 2017
prabhjyotsingh pushed a commit to prabhjyotsingh/zeppelin that referenced this pull request Mar 7, 2017
…nder organization, and show guidance if travis is not configured

### What is this PR for?

When contributor uses zeppelin fork under organization, Jenkins can't check it with current travis_check.py.

This PR updates travis_check.py to distinguish error 1 when it fails with build fail, error 2 when it can't find build.

When it fails with 2, jenkins configuration can retry travis_check.py with organization repo.

Even though it tried again, still get 2 in return, then print instruction how to configure travis-ci.

Jenkins configuration is updated

from
```bash
if [ -f "travis_check.py" ]; then
  git log -n 1
  STATUS=$(curl -s $BUILD_URL | grep -e "GitHub pull request.*from.*" | sed 's/.*GitHub pull request <a href=\"\(https[^"]*\).*from[^"]*.\(https[^"]*\).*/\1 \2/g')
  AUTHOR=$(echo $STATUS | sed 's/.*[/]\(.*\)$/\1/g')
  PR=$(echo $STATUS | awk '{print $1}' | sed 's/.*[/]\(.*\)$/\1/g')
  COMMIT=$(git log -n 1 | grep "^Merge:" | awk '{print $3}')
  if [ -z $COMMIT ]; then
    COMMIT=$(curl -s https://api.github.com/repos/apache/zeppelin/pulls/$PR | grep -e "\"ref\":" -e "\"sha\":" | tr '\n' ' ' | sed 's/\(.*sha[^,]*,\)\(.*ref.*\)/\1 = \2/g' | tr = '\n' | grep -v master | sed 's/.*sha.[^"]*["]\([^"]*\).*/\1/g')
  fi
  sleep 30 # sleep few moment to wait travis starts the build
  python ./travis_check.py ${AUTHOR} ${COMMIT}
else
  echo "travis_check.py does not exists"
  echo "assume it's gh-pages branch"
  echo "return okay"
fi
```

to
```bash
if [ -f "travis_check.py" ]; then
  git log -n 1
  STATUS=$(curl -s $BUILD_URL | grep -e "GitHub pull request.*from.*" | sed 's/.*GitHub pull request <a href=\"\(https[^"]*\).*from[^"]*.\(https[^"]*\).*/\1 \2/g')
  AUTHOR=$(echo $STATUS | sed 's/.*[/]\(.*\)$/\1/g')
  PR=$(echo $STATUS | awk '{print $1}' | sed 's/.*[/]\(.*\)$/\1/g')
  COMMIT=$(git log -n 1 | grep "^Merge:" | awk '{print $3}')
  if [ -z $COMMIT ]; then
    COMMIT=$(curl -s https://api.github.com/repos/apache/zeppelin/pulls/$PR | grep -e "\"ref\":" -e "\"sha\":" | tr '\n' ' ' | sed 's/\(.*sha[^,]*,\)\(.*ref.*\)/\1 = \2/g' | tr = '\n' | grep -v master | sed 's/.*sha.[^"]*["]\([^"]*\).*/\1/g')
  fi
  sleep 30 # sleep few moment to wait travis starts the build
  python ./travis_check.py ${AUTHOR} ${COMMIT}
  RET_CODE=$?
  if [ $RET_CODE -eq 2 ]; then # try with repository name when travis-ci is not available in the account
    AUTHOR=$(curl -s https://api.github.com/repos/apache/zeppelin/pulls/$PR | grep '"full_name":' | grep -v "apache/zeppelin" | sed 's/.*[:][^"]*["]\([^/]*\).*/\1/g')
 	python ./travis_check.py ${AUTHOR} ${COMMIT}
    RET_CODE=$?
  fi

  if [ $RET_CODE -eq 2 ]; then # fail with can't find build information in the travis
    echo "Looks like travis-ci is not configured for your fork."
    echo "Please setup by swich on 'zeppelin' repository at https://travis-ci.org/profile and travis-ci."
    echo "And then make sure 'Build pushes' option is enabled in the settings https://travis-ci.org/${AUTHOR}/zeppelin/settings."
    echo "See http://zeppelin.apache.org/contribution/contributions.html#continuous-integration."
  fi

  exit $RET_CODE
else
  echo "travis_check.py does not exists"
  echo "assume it's gh-pages branch"
  echo "return okay"
fi
```

### What type of PR is it?
Improvement

### Todos
* [x] - distinguish error code travis_check.py
* [x] - Update jenkins configuration

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-2162
https://issues.apache.org/jira/browse/ZEPPELIN-2142

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Lee moon soo <moon@apache.org>

Closes apache#2094 from Leemoonsoo/minor_update_travis_check and squashes the following commits:

5e3ade4 [Lee moon soo] use different error code when can't find build in travis, to distinguish with build fail

(cherry picked from commit 80e09eb)
Signed-off-by: Lee moon soo <moon@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants