From dcbe441b77dc73c34c8fc399b37a9e28bd761f1b Mon Sep 17 00:00:00 2001 From: cpsievert Date: Sat, 25 Apr 2015 15:31:51 -0500 Subject: [PATCH 01/29] First stab at automated comments --- .../testscripts/.push_test_table.sh | 6 ++++++ inst/testscripts/comment.R | 12 ++++++++++++ 2 files changed, 18 insertions(+) rename .push_test_table.sh => inst/testscripts/.push_test_table.sh (94%) create mode 100644 inst/testscripts/comment.R diff --git a/.push_test_table.sh b/inst/testscripts/.push_test_table.sh similarity index 94% rename from .push_test_table.sh rename to inst/testscripts/.push_test_table.sh index b3dd96a8bb..233d7d3f03 100644 --- a/.push_test_table.sh +++ b/inst/testscripts/.push_test_table.sh @@ -1,5 +1,8 @@ #!/bin/bash +# exit on error +set -e + # ----------------------------------------------------------------------- # When pushing to a pull request on GitHub, Travis does two builds: # (1) One for the pull request itself. In this case, $TRAVIS_PULL_REQUEST @@ -49,3 +52,6 @@ GH_REPO="@github.com/ropensci/plotly-test-table.git" FULL_REPO="https://${GH_TOKEN}${GH_REPO}" git pull $FULL_REPO gh-pages git push $FULL_REPO gh-pages + +# post some comments on the pull request +Rscript comment.R ${TRAVIS_PULL_REQUEST} ${TRAVIS_COMMIT} diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R new file mode 100644 index 0000000000..e9379debe7 --- /dev/null +++ b/inst/testscripts/comment.R @@ -0,0 +1,12 @@ +# first argument should be the pull request number +# second should be SHA-1 from the relevant commit +a <- commandArgs(TRUE) +# post a comment on the pull request with link to new test table +# https://developer.github.com/v3/pulls/comments/#create-a-comment +# note that gistr is a good reference for talking to the github API via httr +# https://github.com/ropensci/gistr/blob/master/R/zzz.R +url <- sprintf('https://api.github.com/repos/ropensci/plotly/pulls/%s/comments', a[1]) +home <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[2]) +header <- add_headers(`User-Agent` = "plotly", `Accept` = 'application/vnd.github.v3+json') +msg <- sprintf("New test table created at \n '%s'", new_test) +httr::POST(url = url, header, body = list(body = msg), encode = "json") From 102ed00f4f1d82c54bc2641269ab3a052975b301 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Sat, 25 Apr 2015 15:39:14 -0500 Subject: [PATCH 02/29] moved location of test scripts --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f79a945730..afe1413a1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,10 @@ r_packages: - httr before_script: - - chmod 755 ./.push_test_table.sh + - chmod 755 inst/testscripts/.push_test_table.sh after_success: - - ./.push_test_table.sh + - inst/testscripts/.push_test_table.sh notifications: slack: From 28073b30e7aeb1eb81b91c6691f998f2fe2ee46a Mon Sep 17 00:00:00 2001 From: cpsievert Date: Sat, 25 Apr 2015 17:06:41 -0500 Subject: [PATCH 03/29] fun with paths --- inst/testscripts/.push_test_table.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inst/testscripts/.push_test_table.sh b/inst/testscripts/.push_test_table.sh index 233d7d3f03..14fe628b52 100644 --- a/inst/testscripts/.push_test_table.sh +++ b/inst/testscripts/.push_test_table.sh @@ -53,5 +53,6 @@ FULL_REPO="https://${GH_TOKEN}${GH_REPO}" git pull $FULL_REPO gh-pages git push $FULL_REPO gh-pages + # post some comments on the pull request -Rscript comment.R ${TRAVIS_PULL_REQUEST} ${TRAVIS_COMMIT} +Rscript ../plotly/inst/testscripts/comment.R ${TRAVIS_PULL_REQUEST} ${TRAVIS_COMMIT} From 2fa7d76985443179b84d0d6dc522a84f1e53dd26 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Sat, 25 Apr 2015 17:31:52 -0500 Subject: [PATCH 04/29] bug fix --- inst/testscripts/comment.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index e9379debe7..ea7c83b90c 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -6,7 +6,7 @@ a <- commandArgs(TRUE) # note that gistr is a good reference for talking to the github API via httr # https://github.com/ropensci/gistr/blob/master/R/zzz.R url <- sprintf('https://api.github.com/repos/ropensci/plotly/pulls/%s/comments', a[1]) -home <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[2]) -header <- add_headers(`User-Agent` = "plotly", `Accept` = 'application/vnd.github.v3+json') -msg <- sprintf("New test table created at \n '%s'", new_test) +tables <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[2]) +header <- httr::add_headers(`User-Agent` = "plotly", `Accept` = 'application/vnd.github.v3+json') +msg <- sprintf("New test table created at \n '%s'", tables) httr::POST(url = url, header, body = list(body = msg), encode = "json") From 071a455262c680b709d3dbe97dd7574c7db700cc Mon Sep 17 00:00:00 2001 From: cpsievert Date: Sat, 25 Apr 2015 18:37:33 -0500 Subject: [PATCH 05/29] Can only access pull ID from Travis env var on pull request --- inst/testscripts/.push_test_table.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inst/testscripts/.push_test_table.sh b/inst/testscripts/.push_test_table.sh index 14fe628b52..eee8cbc86d 100644 --- a/inst/testscripts/.push_test_table.sh +++ b/inst/testscripts/.push_test_table.sh @@ -15,7 +15,11 @@ set -e # ----------------------------------------------------------------------- # Only build test table if $TRAVIS_PULL_REQUEST is false -[ "${TRAVIS_PULL_REQUEST}" != "false" ] && exit 0 +if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then + # post some comments on the pull request + Rscript ../plotly/inst/testscripts/comment.R ${TRAVIS_PULL_REQUEST} ${TRAVIS_COMMIT} + exit 0 +fi git config --global user.name "cpsievert" git config --global user.email "cpsievert1@gmail.com" @@ -52,7 +56,3 @@ GH_REPO="@github.com/ropensci/plotly-test-table.git" FULL_REPO="https://${GH_TOKEN}${GH_REPO}" git pull $FULL_REPO gh-pages git push $FULL_REPO gh-pages - - -# post some comments on the pull request -Rscript ../plotly/inst/testscripts/comment.R ${TRAVIS_PULL_REQUEST} ${TRAVIS_COMMIT} From 048df203dbbb4bd446eb61a769dc7595299bac0a Mon Sep 17 00:00:00 2001 From: cpsievert Date: Sat, 25 Apr 2015 19:05:36 -0500 Subject: [PATCH 06/29] Try issues, not pulls --- inst/testscripts/comment.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index ea7c83b90c..7ca60db2e7 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -5,7 +5,7 @@ a <- commandArgs(TRUE) # https://developer.github.com/v3/pulls/comments/#create-a-comment # note that gistr is a good reference for talking to the github API via httr # https://github.com/ropensci/gistr/blob/master/R/zzz.R -url <- sprintf('https://api.github.com/repos/ropensci/plotly/pulls/%s/comments', a[1]) +url <- sprintf('https://api.github.com/repos/ropensci/plotly/issues/%s/comments', a[1]) tables <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[2]) header <- httr::add_headers(`User-Agent` = "plotly", `Accept` = 'application/vnd.github.v3+json') msg <- sprintf("New test table created at \n '%s'", tables) From a21506fa05b6c2f132bfda6c748f63b556ae4291 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Sat, 25 Apr 2015 20:37:22 -0500 Subject: [PATCH 07/29] Pass GH_TOKEN to POST Authentication header --- inst/testscripts/.push_test_table.sh | 2 +- inst/testscripts/comment.R | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/inst/testscripts/.push_test_table.sh b/inst/testscripts/.push_test_table.sh index eee8cbc86d..91c2690dbb 100644 --- a/inst/testscripts/.push_test_table.sh +++ b/inst/testscripts/.push_test_table.sh @@ -17,7 +17,7 @@ set -e # Only build test table if $TRAVIS_PULL_REQUEST is false if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then # post some comments on the pull request - Rscript ../plotly/inst/testscripts/comment.R ${TRAVIS_PULL_REQUEST} ${TRAVIS_COMMIT} + Rscript ../plotly/inst/testscripts/comment.R $TRAVIS_PULL_REQUEST $TRAVIS_COMMIT $GH_TOKEN exit 0 fi diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 7ca60db2e7..37e6273c35 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -1,5 +1,6 @@ # first argument should be the pull request number # second should be SHA-1 from the relevant commit +# third should be the authentication token a <- commandArgs(TRUE) # post a comment on the pull request with link to new test table # https://developer.github.com/v3/pulls/comments/#create-a-comment @@ -7,6 +8,8 @@ a <- commandArgs(TRUE) # https://github.com/ropensci/gistr/blob/master/R/zzz.R url <- sprintf('https://api.github.com/repos/ropensci/plotly/issues/%s/comments', a[1]) tables <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[2]) -header <- httr::add_headers(`User-Agent` = "plotly", `Accept` = 'application/vnd.github.v3+json') +header <- httr::add_headers(`User-Agent` = "plotly", + `Accept` = 'application/vnd.github.v3+json', + `Authorization` = paste0("token ", a[3])) msg <- sprintf("New test table created at \n '%s'", tables) httr::POST(url = url, header, body = list(body = msg), encode = "json") From 9df06f5d63f1c685763b70d02f3aa6edccce6f1f Mon Sep 17 00:00:00 2001 From: cpsievert Date: Sat, 25 Apr 2015 21:19:46 -0500 Subject: [PATCH 08/29] Pass string straight to body argument --- inst/testscripts/comment.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 37e6273c35..3a3e3f9463 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -12,4 +12,4 @@ header <- httr::add_headers(`User-Agent` = "plotly", `Accept` = 'application/vnd.github.v3+json', `Authorization` = paste0("token ", a[3])) msg <- sprintf("New test table created at \n '%s'", tables) -httr::POST(url = url, header, body = list(body = msg), encode = "json") +httr::POST(url = url, header, body = msg, encode = "json") From 7dcf6b9a0de2689c14d5a88cffc2b32d96b2953a Mon Sep 17 00:00:00 2001 From: cpsievert Date: Sat, 25 Apr 2015 21:42:54 -0500 Subject: [PATCH 09/29] try toJSON --- inst/testscripts/comment.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 3a3e3f9463..eb91dc7b43 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -11,5 +11,6 @@ tables <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.h header <- httr::add_headers(`User-Agent` = "plotly", `Accept` = 'application/vnd.github.v3+json', `Authorization` = paste0("token ", a[3])) -msg <- sprintf("New test table created at \n '%s'", tables) -httr::POST(url = url, header, body = msg, encode = "json") +msg <- sprintf("New test table created at %s", tables) +json <- jsonlite::toJSON(list(body = msg), auto_unbox = TRUE) +httr::POST(url = url, header, body = json, encode = "json") From 0e3d5ca144d27d8416318824c1b6ec1421a51045 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 11:13:16 -0500 Subject: [PATCH 10/29] experimenting --- .travis.yml | 1 + inst/testscripts/comment.R | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index afe1413a1a..c79dbdedcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ r_packages: - httr before_script: + - git log - chmod 755 inst/testscripts/.push_test_table.sh after_success: diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index eb91dc7b43..20f2e56016 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -6,11 +6,20 @@ a <- commandArgs(TRUE) # https://developer.github.com/v3/pulls/comments/#create-a-comment # note that gistr is a good reference for talking to the github API via httr # https://github.com/ropensci/gistr/blob/master/R/zzz.R +library("httr") url <- sprintf('https://api.github.com/repos/ropensci/plotly/issues/%s/comments', a[1]) -tables <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[2]) -header <- httr::add_headers(`User-Agent` = "plotly", - `Accept` = 'application/vnd.github.v3+json', - `Authorization` = paste0("token ", a[3])) -msg <- sprintf("New test table created at %s", tables) -json <- jsonlite::toJSON(list(body = msg), auto_unbox = TRUE) -httr::POST(url = url, header, body = json, encode = "json") +tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[2]) +header <- add_headers(`User-Agent` = "plotly", + `Accept` = 'application/vnd.github.v3+json', + `Authorization` = paste0("token ", a[3])) +res <- content(GET(url = url, header)) +old_body <- unlist(lapply(res, "[[", "body")) +# post comment if a link to this SHA doesn't exist +# (needed since Travis randomly re-builds stuff) +if (!any(grepl(tbl_link, old_body))) { + msg <- sprintf("New test table created at %s", tbl_link) + json <- jsonlite::toJSON(list(body = msg), auto_unbox = TRUE) + httr::POST(url = url, header, body = json, encode = "json") +} else { + message("Link already posted") +} From 2ccefd16b98a034ce40b8f54587b7e36b24f962f Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 12:58:40 -0500 Subject: [PATCH 11/29] Rely on GitHub API rather than git for test table info --- inst/testscripts/.push_test_table.sh | 21 ++----------- inst/testscripts/comment.R | 44 +++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/inst/testscripts/.push_test_table.sh b/inst/testscripts/.push_test_table.sh index 91c2690dbb..5cae54d26f 100644 --- a/inst/testscripts/.push_test_table.sh +++ b/inst/testscripts/.push_test_table.sh @@ -14,12 +14,8 @@ set -e # http://docs.travis-ci.com/user/ci-environment/ # ----------------------------------------------------------------------- -# Only build test table if $TRAVIS_PULL_REQUEST is false -if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then - # post some comments on the pull request - Rscript ../plotly/inst/testscripts/comment.R $TRAVIS_PULL_REQUEST $TRAVIS_COMMIT $GH_TOKEN - exit 0 -fi +# We need the pull request number to talk to the GitHub API, make comments, etc. +[ "${TRAVIS_PULL_REQUEST}" = "false" ] && exit 0 git config --global user.name "cpsievert" git config --global user.email "cpsievert1@gmail.com" @@ -31,22 +27,11 @@ git config --global user.email "cpsievert1@gmail.com" cd .. rm -rf plotly/ git clone https://github.com/ropensci/plotly.git -cd plotly -echo "user,SHA1,label" >> ../code_commits.csv -echo "ropensci,`git rev-parse HEAD`,master" >> ../code_commits.csv -git checkout $TRAVIS_BRANCH -echo "ropensci,`git rev-parse HEAD`,${TRAVIS_BRANCH}" >> ../code_commits.csv -Rscript -e "devtools::install()" - -cd .. git clone https://github.com/ropensci/plotly-test-table.git cd plotly-test-table git checkout gh-pages -mv ../code_commits.csv . -cat code_commits.csv -touch table.R -make +Rscript inst/testscripts/comment.R $TRAVIS_PULL_REQUEST $GH_TOKEN # add, commit, push to gh-pages branch of plotly-test-table ./git-add.sh diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 20f2e56016..12f5cc5264 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -1,21 +1,49 @@ # first argument should be the pull request number -# second should be SHA-1 from the relevant commit # third should be the authentication token a <- commandArgs(TRUE) -# post a comment on the pull request with link to new test table -# https://developer.github.com/v3/pulls/comments/#create-a-comment -# note that gistr is a good reference for talking to the github API via httr +# gistr is a good reference for talking to the github API via httr # https://github.com/ropensci/gistr/blob/master/R/zzz.R library("httr") -url <- sprintf('https://api.github.com/repos/ropensci/plotly/issues/%s/comments', a[1]) -tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[2]) +base <- 'https://api.github.com/repos/ropensci/plotly/' +pr <- sprintf(file.path(base, 'pulls/%s/'), a[1]) +comments <- sprintf(file.path(base, 'issues/%s/comments'), a[1]) header <- add_headers(`User-Agent` = "plotly", `Accept` = 'application/vnd.github.v3+json', `Authorization` = paste0("token ", a[3])) -res <- content(GET(url = url, header)) -old_body <- unlist(lapply(res, "[[", "body")) +# Must be successful since we grab the branch name for this pull request +# and SHA1 info from the request content +res <- GET(url = pr, header) +stop_for_status(res) +info <- content(res) +# find the branch name for this pull request +# http://stackoverflow.com/questions/15096331/github-api-how-to-find-the-branches-of-a-pull-request +branch <- strsplit(info$head$label, ":")[[1]][2] + +# plotly-test-table build script assumes we've checkout the dev branch +setwd("../plotly") +if (system(paste("git checkout", branch)) != 0L) + stop(paste("Failed to 'git checkout'", branch, "branch")) +setwd("../plotly-test-table") +cat("user,SHA1,label", file = "code_commits.csv") +row1 <- paste0("\nropensci,", info$base$sha, ",master") +cat(row1, file = "code_commits.csv", append = TRUE) +row2 <- paste0("\nropensci,", info$head$sha, ",", branch) +cat(row2, file = "code_commits.csv", append = TRUE) + +# copy over file (created during Rscript) +# with sha/branch info for building test table +system("touch table.R") +if (system("make") != 0L) + stop("Failed to 'make' test table") + # post comment if a link to this SHA doesn't exist # (needed since Travis randomly re-builds stuff) +tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", + info$head$sha) +res <- GET(url = comments, header) +warn_for_status(res) +info <- content(res) +old_body <- unlist(lapply(info, "[", "body")) if (!any(grepl(tbl_link, old_body))) { msg <- sprintf("New test table created at %s", tbl_link) json <- jsonlite::toJSON(list(body = msg), auto_unbox = TRUE) From 7e4a041a68583ebace767c7e51daf070ea6a3833 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 13:21:47 -0500 Subject: [PATCH 12/29] no git log --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c79dbdedcd..afe1413a1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ r_packages: - httr before_script: - - git log - chmod 755 inst/testscripts/.push_test_table.sh after_success: From f894b13169ba262b2509eae4d77ccbd465d21e06 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 13:53:55 -0500 Subject: [PATCH 13/29] Move more shell code to R for consistency --- inst/testscripts/.push_test_table.sh | 11 +---------- inst/testscripts/comment.R | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/inst/testscripts/.push_test_table.sh b/inst/testscripts/.push_test_table.sh index 5cae54d26f..d43f98d626 100644 --- a/inst/testscripts/.push_test_table.sh +++ b/inst/testscripts/.push_test_table.sh @@ -31,13 +31,4 @@ git clone https://github.com/ropensci/plotly-test-table.git cd plotly-test-table git checkout gh-pages -Rscript inst/testscripts/comment.R $TRAVIS_PULL_REQUEST $GH_TOKEN - -# add, commit, push to gh-pages branch of plotly-test-table -./git-add.sh -git commit -a -m "Travis build number ${TRAVIS_BUILD_NUMBER} of ${TRAVIS_REPO_SLUG}" -# This post explains how this works -- http://rmflight.github.io/posts/2014/11/travis_ci_gh_pages.html -GH_REPO="@github.com/ropensci/plotly-test-table.git" -FULL_REPO="https://${GH_TOKEN}${GH_REPO}" -git pull $FULL_REPO gh-pages -git push $FULL_REPO gh-pages +Rscript ../plotly/inst/testscripts/comment.R $TRAVIS_PULL_REQUEST $TRAVIS_BUILD_ID $GH_TOKEN diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 12f5cc5264..885604ffd4 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -1,5 +1,6 @@ -# first argument should be the pull request number -# third should be the authentication token +# first argument should be the pull request number (TRAVIS_PULL_REQUEST) +# second should be the travis build ID (TRAVIS_BUILD_ID) +# third should be the github authentication token a <- commandArgs(TRUE) # gistr is a good reference for talking to the github API via httr # https://github.com/ropensci/gistr/blob/master/R/zzz.R @@ -36,6 +37,16 @@ system("touch table.R") if (system("make") != 0L) stop("Failed to 'make' test table") + +# add, commit, push to gh-pages branch of plotly-test-table +system("./git-add.sh") +commit_msg <- paste0("Pushed from https://travis-ci.org/ropensci/plotly/builds/", a[2]) +system(paste('git commit -a -m', commit_msg)) +# This post explains how this works -- http://rmflight.github.io/posts/2014/11/travis_ci_gh_pages.html +repo <- paste0("https://", a[3], "@github.com/ropensci/plotly-test-table.git") +system(paste("git pull", repo, "gh-pages")) +system(paste("git push", repo, "gh-pages")) + # post comment if a link to this SHA doesn't exist # (needed since Travis randomly re-builds stuff) tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", From d8bd763d7e4678424d3bc37a05b791d0e621d117 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 15:11:37 -0500 Subject: [PATCH 14/29] Avoid re-clone of plotly; dev branch column will now reflect result *after* merging with master --- inst/testscripts/.push_test_table.sh | 25 ++++++++++--------------- inst/testscripts/comment.R | 12 ++++++++---- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/inst/testscripts/.push_test_table.sh b/inst/testscripts/.push_test_table.sh index d43f98d626..69625c918d 100644 --- a/inst/testscripts/.push_test_table.sh +++ b/inst/testscripts/.push_test_table.sh @@ -4,31 +4,26 @@ set -e # ----------------------------------------------------------------------- -# When pushing to a pull request on GitHub, Travis does two builds: -# (1) One for the pull request itself. In this case, $TRAVIS_PULL_REQUEST -# is 'false' and $TRAVIS_BRANCH contains the branch name -# (2) One to *simulate* a merge with master. In this case, $TRAVIS_PULL_REQUEST -# is the pull ID number and $TRAVIS_BRANCH = 'master' -# -# Read more about Travis environment variables -- -# http://docs.travis-ci.com/user/ci-environment/ +# Travis does two types of builds: +# +# (1) A so-called "push". This essentially does a checkout on the most +# recent commit of the pull request, but *doesn't* merge with master. +# In this case, $TRAVIS_PULL_REQUEST = "false" +# (2) A so-called "pr" (pull request). This *does* merge with master. +# In this case, $TRAVIS_PULL_REQUEST contains the pull request number. # ----------------------------------------------------------------------- -# We need the pull request number to talk to the GitHub API, make comments, etc. +# We need the pull request number to talk to the GitHub API, make comments, etc. [ "${TRAVIS_PULL_REQUEST}" = "false" ] && exit 0 git config --global user.name "cpsievert" git config --global user.email "cpsievert1@gmail.com" -# Since Travis does `git clone --branch=$TRAVIS_BRANCH --depth=50`, -# we can't simply `git checkout master`. As far as I can tell, we are -# forced to re-clone -- https://gist.github.com/cpsievert/698c7f1404f972782e71 - cd .. -rm -rf plotly/ -git clone https://github.com/ropensci/plotly.git git clone https://github.com/ropensci/plotly-test-table.git cd plotly-test-table git checkout gh-pages +# Read more about Travis environment variables -- +# http://docs.travis-ci.com/user/ci-environment/ Rscript ../plotly/inst/testscripts/comment.R $TRAVIS_PULL_REQUEST $TRAVIS_BUILD_ID $GH_TOKEN diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 885604ffd4..e246422da2 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -20,10 +20,15 @@ info <- content(res) # http://stackoverflow.com/questions/15096331/github-api-how-to-find-the-branches-of-a-pull-request branch <- strsplit(info$head$label, ":")[[1]][2] -# plotly-test-table build script assumes we've checkout the dev branch +# plotly-test-table build script assumes we've checkout the dev branch. +# Note that travis does something like this for "pr" build: +#$ git fetch origin +refs/pull/number/merge: +#$ git checkout -qf FETCH_HEAD +# this leaves HEAD in a detached state, but we should be able to do: +# git checkout -b new_branch_name setwd("../plotly") -if (system(paste("git checkout", branch)) != 0L) - stop(paste("Failed to 'git checkout'", branch, "branch")) +if (system(paste("git checkout -b", branch)) != 0L) + stop(paste("Failed to 'git checkout -b'", branch, "branch")) setwd("../plotly-test-table") cat("user,SHA1,label", file = "code_commits.csv") row1 <- paste0("\nropensci,", info$base$sha, ",master") @@ -37,7 +42,6 @@ system("touch table.R") if (system("make") != 0L) stop("Failed to 'make' test table") - # add, commit, push to gh-pages branch of plotly-test-table system("./git-add.sh") commit_msg <- paste0("Pushed from https://travis-ci.org/ropensci/plotly/builds/", a[2]) From 53e91d3b600871b50e946ae5bad63b5b73606863 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 15:36:15 -0500 Subject: [PATCH 15/29] Ugh. 404 is back --- inst/testscripts/comment.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index e246422da2..3a2c188a4e 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -13,6 +13,7 @@ header <- add_headers(`User-Agent` = "plotly", `Authorization` = paste0("token ", a[3])) # Must be successful since we grab the branch name for this pull request # and SHA1 info from the request content +message(pr) res <- GET(url = pr, header) stop_for_status(res) info <- content(res) @@ -39,8 +40,7 @@ cat(row2, file = "code_commits.csv", append = TRUE) # copy over file (created during Rscript) # with sha/branch info for building test table system("touch table.R") -if (system("make") != 0L) - stop("Failed to 'make' test table") +if (system("make") != 0L) stop("Failed to 'make' test table") # add, commit, push to gh-pages branch of plotly-test-table system("./git-add.sh") From 88dc4594934c643ffc921ebcbd5dbaf4d560d54b Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 16:27:21 -0500 Subject: [PATCH 16/29] Fix url link --- inst/testscripts/comment.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 3a2c188a4e..8efc530e87 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -6,8 +6,8 @@ a <- commandArgs(TRUE) # https://github.com/ropensci/gistr/blob/master/R/zzz.R library("httr") base <- 'https://api.github.com/repos/ropensci/plotly/' -pr <- sprintf(file.path(base, 'pulls/%s/'), a[1]) -comments <- sprintf(file.path(base, 'issues/%s/comments'), a[1]) +pr <- sprintf(paste0(base, 'pulls/%s'), a[1]) +comments <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) header <- add_headers(`User-Agent` = "plotly", `Accept` = 'application/vnd.github.v3+json', `Authorization` = paste0("token ", a[3])) From 3e0991b6dd36e9e1cb8dcdc22a51d121b1abb0d2 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 17:26:55 -0500 Subject: [PATCH 17/29] Gotta install plotly before making test table --- inst/testscripts/comment.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 8efc530e87..b8454fa3c6 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -13,7 +13,6 @@ header <- add_headers(`User-Agent` = "plotly", `Authorization` = paste0("token ", a[3])) # Must be successful since we grab the branch name for this pull request # and SHA1 info from the request content -message(pr) res <- GET(url = pr, header) stop_for_status(res) info <- content(res) @@ -30,6 +29,7 @@ branch <- strsplit(info$head$label, ":")[[1]][2] setwd("../plotly") if (system(paste("git checkout -b", branch)) != 0L) stop(paste("Failed to 'git checkout -b'", branch, "branch")) +devtools::install() setwd("../plotly-test-table") cat("user,SHA1,label", file = "code_commits.csv") row1 <- paste0("\nropensci,", info$base$sha, ",master") From 2c0b3c8c4fcd77d0d73f3fdede5ee5e411082e3c Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 18:33:19 -0500 Subject: [PATCH 18/29] almost there --- inst/testscripts/comment.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index b8454fa3c6..ed3ce9a733 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -43,9 +43,9 @@ system("touch table.R") if (system("make") != 0L) stop("Failed to 'make' test table") # add, commit, push to gh-pages branch of plotly-test-table -system("./git-add.sh") -commit_msg <- paste0("Pushed from https://travis-ci.org/ropensci/plotly/builds/", a[2]) -system(paste('git commit -a -m', commit_msg)) +system("git add tables/*/*.html data/*/*.png data/*/*.log") +commit_msg <- paste0('"Pushed from https://travis-ci.org/ropensci/plotly/builds/"', a[2]) +system(paste('git commit -m', commit_msg)) # This post explains how this works -- http://rmflight.github.io/posts/2014/11/travis_ci_gh_pages.html repo <- paste0("https://", a[3], "@github.com/ropensci/plotly-test-table.git") system(paste("git pull", repo, "gh-pages")) From 20dab8e0d33e2b8eadf118c18d9286911ef29c8d Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 19:00:00 -0500 Subject: [PATCH 19/29] git add only allows one file argument --- inst/testscripts/comment.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index ed3ce9a733..97b97cde9e 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -43,7 +43,9 @@ system("touch table.R") if (system("make") != 0L) stop("Failed to 'make' test table") # add, commit, push to gh-pages branch of plotly-test-table -system("git add tables/*/*.html data/*/*.png data/*/*.log") +system("git add tables/*/*.html") +system("git add data/*/*.png") +system("git add data/*/*.log") commit_msg <- paste0('"Pushed from https://travis-ci.org/ropensci/plotly/builds/"', a[2]) system(paste('git commit -m', commit_msg)) # This post explains how this works -- http://rmflight.github.io/posts/2014/11/travis_ci_gh_pages.html @@ -55,7 +57,7 @@ system(paste("git push", repo, "gh-pages")) # (needed since Travis randomly re-builds stuff) tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", info$head$sha) -res <- GET(url = comments, header) +res <- GET(comments, header) warn_for_status(res) info <- content(res) old_body <- unlist(lapply(info, "[", "body")) From 6d62f2eed388361088866fd276ecf4ee9809a344 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 20:19:41 -0500 Subject: [PATCH 20/29] debugging travis isn't fun --- inst/testscripts/comment.R | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 97b97cde9e..f931535571 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -7,7 +7,6 @@ a <- commandArgs(TRUE) library("httr") base <- 'https://api.github.com/repos/ropensci/plotly/' pr <- sprintf(paste0(base, 'pulls/%s'), a[1]) -comments <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) header <- add_headers(`User-Agent` = "plotly", `Accept` = 'application/vnd.github.v3+json', `Authorization` = paste0("token ", a[3])) @@ -50,14 +49,16 @@ commit_msg <- paste0('"Pushed from https://travis-ci.org/ropensci/plotly/builds/ system(paste('git commit -m', commit_msg)) # This post explains how this works -- http://rmflight.github.io/posts/2014/11/travis_ci_gh_pages.html repo <- paste0("https://", a[3], "@github.com/ropensci/plotly-test-table.git") -system(paste("git pull", repo, "gh-pages")) -system(paste("git push", repo, "gh-pages")) +system(paste("git pull -q", repo, "gh-pages")) +system(paste("git push -q", repo, "gh-pages")) # post comment if a link to this SHA doesn't exist # (needed since Travis randomly re-builds stuff) tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", info$head$sha) -res <- GET(comments, header) +commentz <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) +message(commentz) +res <- GET(commentz, header) warn_for_status(res) info <- content(res) old_body <- unlist(lapply(info, "[", "body")) From d60157c5a4c287781b7001a2f6a675353a7010c5 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 20:46:34 -0500 Subject: [PATCH 21/29] derp --- inst/testscripts/comment.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index f931535571..2984af1e29 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -57,7 +57,6 @@ system(paste("git push -q", repo, "gh-pages")) tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", info$head$sha) commentz <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) -message(commentz) res <- GET(commentz, header) warn_for_status(res) info <- content(res) @@ -65,7 +64,7 @@ old_body <- unlist(lapply(info, "[", "body")) if (!any(grepl(tbl_link, old_body))) { msg <- sprintf("New test table created at %s", tbl_link) json <- jsonlite::toJSON(list(body = msg), auto_unbox = TRUE) - httr::POST(url = url, header, body = json, encode = "json") + httr::POST(url = commentz, header, body = json, encode = "json") } else { message("Link already posted") } From 9a8c2e8b9a45743470455bbe593e7ddb3175a05f Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 21:28:34 -0500 Subject: [PATCH 22/29] replace head SHA from API with TRAVIS_COMMIT since we want representing of what we'll see after mergin with master --- inst/testscripts/.push_test_table.sh | 2 +- inst/testscripts/comment.R | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/inst/testscripts/.push_test_table.sh b/inst/testscripts/.push_test_table.sh index 69625c918d..b6ef2e1976 100644 --- a/inst/testscripts/.push_test_table.sh +++ b/inst/testscripts/.push_test_table.sh @@ -26,4 +26,4 @@ git checkout gh-pages # Read more about Travis environment variables -- # http://docs.travis-ci.com/user/ci-environment/ -Rscript ../plotly/inst/testscripts/comment.R $TRAVIS_PULL_REQUEST $TRAVIS_BUILD_ID $GH_TOKEN +Rscript ../plotly/inst/testscripts/comment.R $TRAVIS_PULL_REQUEST $TRAVIS_BUILD_ID $TRAVIS_COMMIT $GH_TOKEN diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 2984af1e29..efee41ad93 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -9,7 +9,7 @@ base <- 'https://api.github.com/repos/ropensci/plotly/' pr <- sprintf(paste0(base, 'pulls/%s'), a[1]) header <- add_headers(`User-Agent` = "plotly", `Accept` = 'application/vnd.github.v3+json', - `Authorization` = paste0("token ", a[3])) + `Authorization` = paste0("token ", a[4])) # Must be successful since we grab the branch name for this pull request # and SHA1 info from the request content res <- GET(url = pr, header) @@ -33,7 +33,7 @@ setwd("../plotly-test-table") cat("user,SHA1,label", file = "code_commits.csv") row1 <- paste0("\nropensci,", info$base$sha, ",master") cat(row1, file = "code_commits.csv", append = TRUE) -row2 <- paste0("\nropensci,", info$head$sha, ",", branch) +row2 <- paste0("\nropensci,", a[3], ",", branch) cat(row2, file = "code_commits.csv", append = TRUE) # copy over file (created during Rscript) @@ -48,14 +48,13 @@ system("git add data/*/*.log") commit_msg <- paste0('"Pushed from https://travis-ci.org/ropensci/plotly/builds/"', a[2]) system(paste('git commit -m', commit_msg)) # This post explains how this works -- http://rmflight.github.io/posts/2014/11/travis_ci_gh_pages.html -repo <- paste0("https://", a[3], "@github.com/ropensci/plotly-test-table.git") +repo <- sprintf("https://%s@github.com/ropensci/plotly-test-table.git", a[4]) system(paste("git pull -q", repo, "gh-pages")) system(paste("git push -q", repo, "gh-pages")) # post comment if a link to this SHA doesn't exist # (needed since Travis randomly re-builds stuff) -tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", - info$head$sha) +tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[3]) commentz <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) res <- GET(commentz, header) warn_for_status(res) From ab1967e94dd17947aae129146bb93ef7203c49ed Mon Sep 17 00:00:00 2001 From: cpsievert Date: Mon, 27 Apr 2015 22:08:37 -0500 Subject: [PATCH 23/29] More informative comment --- inst/testscripts/comment.R | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index efee41ad93..202e7d495a 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -1,6 +1,7 @@ -# first argument should be the pull request number (TRAVIS_PULL_REQUEST) -# second should be the travis build ID (TRAVIS_BUILD_ID) -# third should be the github authentication token +# first argument is the pull request number (TRAVIS_PULL_REQUEST) +# second is travis build ID (TRAVIS_BUILD_ID) +# third is the commit SHA1 currently being tested (TRAVIS_COMMIT) +# fourth is the github authentication token a <- commandArgs(TRUE) # gistr is a good reference for talking to the github API via httr # https://github.com/ropensci/gistr/blob/master/R/zzz.R @@ -42,6 +43,7 @@ system("touch table.R") if (system("make") != 0L) stop("Failed to 'make' test table") # add, commit, push to gh-pages branch of plotly-test-table +system("git add index.html") system("git add tables/*/*.html") system("git add data/*/*.png") system("git add data/*/*.log") @@ -55,13 +57,14 @@ system(paste("git push -q", repo, "gh-pages")) # post comment if a link to this SHA doesn't exist # (needed since Travis randomly re-builds stuff) tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[3]) +msg <- sprintf("Commit %s was successfully merged with %s (master) to create %s. A visual testing table comparing %s with %s \n %s", + info$head$sha, info$base$sha, a[3], info$base$sha, a[3], tbl_link) commentz <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) res <- GET(commentz, header) warn_for_status(res) info <- content(res) old_body <- unlist(lapply(info, "[", "body")) if (!any(grepl(tbl_link, old_body))) { - msg <- sprintf("New test table created at %s", tbl_link) json <- jsonlite::toJSON(list(body = msg), auto_unbox = TRUE) httr::POST(url = commentz, header, body = json, encode = "json") } else { From 38a8fb012729db1c5c0e8dc22f104ab1b511f935 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Tue, 28 Apr 2015 14:46:41 -0500 Subject: [PATCH 24/29] Make message more bot-like --- inst/testscripts/comment.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 202e7d495a..af1b32d913 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -57,8 +57,9 @@ system(paste("git push -q", repo, "gh-pages")) # post comment if a link to this SHA doesn't exist # (needed since Travis randomly re-builds stuff) tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[3]) -msg <- sprintf("Commit %s was successfully merged with %s (master) to create %s. A visual testing table comparing %s with %s \n %s", +msg <- sprintf("On TravisCI, commit %s was successfully merged with %s (master) to create %s. A visual testing table comparing %s with %s can be found here:\n %s", info$head$sha, info$base$sha, a[3], info$base$sha, a[3], tbl_link) +msg <- paste0("```---Automatically generated message---```", msg, "```---Automatically generated message---```") commentz <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) res <- GET(commentz, header) warn_for_status(res) From 581aa0454994aa0b6055a68fbdf92b3ec9d3596b Mon Sep 17 00:00:00 2001 From: cpsievert Date: Tue, 28 Apr 2015 16:16:47 -0500 Subject: [PATCH 25/29] Line breaks --- inst/testscripts/comment.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index af1b32d913..a56ccf48c9 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -59,7 +59,8 @@ system(paste("git push -q", repo, "gh-pages")) tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[3]) msg <- sprintf("On TravisCI, commit %s was successfully merged with %s (master) to create %s. A visual testing table comparing %s with %s can be found here:\n %s", info$head$sha, info$base$sha, a[3], info$base$sha, a[3], tbl_link) -msg <- paste0("```---Automatically generated message---```", msg, "```---Automatically generated message---```") +msg <- paste("```---Automatically generated message---```", msg, + "```---Automatically generated message---```", collapse = "\n") commentz <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) res <- GET(commentz, header) warn_for_status(res) From aa50cb00894dabfc5b9d6a056a2361527ed67637 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Tue, 28 Apr 2015 17:23:53 -0500 Subject: [PATCH 26/29] sep not collapse --- inst/testscripts/comment.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index a56ccf48c9..175f057ec5 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -60,7 +60,7 @@ tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index msg <- sprintf("On TravisCI, commit %s was successfully merged with %s (master) to create %s. A visual testing table comparing %s with %s can be found here:\n %s", info$head$sha, info$base$sha, a[3], info$base$sha, a[3], tbl_link) msg <- paste("```---Automatically generated message---```", msg, - "```---Automatically generated message---```", collapse = "\n") + "```---Automatically generated message---```", sep = "\n") commentz <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) res <- GET(commentz, header) warn_for_status(res) From 8011a964b65ba66b5e858d2791bcb84024fb52f7 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Tue, 28 Apr 2015 18:03:01 -0500 Subject: [PATCH 27/29] Use blockquote, not code blocks --- inst/testscripts/comment.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 175f057ec5..b8bf5ae2f8 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -59,8 +59,7 @@ system(paste("git push -q", repo, "gh-pages")) tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[3]) msg <- sprintf("On TravisCI, commit %s was successfully merged with %s (master) to create %s. A visual testing table comparing %s with %s can be found here:\n %s", info$head$sha, info$base$sha, a[3], info$base$sha, a[3], tbl_link) -msg <- paste("```---Automatically generated message---```", msg, - "```---Automatically generated message---```", sep = "\n") +msg <- paste("> The message below was automatically generated \n", msg) commentz <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) res <- GET(commentz, header) warn_for_status(res) From fec97433f0a08ef4ebe8cf3c983c83bf4b870dbf Mon Sep 17 00:00:00 2001 From: cpsievert Date: Tue, 28 Apr 2015 18:55:44 -0500 Subject: [PATCH 28/29] Ugh, need 2 line breaks --- inst/testscripts/comment.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index b8bf5ae2f8..696ce154d5 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -59,7 +59,7 @@ system(paste("git push -q", repo, "gh-pages")) tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[3]) msg <- sprintf("On TravisCI, commit %s was successfully merged with %s (master) to create %s. A visual testing table comparing %s with %s can be found here:\n %s", info$head$sha, info$base$sha, a[3], info$base$sha, a[3], tbl_link) -msg <- paste("> The message below was automatically generated \n", msg) +msg <- paste("> The message below was automatically generated \n\n", msg) commentz <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) res <- GET(commentz, header) warn_for_status(res) From f3b40a7f7844a4863780df5ffb0fe277204059a5 Mon Sep 17 00:00:00 2001 From: cpsievert Date: Tue, 28 Apr 2015 21:18:20 -0500 Subject: [PATCH 29/29] Add link to Travis build --- inst/testscripts/comment.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inst/testscripts/comment.R b/inst/testscripts/comment.R index 696ce154d5..31786439ec 100644 --- a/inst/testscripts/comment.R +++ b/inst/testscripts/comment.R @@ -47,7 +47,8 @@ system("git add index.html") system("git add tables/*/*.html") system("git add data/*/*.png") system("git add data/*/*.log") -commit_msg <- paste0('"Pushed from https://travis-ci.org/ropensci/plotly/builds/"', a[2]) +build_link <- paste0('https://travis-ci.org/ropensci/plotly/builds/', a[2]) +commit_msg <- paste0('"Pushed from ', build_link, '"') system(paste('git commit -m', commit_msg)) # This post explains how this works -- http://rmflight.github.io/posts/2014/11/travis_ci_gh_pages.html repo <- sprintf("https://%s@github.com/ropensci/plotly-test-table.git", a[4]) @@ -59,7 +60,7 @@ system(paste("git push -q", repo, "gh-pages")) tbl_link <- sprintf("http://ropensci.github.io/plotly-test-table/tables/%s/index.html", a[3]) msg <- sprintf("On TravisCI, commit %s was successfully merged with %s (master) to create %s. A visual testing table comparing %s with %s can be found here:\n %s", info$head$sha, info$base$sha, a[3], info$base$sha, a[3], tbl_link) -msg <- paste("> The message below was automatically generated \n\n", msg) +msg <- paste("> The message below was automatically generated after build", build_link, "\n\n", msg) commentz <- sprintf(paste0(base, 'issues/%s/comments'), a[1]) res <- GET(commentz, header) warn_for_status(res)