[ 
https://issues.apache.org/jira/browse/BEAM-5681?focusedWorklogId=153311&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-153311
 ]

ASF GitHub Bot logged work on BEAM-5681:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Oct/18 22:54
            Start Date: 10/Oct/18 22:54
    Worklog Time Spent: 10m 
      Work Description: swegner closed pull request #6608: [BEAM-5681] Fix 
website tasks when pull-request ID is specified
URL: https://github.com/apache/beam/pull/6608
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/website/_config.yml b/website/_config.yml
index 50826fa5341..d5827ba0b71 100644
--- a/website/_config.yml
+++ b/website/_config.yml
@@ -28,12 +28,8 @@ description: > # this means to ignore newlines until 
"baseurl:"
   (a cloud service). Beam also brings DSL in different languages, allowing
   users to easily implement their data integration processes.
 
-# the subpath of your site, e.g. /blog
-baseurl: ""
-
-# input and output directory
+# input directory
 source: src
-destination: generated-content
 
 # the base hostname & protocol for your site
 url: "https://beam.apache.org";
diff --git a/website/_config_test.yml b/website/_config_test.yml
new file mode 100644
index 00000000000..08bd1942cb4
--- /dev/null
+++ b/website/_config_test.yml
@@ -0,0 +1,21 @@
+# Licensed 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.
+# Welcome to Jekyll!
+
+# This config file specifies a set of config overrides necessary to stage
+# the website on GCS as part of the :beam-website:stageWebsite task. This is
+# run automatically on Jenkins for website pull requests to make it easy to
+# preview website changes during code review.
+
+# Clear our the URL so that links are relative rather
+# than pointing to apache.org
+url: ""
diff --git a/website/build.gradle b/website/build.gradle
index a0d8d955cb8..cba2799ed9e 100644
--- a/website/build.gradle
+++ b/website/build.gradle
@@ -25,8 +25,7 @@ apply plugin: 'org.ajoberstar.grgit'
 def dockerImageTag = 'beam-website'
 def dockerWorkDir = "/repo"
 def buildDir = "${project.rootDir}/build/website"
-def buildContentDir = "${project.rootDir}/build/website/generated-content"
-def repoContentDir = "${project.rootDir}/website/generated-content"
+
 def commitedChanges = false
 def gitboxUrl = project.findProperty('gitPublishRemote') ?: 
'https://gitbox.apache.org/repos/asf/beam.git'
 
@@ -35,7 +34,7 @@ def shell = { cmd ->
   exec {
     executable 'sh'
     args '-c', cmd
-  } 
+  }
 }
 
 
@@ -99,25 +98,49 @@ task cleanWebsite(type: Delete) {
 }
 clean.dependsOn cleanWebsite
 
