Skip to content

Commit

Permalink
Meta: add commit and branch snapshots
Browse files Browse the repository at this point in the history
This moves the deploy process to be in line with most other WHATWG specifications; see whatwg/meta#2. It also adds the missing dfn.js file to get popups when clicking on <dfn> elements and makes other small tweaks.
  • Loading branch information
domenic authored Feb 17, 2017
1 parent 79390cb commit 36c3ee5
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 60 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
node_modules/
npm-debug.log
index.html

console_spec_id_rsa
deploy_key
console.spec.whatwg.org/
.DS_Store
.idea
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ sudo: false

env:
global:
secure: "a5khJF7IdbDt2cT7xjlVpEglXeud5Ln+4AnfjOwR7hrcFnwY9s/fHDXRdNi/QdOUnl/2vFM86OXgyEVUOCnwvJAPHu5fw6nDfcj18CMDBUNBZvVXwEFCTJTjL8P+zTsGx5Sh8xmWo2s+eoPJiczcwtsk7XD9gMoTYrR5Us9KF/0="
ENCRYPTION_LABEL: "b9b018a1d67d"

addons:
ssh_known_hosts: console.spec.whatwg.org

script:
- make deploy
- bash ./deploy.sh

notifications:
email:
Expand Down
61 changes: 6 additions & 55 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,59 +1,10 @@
SHELL=/bin/bash -o pipefail

spec = console
targetfolder = $(spec).spec.whatwg.org
server = $(spec).spec.whatwg.org
local: index.bs
bikeshed spec index.bs index.html --md-Text-Macro="SNAPSHOT-LINK LOCAL COPY"

# find all bikeshed files and create a target for them
# ./index.bs gets console.spec.whatwg.org/index.html
markupfiles := $(shell find . -name '*.bs' \
| sed 's|.bs|.html|g' \
| sed 's|./|$(targetfolder)/|g')
remote: index.bs
curl https://api.csswg.org/bikeshed/ -f -F [email protected] > index.html -F md-Text-Macro="SNAPSHOT-LINK LOCAL COPY"

# and build after a clean
all: clean $(markupfiles) $(targetfolder)/images

# rule matches our target files from markupfiles:
# $(targetfolder)/%.html matches all html file in the targetfolder
# $@ in the rule gets the target files from markupfiles
# i.e. if markupfiles contains bla/foo.html and bla/index.html it gets:
# bla/index.html and bla/foo.html
# the magic var @D is the directory part of our matching rule.
# @$ is basically what is matched in the % of the %.html
$(targetfolder)/%.html:
@[ -d $(@D) ] || mkdir -p $(@D) # create dir if it does not exist
@curl -f -s https://api.csswg.org/bikeshed/ -F file=@$*.bs \
| node_modules/.bin/emu-algify > $@

# copy images
$(targetfolder)/images:
$(shell cp -R images $(targetfolder)/)

# cleaning up
clean:
@rm -rf $(targetfolder)

# deployment
ifneq ($(TRAVIS_BRANCH),master)
deploy:
@echo "Not on master branch; skipping deploy"
else ifneq ($(TRAVIS_PULL_REQUEST),false)
deploy:
@echo "Building a pull request; skipping deploy"
else
deploy: clean all upload
@echo "Living standard output to $(targetfolder)"
@echo ""
@find $(targetfolder) -print
@echo ""
endif

# upload to server
upload:
@openssl aes-256-cbc -K $(encrypted_b9b018a1d67d_key) -iv $(encrypted_b9b018a1d67d_iv) -in console_spec_id_rsa.enc -out console_spec_id_rsa -d
@chmod 600 console_spec_id_rsa
@scp -r -i console_spec_id_rsa $(targetfolder) $(DEPLOY_USER)@$(server):

# don't confuse make given we have files called "clean" "upload"
# "deploy" or "all" in our root dir
.PHONY: clean upload deploy all
# Don't confuse make given we have files called "local" or "remote" in our root dir
.PHONY: local remote
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ This specification is still in its very early stages. It is very much a work in

