diff --git a/.travis.yml b/.travis.yml index d1f1aba8f..33f6a38f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ install: - pip install markdown py-gfm script: - shellcheck deploy.sh - - shellcheck resources.whatwg.org/build/deploy.sh + - shellcheck resources.whatwg.org/build/*.sh - bash ./deploy.sh branches: diff --git a/resources.whatwg.org/build/README.md b/resources.whatwg.org/build/README.md index 4d6885bf9..7e4ddaa8b 100644 --- a/resources.whatwg.org/build/README.md +++ b/resources.whatwg.org/build/README.md @@ -51,4 +51,18 @@ Similarly, a local deploy can be performed with curl --remote-name --fail https://resources.whatwg.org/build/deploy.sh && bash ./deploy.sh ``` +or more typically `make deploy`. + Whether the script is running a local vs. Travis deploy is determined by checking [the `$TRAVIS` environment variable](https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables). + +## `review.sh` + +The `review.sh` script is also used by most WHATWG standards and is meant to be run locally to generate a new [Review Draft](https://whatwg.org/workstream-policy#review-drafts). + +It can be run with + +```bash +curl --remote-name --fail https://resources.whatwg.org/build/review.sh && bash ./review.sh +``` + +or more typically `make review`. diff --git a/resources.whatwg.org/build/deploy.sh b/resources.whatwg.org/build/deploy.sh index e4f95c7bb..ca318f6db 100644 --- a/resources.whatwg.org/build/deploy.sh +++ b/resources.whatwg.org/build/deploy.sh @@ -14,6 +14,7 @@ LS_URL="https://$SHORTNAME.spec.whatwg.org/" COMMIT_URL_BASE="https://github.com/whatwg/$SHORTNAME/commit/" WEB_ROOT="$SHORTNAME.spec.whatwg.org" COMMITS_DIR="commit-snapshots" +REVIEW_DRAFTS_DIR="review-drafts" # Optional environment variables (won't be set for local deploys) TRAVIS=${TRAVIS:-false} @@ -111,6 +112,29 @@ run_post_build_step "$WEB_ROOT" echo "Living standard output to $WEB_ROOT" echo "" +header "Starting review drafts (if applicable)..." +echo "Note: review drafts must be added or changed in a single commit on master" +if [[ "$TRAVIS_PULL_REQUEST" == "true" ]]; then + CHANGED_FILES=$(git diff --name-only master..HEAD) +else + CHANGED_FILES=$(git diff --name-only HEAD^ HEAD) +fi +for CHANGED in $CHANGED_FILES; do # Omit quotes around variable to split on whitespace + if ! [[ "$CHANGED" =~ ^review-drafts/.*.bs$ ]]; then + continue + fi + echo "" + BASENAME=$(basename "$RELATIVE_REVIEW_DRAFT" .bs) + DRAFT_DIR="$WEB_ROOT/$REVIEW_DRAFTS_DIR/$BASENAME" + mkdir -p "$DRAFT_DIR" + curlbikeshed -F md-Status="RD" \ + > "$DRAFT_DIR/index.html" + copy_extra_files "$DRAFT_DIR" + run_post_build_step "$DRAFT_DIR" + echo "Review draft output to $DRAFT_DIR" +done +echo "" + # Standard service worker and robots.txt header "Getting the service worker hash..." SERVICE_WORKER_SHA=$(curlretry https://resources.whatwg.org/standard-service-worker.js | shasum | cut -c 1-40) @@ -133,7 +157,8 @@ importScripts(\"https://resources.whatwg.org/standard-service-worker.js\"); > "$WEB_ROOT/service-worker.js" echo "User-agent: * Disallow: /branch-snapshots/ -Disallow: /commit-snapshots/" > "$WEB_ROOT/robots.txt" +Disallow: /commit-snapshots/ +Disallow: /review-drafts/" > "$WEB_ROOT/robots.txt" echo "Service worker and robots.txt output to $WEB_ROOT" echo "" diff --git a/resources.whatwg.org/build/review.sh b/resources.whatwg.org/build/review.sh new file mode 100644 index 000000000..54c801d18 --- /dev/null +++ b/resources.whatwg.org/build/review.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -o errexit +set -o nounset + +# This script is maintained at +# https://github.com/whatwg/whatwg.org/tree/master/resources.whatwg.org/build. +# See README.md there for documentation. + +mkdir -p "review-drafts" +INPUT_FILE=$(find . -maxdepth 1 -name "*.bs" -print -quit) +REVIEW_DRAFT="review-drafts/$(date +'%Y-%m').bs" +# The backslash+linefeed literal is for sed. +# shellcheck disable=SC1004 +sed 's/^Group: WHATWG$/&\ +'"Date: $(date +'%Y-%m-%d')/g" < "$INPUT_FILE" > "$REVIEW_DRAFT" +echo "Created Review Draft at $REVIEW_DRAFT" +echo "Please verify that only one line changed relative to $INPUT_FILE:" +diff -up "$INPUT_FILE" "$REVIEW_DRAFT"