(ci) CI integration for book
* Test book code examples in separate job * In master branch, build + push book to gh-pages branch
This commit is contained in:
parent
9623e4d326
commit
ca7f9aa253
3 changed files with 77 additions and 2 deletions
|
@ -93,8 +93,8 @@ Juniper has not reached 1.0 yet, thus some API instability should be expected.
|
||||||
[iron_examples]: https://github.com/graphql-rust/juniper/tree/master/juniper_iron/examples
|
[iron_examples]: https://github.com/graphql-rust/juniper/tree/master/juniper_iron/examples
|
||||||
[hyper]: https://hyper.rs
|
[hyper]: https://hyper.rs
|
||||||
[rocket]: https://rocket.rs
|
[rocket]: https://rocket.rs
|
||||||
[book]: https://graphql-rust.github.io
|
[book]: https://graphql-rust.github.io/juniper/master
|
||||||
[book_quickstart]: https://graphql-rust.github.io/quickstart.html
|
[book_quickstart]: https://graphql-rust.github.io/juniper/master/quickstart.html
|
||||||
[docsrs]: https://docs.rs/juniper
|
[docsrs]: https://docs.rs/juniper
|
||||||
[warp]: https://github.com/seanmonstar/warp
|
[warp]: https://github.com/seanmonstar/warp
|
||||||
[warp_examples]: https://github.com/graphql-rust/juniper/tree/master/juniper_warp/examples
|
[warp_examples]: https://github.com/graphql-rust/juniper/tree/master/juniper_warp/examples
|
||||||
|
|
|
@ -13,6 +13,34 @@ jobs:
|
||||||
$HOME/.cargo/bin/cargo fmt -- --check
|
$HOME/.cargo/bin/cargo fmt -- --check
|
||||||
displayName: Run rustfmt
|
displayName: Run rustfmt
|
||||||
|
|
||||||
|
- job: run_book_tests
|
||||||
|
displayName: Book code example tests
|
||||||
|
pool:
|
||||||
|
vmImage: ubuntu-16.04
|
||||||
|
steps:
|
||||||
|
- script: |
|
||||||
|
curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||||
|
$HOME/.cargo/bin/rustup component add rustfmt
|
||||||
|
displayName: Install stable Rust
|
||||||
|
- script: |
|
||||||
|
cd docs/book/tests && $HOME/.cargo/bin/cargo test
|
||||||
|
displayName: Test book code examples via skeptic
|
||||||
|
|
||||||
|
- job: build_book_master
|
||||||
|
displayName: Build rendered book on master branch and push to Github
|
||||||
|
dependsOn: run_book_tests
|
||||||
|
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
|
||||||
|
variables:
|
||||||
|
- group: github-keys
|
||||||
|
steps:
|
||||||
|
- task: InstallSSHKey@0
|
||||||
|
inputs:
|
||||||
|
hostName: $(secret.GHSshKnownHosts)
|
||||||
|
sshPublicKey: $(secret.GHSshPub)
|
||||||
|
sshKeySecureFile: $(secret.GHSshPriv)
|
||||||
|
- script: |
|
||||||
|
./docs/book/build.sh master
|
||||||
|
|
||||||
- template: _build/azure-pipelines-template.yml
|
- template: _build/azure-pipelines-template.yml
|
||||||
parameters:
|
parameters:
|
||||||
name: Linux
|
name: Linux
|
||||||
|
|
47
docs/book/ci-build.sh
Executable file
47
docs/book/ci-build.sh
Executable file
|
@ -0,0 +1,47 @@
|
||||||
|
#! /usr/bin/env sh
|
||||||
|
|
||||||
|
# Usage: ./ci-build.sh VERSION
|
||||||
|
#
|
||||||
|
# This script builds the book to HTML with mdbook
|
||||||
|
# commits and pushes the contents to the repo in the "gh-pages" branch.
|
||||||
|
#
|
||||||
|
# It is only inteded for use on the CI!
|
||||||
|
|
||||||
|
# Enable strict error checking.
|
||||||
|
set -exo pipefail
|
||||||
|
|
||||||
|
DIR=$(dirname $(readlink -f $0))
|
||||||
|
MDBOOK="mdbook"
|
||||||
|
|
||||||
|
cd $DIR
|
||||||
|
|
||||||
|
# Verify version argument.
|
||||||
|
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
echo "Missing required argument 'version': cargo make build-book VERSION"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
VERSION="$1"
|
||||||
|
|
||||||
|
# Download mdbook if not found.
|
||||||
|
$MDBOOK -h 2>&1 > /dev/null
|
||||||
|
if [ $? != 0]; then
|
||||||
|
echo "mdbook not found. Downloading..."
|
||||||
|
curl -L https://github.com/rust-lang-nursery/mdBook/releases/download/v0.2.0/mdbook-v0.2.0-x86_64-unknown-linux-gnu.tar.gz | tar xzf -
|
||||||
|
mv ./mdbook /tmp/mdbook
|
||||||
|
set MDBOOK="/tmp/mdbook"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$MDBOOK build
|
||||||
|
echo $VERSION > ./_rendered/VERSION
|
||||||
|
rm -rf /tmp/book-content
|
||||||
|
mv ./_rendered /tmp/book-content
|
||||||
|
|
||||||
|
cd $DIR/../..
|
||||||
|
git clean -fd
|
||||||
|
git checkout gh-pages
|
||||||
|
rm -rf $VERSION
|
||||||
|
mv /tmp/book-content ./$VERSION
|
||||||
|
git add -A $VERSION
|
||||||
|
git commit -m "Updated book for $VERSION"
|
||||||
|
git push origin gh-pages
|
Loading…
Add table
Reference in a new issue