-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new validator tools subfolder and doc for building a command-line validator on Mac OS X #1554
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
181 changes: 181 additions & 0 deletions
181
validator/docs/building_a_command_line_amp_validator_for_mac_os_x.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
#Building a command-line AMP Validator: Mac OS X | ||
|
||
## Purpose | ||
|
||
This documents how to build the official AMP-HTML command-line AMP Validator on Mac OS X. Once built in this fashion it can then be executed from a OS X terminal session to validate candidate HTML files over the local file system or the web as follows: | ||
|
||
No HTML file passed to the program: | ||
|
||
``` | ||
$ node validate | ||
usage: validate <file.html or url> | ||
``` | ||
|
||
Valid HTML file passed to the program: | ||
|
||
``` | ||
$ node validate testdata/feature_tests/minimum_valid_amp.html | ||
PASS | ||
``` | ||
|
||
Invalid HTML file passed to the program: | ||
|
||
``` | ||
$ node validate testdata/feature_tests/empty.html | ||
FAIL | ||
empty.html:1:0 The mandatory tag 'html ⚡ for top-level html' is missing or incorrect. (see [https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#ampd]) | ||
``` | ||
|
||
## References | ||
- Development on AMP HTML | ||
- [https://github.com/ampproject/amphtml/blob/master/DEVELOPING.md](https://github.com/ampproject/amphtml/blob/master/DEVELOPING.md) | ||
- AMP HTML ⚡ Validator | ||
- [https://github.com/ampproject/amphtml/blob/master/validator/README.md](https://github.com/ampproject/amphtml/blob/master/validator/README.md) | ||
- Validating outside the browser - command line tool #937 | ||
- [https://github.com/ampproject/amphtml/issues/937](https://github.com/ampproject/amphtml/issues/937) | ||
|
||
## Dependencies and configuration | ||
|
||
### Homebrew | ||
|
||
#### Installing Homebrew | ||
|
||
See: [http://brew.sh/](http://brew.sh/) | ||
|
||
``` | ||
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | ||
``` | ||
|
||
#### Maintaining your Homebrew environment | ||
|
||
See GitHub Gist: [pietergreyling/mybrew.sh](https://gist.github.com/pietergreyling/43b00966f0a775a84ac8) | ||
|
||
``` | ||
#!/bin/bash | ||
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
#-- desc: To clean up and verify your Homebrew setup. | ||
#-- exec: In a terminal session run: $ ./mybrew.sh | ||
clear | ||
echo "-- Updating your Homebrew installation at: " && brew --prefix | ||
sudo chown -R $(whoami):admin /usr/local | ||
brew update && brew upgrade | ||
echo "-- \$HOMEBREW_INSTALL: $HOMEBREW_INSTALL" | ||
brew prune | ||
brew doctor | ||
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
``` | ||
|
||
### Node JS | ||
|
||
``` | ||
$ brew install node | ||
``` | ||
|
||
### Edit /etc/hosts | ||
|
||
Not strictly initially necessary for the validator, but good not to forget: | ||
|
||
``` | ||
127.0.0.1 ads.localhost iframe.localhost | ||
``` | ||
|
||
### Google Protocol Buffers | ||
|
||
``` | ||
$ brew tap homebrew/versions | ||
$ brew install protobuf --c++11 | ||
$ brew link protobuf | ||
$ protoc --version | ||
libprotoc 2.6.1 | ||
$ python | ||
Python 2.7.11 (default, Dec 5 2015, 14:44:53) | ||
>> import google.protobuf | ||
. . . exit if import worked . . . | ||
``` | ||
|
||
### Getting a local working copy of the AMP repository source | ||
|
||
``` | ||
$ cd my_amp_repo_work_directory | ||
$ git clone [https://github.com/ampproject/amphtml.git](https://github.com/ampproject/amphtml.git) | ||
$ cd amphtml | ||
$ npm install | ||
``` | ||
|
||
### Updating an existing AMP repository source copy | ||
|
||
``` | ||
$ cd my_amp_repo_work_directory/amphtml | ||
$ git pull origin master | ||
$ npm install | ||
``` | ||
|
||
## Building the validator | ||
|
||
``` | ||
$ cd validator | ||
$ npm install | ||
$ sudo python ./build.py | ||
[[build.py getNodeJsCmd]] - entering ... | ||
[[build.py getNodeJsCmd]] - ... done | ||
[[build.py CheckPrereqs]] - entering ... | ||
[[build.py CheckPrereqs]] - ... done | ||
[[build.py InstallNodeDependencies]] - entering ... | ||
amp_validator@0.1.0 .../amphtml/validator | ||
├── google-closure-compiler@20151015.0.0 | ||
├── google-closure-library@20151015.0.0 | ||
└─┬ jasmine@2.3.2 | ||
├── exit@0.1.2 | ||
├─┬ glob@3.2.11 | ||
│ ├── inherits@2.0.1 | ||
│ └─┬ minimatch@0.3.0 | ||
│ ├── lru-cache@2.7.3 | ||
│ └── sigmund@1.0.1 | ||
└── jasmine-core@2.3.4 | ||
|
||
[[build.py InstallNodeDependencies]] - ... done | ||
[[build.py SetupOutDir]] - entering ... | ||
[[build.py SetupOutDir]] - ... done | ||
[[build.py GenValidatorPb2Py]] - entering ... | ||
[[build.py GenValidatorPb2Py]] - ... done | ||
[[build.py GenValidatorGeneratedJs]] - entering ... | ||
[[build.py GenValidatorGeneratedJs]] - ... done | ||
[[build.py CompileValidatorMinified]] - entering ... | ||
[[build.py CompileValidatorMinified]] - ... done | ||
[[build.py GenerateValidateBin]] - entering ... | ||
[[build.py GenerateValidateBin]] - ... done | ||
[[build.py RunSmokeTest]] - entering ... | ||
[[build.py RunSmokeTest]] - ... done | ||
[[build.py CompileValidatorTestMinified]] - entering ... | ||
[[build.py CompileValidatorTestMinified]] - ... success | ||
[[build.py CompileHtmlparserTestMinified]] - entering ... | ||
[[build.py CompileHtmlparserTestMinified]] - ... success | ||
[[build.py CompileParseCssTestMinified]] - entering ... | ||
[[build.py CompileParseCssTestMinified]] - ... success | ||
[[build.py GenerateTestRunner]] - entering ... | ||
[[build.py GenerateTestRunner]] - ... success | ||
[[build.py RunTests]] - entering ... | ||
Started | ||
................................................................................... | ||
83 specs, 0 failures | ||
Finished in 0.394 seconds | ||
[[build.py RunTests]] - ... success | ||
``` | ||
|
||
## Running the validator (dist/validate) | ||
|
||
``` | ||
$ ls -alG dist/validate | ||
-rwxr-x--- 1 245040 Jan 21 14:47 dist/validate | ||
|
||
$ node dist/validate | ||
usage: validate <file.html or url>; | ||
|
||
$ node dist/validate testdata/feature_tests/minimum_valid_amp.html | ||
PASS | ||
|
||
$ node dist/validate testdata/feature_tests/empty.html | ||
FAIL | ||
empty.html:1:0 The mandatory tag 'html ⚡ for top-level html' is missing or incorrect. (see [https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#ampd]) | ||
. . . | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to drop this section since it's not needed for the validator. We have a DEVELOPMENT.md with these instructions instead.