Skip to content

Commit

Permalink
Add scripts for Review Draft deployment
Browse files Browse the repository at this point in the history
Closes #197. See also whatwg/sg#70 and
whatwg/meta#92.
  • Loading branch information
domenic authored May 29, 2018
1 parent 4c6f484 commit 5d97cac
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions resources.whatwg.org/build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
27 changes: 26 additions & 1 deletion resources.whatwg.org/build/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand All @@ -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 ""

Expand Down
18 changes: 18 additions & 0 deletions resources.whatwg.org/build/review.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 5d97cac

Please sign in to comment.