-task buildWebsite(type: Exec) {
-  def baseurlFlag = project.findProperty('githubPullRequestId') ? 
"--baseurl=/${project.findProperty('githubPullRequestId')}" : ''
-  dependsOn startDockerContainer, setupBuildDir
-  finalizedBy stopAndRemoveDockerContainer
-  inputs.files 'Gemfile.lock', '_config.yml'
-  inputs.dir 'src'
-  inputs.property 'baseurl', baseurlFlag
-  outputs.dir "$buildDir/.sass-cache"
-  outputs.dir buildContentDir
-  commandLine 'docker', 'exec',
-    "${->startDockerContainer.containerId()}", '/bin/bash', '-c',
-    """cd $dockerWorkDir/build/website && \
-      bundle exec jekyll build \
-      --config $dockerWorkDir/website/_config.yml \
-      --incremental ${baseurlFlag} \
-      --source $dockerWorkDir/website/src
-      """
+class BuildTaskConfiguration {
+  String name
+  boolean useTestConfig = false
+  String baseUrl = ''
+  String dockerWorkDir = ''
+}
+def createBuildTask = {
+  BuildTaskConfiguration config = it as BuildTaskConfiguration
+  task "build${config.name}Website" (type:Exec) {
+    dependsOn startDockerContainer, setupBuildDir
+    finalizedBy stopAndRemoveDockerContainer
+    inputs.files 'Gemfile.lock', '_config.yml'
+    inputs.dir 'src'
+    outputs.dir "$buildDir/.sass-cache"
+    outputs.dir buildContentDir(config.name)
+    def configs = "${config.dockerWorkDir}/website/_config.yml"
+    if (config.useTestConfig) {
+      configs += ",${config.dockerWorkDir}/website/_config_test.yml"
+    }
+    def baseUrlFlag = config.baseUrl ? "--baseurl=/${config.baseUrl}" : ""
+    commandLine 'docker', 'exec',
+      "${->startDockerContainer.containerId()}", '/bin/bash', '-c',
+      """cd ${config.dockerWorkDir}/build/website && \
+        bundle exec jekyll build \
+       --destination generated-${config.name.toLowerCase()}-content \
+        --config ${configs} \
+        --incremental ${baseUrlFlag} \
+        --source ${config.dockerWorkDir}/website/src
+        """
+  }
 }
+createBuildTask(name:'Local', useTestConfig: true, dockerWorkDir: 
dockerWorkDir)
+task buildWebsite(dependsOn:buildLocalWebsite)
 build.dependsOn buildWebsite
+createBuildTask( name:'Gcs', useTestConfig: true, baseUrl: getBaseUrl(), 
dockerWorkDir: dockerWorkDir)
+createBuildTask( name:'Apache', dockerWorkDir: dockerWorkDir)
+
+def getBaseUrl() {
+  project.findProperty('githubPullRequestId') ?: 'latest'
+}
+def buildContentDir(name) {
+  "${project.rootDir}/build/website/generated-${name.toLowerCase()}-content"
+}
 
 task serveWebsite(type: Exec) {
   dependsOn startDockerContainer, setupBuildDir
@@ -125,7 +148,7 @@ task serveWebsite(type: Exec) {
   inputs.files 'Gemfile.lock', '_config.yml'
   inputs.dir 'src'
   outputs.dir "$buildDir/.sass-cache"
-  outputs.dir buildContentDir
+  outputs.dir buildContentDir('local')
   commandLine 'docker', 'exec',
     "${->startDockerContainer.containerId()}", '/bin/bash', '-c',
     """cd $dockerWorkDir/build/website && \
@@ -138,17 +161,18 @@ task serveWebsite(type: Exec) {
 }
 
 task testWebsite(type: Exec) {
-  dependsOn startDockerContainer, buildWebsite
+  // dependsOn startDockerContainer, 'buildWebsite'
   finalizedBy stopAndRemoveDockerContainer
 
   inputs.files "$buildDir/Rakefile"
-  inputs.dir buildContentDir
+  inputs.dir buildContentDir('local')
   commandLine 'docker', 'exec',
     "${->startDockerContainer.containerId()}", '/bin/bash', '-c',
     """cd $dockerWorkDir/build/website && \
       bundle exec rake test"""
 }
 
+testWebsite.dependsOn 'buildLocalWebsite'
 check.dependsOn testWebsite
 
 task preCommit {
@@ -157,10 +181,10 @@ task preCommit {
 
 // Creates a new commit on asf-site branch
 task commitWebsite << {
-  assert file("${buildContentDir}/index.html").exists()
+  assert file("${buildContentDir('apache')}/index.html").exists()
   // Generated javadoc and pydoc content is not built or stored in this repo.
-  assert !file("${buildContentDir}/documentation/sdks/javadoc").exists()
-  assert !file("${buildContentDir}/documentation/sdks/pydoc").exists()
+  assert 
!file("${buildContentDir('apache')}/documentation/sdks/javadoc").exists()
+  assert 
!file("${buildContentDir('apache')}/documentation/sdks/pydoc").exists()
 
   def git = grgit.open()
   // get the latest commit on master
@@ -169,14 +193,15 @@ task commitWebsite << {
   shell "git fetch --force origin +asf-site:asf-site"
   git.checkout(branch: 'asf-site')
 
-  // Delete the previous content.
+  // Delete the previous content. These are asf-site branch paths.
   git.remove(patterns: [ 'website/generated-content' ])
+  def repoContentDir = "${project.rootDir}/website/generated-content"
   assert !file("${repoContentDir}/index.html").exists()
   delete repoContentDir
 
   // Copy the built content and add it.
   copy {
-    from buildContentDir
+    from buildContentDir('apache')
     into repoContentDir
   }
   assert file("${repoContentDir}/index.html").exists()
@@ -221,7 +246,7 @@ task publishWebsite << {
   shell "git push ${gitboxUrl} asf-site"
 }
 
-commitWebsite.dependsOn buildWebsite
+commitWebsite.dependsOn buildApacheWebsite
 publishWebsite.dependsOn commitWebsite
 
 /*
@@ -230,26 +255,24 @@ publishWebsite.dependsOn commitWebsite
  *   ./gradlew :beam-website:stageWebsite -PgithubPullRequestId=${ghprbPullId} 
-PwebsiteBucket=foo
  */
 task stageWebsite << {
-  assert project.hasProperty('githubPullRequestId')
-  assert githubPullRequestId.isInteger()
-
+  def baseUrl = getBaseUrl()
   def gcs_bucket = project.findProperty('websiteBucket') ?: 
'apache-beam-website-pull-requests'
-  def gcs_path = "gs://${gcs_bucket}/${githubPullRequestId}"
+  def gcs_path = "gs://${gcs_bucket}/${baseUrl}"
 
   // Remove current site if it exists.
   shell "gsutil -m rm -r -f ${gcs_path} || true"
 
   // Fixup the links to index.html files
-  shell "cd ${buildDir} && ln -s generated-content content || true"
+  shell "cd ${buildDir} && ln -s generated-gcs-content content || true"
   shell ". ${envdir}/bin/activate && cd ${buildDir} && " +
         "python 
${project.rootDir}/website/.jenkins/append_index_html_to_internal_links.py"
 
   // Copy the build website to GCS
-  shell "gsutil -m cp -r ${buildContentDir} ${gcs_path}"
+  shell "gsutil -m cp -r ${buildContentDir('gcs')} ${gcs_path}"
 
   println "Website published to http://${gcs_bucket}."; +
-      "storage.googleapis.com/${githubPullRequestId}/index.html"
+      "storage.googleapis.com/${baseUrl}/index.html"
 }
 
 stageWebsite.dependsOn setupVirtualenv
-stageWebsite.dependsOn buildWebsite
+stageWebsite.dependsOn buildGcsWebsite


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 153311)
    Time Spent: 1h 50m  (was: 1h 40m)

> [beam_PreCommit_Website_Cron] [testWebsite] Fails on URL checks
> ---------------------------------------------------------------
>
>                 Key: BEAM-5681
>                 URL: https://issues.apache.org/jira/browse/BEAM-5681
>             Project: Beam
>          Issue Type: Bug
>          Components: test-failures, website
>            Reporter: Scott Wegner
>            Assignee: Alan Myrvold
>            Priority: Major
>              Labels: currently-failing
>          Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> _Use this form to file an issue for test failure:_
>  * [Jenkins Job|https://builds.apache.org/job/beam_PreCommit_Website_Cron/154]
>  * [Gradle Build 
> Scan|https://scans.gradle.com/s/k6ul7uyovyyce/console-log?task=:beam-website:testWebsite#L27]
>  * [Test source 
> code|https://github.com/apache/beam/blob/1c573ffba014f6969a689d0e6cdcace31358885d/website/build.gradle#L140]
> Initial investigation:
> It seems every link is failing. Same error message:
> {{- ./generated-content/beam/capability/2016/03/17/capability-matrix.html}}
> {{  *  http:// is an invalid URL (line 76)}}
> {{     <a href="//" class="navbar-brand">}}
> {{        <img alt="Brand" style="height: 25px" 
> src="//images/beam_logo_navbar.png">}}
> {{      </a>}}
> The _Cron version of this job has been failing consistently since 10/5 
> ([history|https://builds.apache.org/job/beam_PreCommit_Website_Cron/])
> ----
> _After you've filled out the above details, please [assign the issue to an 
> individual|https://beam.apache.org/contribute/postcommits-guides/index.html#find_specialist].
>  Assignee should [treat test failures as 
> high-priority|https://beam.apache.org/contribute/postcommits-policies/#assigned-failing-test],
>  helping to fix the issue or find a more appropriate owner. See [Apache Beam 
> Post-Commit 
> Policies|https://beam.apache.org/contribute/postcommits-policies]._



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to