From b122272d680bff5efd4f4b225bd6dfd7b955a4b6 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Fri, 8 Jul 2016 01:23:47 -0700 Subject: Add option to show preview URL for the PR in the GitHub comment (#42) Refs https://github.com/twbs/bootstrap/pull/20179 --- README.md | 4 ++++ src/main/resources/application.conf | 1 + .../scala/com/getbootstrap/savage/server/PullRequestCommenter.scala | 2 ++ src/main/scala/com/getbootstrap/savage/server/Settings.scala | 1 + 4 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 7fd81d4..dfb5181 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,10 @@ savage { // pushing the branch to GitHub, Savage will assume something went wrong and delete the branch to // keep the test repo's branches tidy. travis-timeout = 2 hours + // Include a link to the "preview URL" of the PR in the GitHub comment? + // Probably only makes sense if you're Bootstrap. + // Otherwise, you'll need to edit the hardcoded URL template string. + show-preview-urls = false // Full name of GitHub repo to watch for new pull requests github-repo-to-watch = "twbs/bootstrap" // Full name of GitHub repo to push test branches to diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index f2782b3..d6b2f1a 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -26,6 +26,7 @@ savage { squelch-invalid-http-logging = true set-commit-status = true travis-timeout = 2 hours + show-preview-urls = true github-repo-to-watch = "twbs/bootstrap" github-test-repo = "twbs-savage/bootstrap" allowed-base-branches = [ "master", "v4-dev", "v3-dev" ] diff --git a/src/main/scala/com/getbootstrap/savage/server/PullRequestCommenter.scala b/src/main/scala/com/getbootstrap/savage/server/PullRequestCommenter.scala index b31e08f..1701d90 100644 --- a/src/main/scala/com/getbootstrap/savage/server/PullRequestCommenter.scala +++ b/src/main/scala/com/getbootstrap/savage/server/PullRequestCommenter.scala @@ -15,12 +15,14 @@ class PullRequestCommenter extends GitHubActorWithLogging { case PullRequestBuildResult(prNum, commitSha, buildUrl, succeeded) => { val mythicalStatus = if (succeeded) { "**CONFIRMED**" } else { "**BUSTED**" } val plainStatus = if (succeeded) { "**Tests passed.**" } else { "**Tests failed.**" } + val previewInfo = if (settings.ShowPreviewUrls) { "Docs preview: http://preview.twbsapps.com/c/${commitSha.sha}" } else { "" } val commentMarkdown = s""" |${plainStatus} Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: ${mythicalStatus} | |Commit: ${commitSha.sha} |Build details: ${buildUrl} + |${previewInfo} | |(*Please note that this is a [fully automated](https://github.com/twbs/savage) comment.*) """.stripMargin diff --git a/src/main/scala/com/getbootstrap/savage/server/Settings.scala b/src/main/scala/com/getbootstrap/savage/server/Settings.scala index 5a2041a..2a31f49 100644 --- a/src/main/scala/com/getbootstrap/savage/server/Settings.scala +++ b/src/main/scala/com/getbootstrap/savage/server/Settings.scala @@ -30,6 +30,7 @@ class SettingsImpl(config: Config) extends Extension { val TrustedOrganizations: Set[String] = config.getStringList("savage.trusted-orgs").asScala.toSet val SetCommitStatus: Boolean = config.getBoolean("savage.set-commit-status") val TravisTimeout: FiniteDuration = config.getFiniteDuration("savage.travis-timeout") + val ShowPreviewUrls: Boolean = config.getBoolean("savage.show-preview-urls") } object Settings extends ExtensionId[SettingsImpl] with ExtensionIdProvider { override def lookup() = Settings -- cgit v1.2.3