The Console Standard is written in [Bikeshed](https://github.com/tabatkins/bikeshed), with an additional bit of help from [emu-algify](https://www.npmjs.com/package/emu-algify). The main source is in the file `index.bs`.

To build the standard locally, you will need a recent version of [Node.js](https://nodejs.org/en/). Run `npm install` in the root directory to set things up. Then the Makefile should take care of the rest by calling out to the Bikeshed web service.
To build the standard locally, you will need a recent version of [Node.js](https://nodejs.org/en/). Run `npm install` in the root directory to set things up. Then you can either use a locally installed copy of [Bikeshed](https://github.com/tabatkins/bikeshed) by running `make` or use the HTTP API version by
running `make remote`.

If you want to do a complete "local deploy" including commit and/or branch snapshots, run

```
./deploy.sh --local
```
105 changes: 105 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash
set -e

DEPLOY_USER="ddenicola"

TITLE="Console Standard"
LS_URL="https://console.spec.whatwg.org/"
COMMIT_URL_BASE="https://github.com/whatwg/console/commit/"
BRANCH_URL_BASE="https://github.com/whatwg/console/tree/"

INPUT_FILE="index.bs"
SERVER="console.spec.whatwg.org"
WEB_ROOT="console.spec.whatwg.org"
COMMITS_DIR="commit-snapshots"
BRANCHES_DIR="branch-snapshots"

if [ "$1" != "--local" -a "$DEPLOY_USER" == "" ]; then
echo "No deploy credentials present; skipping deploy"
exit 0
fi

if [ "$1" == "--local" ]; then
echo "Running a local deploy into $WEB_ROOT directory"
echo ""
fi

SHA="`git rev-parse HEAD`"
BRANCH="`git rev-parse --abbrev-ref HEAD`"
if [ "$BRANCH" == "HEAD" ]; then # Travis does this for some reason
BRANCH=$TRAVIS_BRANCH
fi

if [ "$BRANCH" == "master" -a "$TRAVIS_PULL_REQUEST" != "false" -a "$TRAVIS_PULL_REQUEST" != "" ]; then
echo "Skipping deploy for a pull request; the branch build will suffice"
exit 0
fi

BACK_TO_LS_LINK="<a href=\"/\" id=\"commit-snapshot-link\">Go to the living standard</a>"
SNAPSHOT_LINK="<a href=\"/commit-snapshots/$SHA/\" id=\"commit-snapshot-link\">Snapshot as of this commit</a>"

echo "Branch = $BRANCH"
echo "Commit = $SHA"
echo ""

rm -rf $WEB_ROOT || exit 0

# Commit snapshot
COMMIT_DIR=$WEB_ROOT/$COMMITS_DIR/$SHA
mkdir -p $COMMIT_DIR
curl https://api.csswg.org/bikeshed/ -f -F file=@$INPUT_FILE -F md-status=LS-COMMIT \
-F md-warning="Commit $SHA $COMMIT_URL_BASE$SHA replaced by $LS_URL" \
-F md-title="$TITLE (Commit Snapshot $SHA)" \
-F md-Text-Macro="SNAPSHOT-LINK $BACK_TO_LS_LINK" \
> $COMMIT_DIR/index.intermediate.html;
node_modules/.bin/emu-algify < $COMMIT_DIR/index.intermediate.html > $COMMIT_DIR/index.html
rm $COMMIT_DIR/index.intermediate.html
mkdir $COMMIT_DIR/images
cp images/*.* $COMMIT_DIR/images/
echo "Commit snapshot output to $WEB_ROOT/$COMMITS_DIR/$SHA"
echo ""

if [ $BRANCH != "master" ] ; then
# Branch snapshot, if not master
BRANCH_DIR=$WEB_ROOT/$BRANCHES_DIR/$BRANCH
mkdir -p $BRANCH_DIR
curl https://api.csswg.org/bikeshed/ -f -F file=@$INPUT_FILE -F md-status=LS-BRANCH \
-F md-warning="Branch $BRANCH $BRANCH_URL_BASE$BRANCH replaced by $LS_URL" \
-F md-title="$TITLE (Branch Snapshot $BRANCH)" \
-F md-Text-Macro="SNAPSHOT-LINK $SNAPSHOT_LINK" \
> $BRANCH_DIR/index.intermediate.html;
node_modules/.bin/emu-algify < $BRANCH_DIR/index.intermediate.html > $BRANCH_DIR/index.html
mkdir $BRANCH_DIR/images
rm $BRANCH_DIR/index.intermediate.html
cp images/*.* $BRANCH_DIR/images/
echo "Branch snapshot output to $WEB_ROOT/$BRANCHES_DIR/$BRANCH"
else
# Living standard, if master
curl https://api.csswg.org/bikeshed/ -f -F file=@$INPUT_FILE \
-F md-Text-Macro="SNAPSHOT-LINK $SNAPSHOT_LINK" \
> $WEB_ROOT/index.intermediate.html;
node_modules/.bin/emu-algify < $WEB_ROOT/index.intermediate.html > $WEB_ROOT/index.html
rm $WEB_ROOT/index.intermediate.html
mkdir $WEB_ROOT/images
cp images/*.* $WEB_ROOT/images/
echo "Living standard output to $WEB_ROOT"
fi

echo ""
find $WEB_ROOT -print
echo ""

if [ "$1" != "--local" ]; then
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in deploy_key.enc -out deploy_key -d
chmod 600 deploy_key
eval `ssh-agent -s`
ssh-add deploy_key

# scp the output directory up
scp -r $WEB_ROOT $DEPLOY_USER@$SERVER:
fi
File renamed without changes.
5 changes: 4 additions & 1 deletion index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Abstract: This specification defines APIs for console debugging facilities.
Logo: https://resources.whatwg.org/logo-console.svg
!Participate: <a href="https://github.com/whatwg/console">GitHub whatwg/console</a> (<a href="https://github.com/whatwg/console/issues/new">new issue</a>, <a href="https://github.com/whatwg/console/issues">open issues</a>)
!Participate: <a href="https://wiki.whatwg.org/wiki/IRC">IRC: #whatwg on Freenode</a>
!Commits: <a href="https://github.com/whatwg/console/commits">https://github.com/whatwg/console/commits</a>
!Commits: <a href="https://github.com/whatwg/console/commits">GitHub whatwg/console/commits</a>
!Commits: [SNAPSHOT-LINK]
!Commits: <a href="https://twitter.com/consolelog">@consolelog</a>
Opaque Elements: emu-alg
Expand Down Expand Up @@ -41,6 +42,8 @@ Link Defaults: html (dfn) structured clone
</style>

<script src=https://resources.whatwg.org/file-issue.js async></script>
<script src=https://resources.whatwg.org/commit-snapshot-shortcut-key.js async></script>
<script src=https://resources.whatwg.org/dfn.js defer></script>

<h2 id="status" class="no-num no-toc">Status</h2>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"author": "Terin Stock <[email protected]> & Robert Kowalski <[email protected]>",
"license": "CC0",
"devDependencies": {
"emu-algify": "^2.0.0"
"emu-algify": "^2.2.0"
}
}

0 comments on commit 36c3ee5

Please sign in to comment.