From c1fbabf68691f04b0a4bbe69e211902183499731 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Wed, 27 Sep 2017 16:20:08 -0500 Subject: [PATCH] Make CI build flatter (and therefore faster) (#123) Now with a fancier script for running h2spec will ensure that the server executable is killed when h2spec finishes, de-interleaves h2spec & example server stdout --- .travis.yml | 63 +++++++++++++++++++--------------------------------- ci/h2spec.sh | 28 +++++++++++++++++++++++ 2 files changed, 51 insertions(+), 40 deletions(-) create mode 100755 ci/h2spec.sh diff --git a/.travis.yml b/.travis.yml index 9b4f1d0..b2e1807 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,12 +12,15 @@ addons: packages: - libssl-dev -rust: -- nightly -- stable +matrix: + include: + - rust: nightly + before_deploy: cargo doc --no-deps + - rust: stable install: - bash <(curl https://raw.githubusercontent.com/xd009642/tarpaulin/master/travis-install.sh) + - if [ "${TRAVIS_RUST_VERSION}" = "nightly" ]; then cargo install --force rustfmt-nightly; fi before_script: - cargo clean @@ -34,50 +37,30 @@ script: # Run tests, uploading results to codecov.. # hpack tests are _super_ slow in coverage, so skip them here. - - cargo tarpaulin --features unstable --out Xml -- --skip hpack + - cargo tarpaulin --features unstable --skip-clean --no-count --out Xml -- --skip hpack # Test _only_ hpack. - cargo test --lib -- hpack + # Run rustfmt on nightly + - if [ "${TRAVIS_RUST_VERSION}" = "nightly" ]; then cargo fmt -- --write-mode=diff; fi + + # Run h2spec on stable + - if [ "${TRAVIS_RUST_VERSION}" = "stable" ]; then ./ci/h2spec.sh; fi + after_success: - bash <(curl -Ls https://codecov.io/bash) -jobs: - # allow_failures: - # - rust: nightly - include: - - stage: h2spec - rust: nightly - install: | - wget https://github.com/summerwind/h2spec/releases/download/v2.1.0/h2spec_linux_amd64.tar.gz && - tar xf h2spec_linux_amd64.tar.gz - script: - - cargo build --example server - - | - exec 3< <(./target/debug/examples/server); - sed '/listening on Ok(V4(127.0.0.1:5928))/q' <&3 ; cat <&3 & - ./h2spec -p 5928 - - stage: docs - script: cargo doc --no-deps - install: skip - deploy: - provider: pages - skip_cleanup: true - github_token: $GH_TOKEN - target_branch: gh-pages - local_dir: target/doc - on: - branch: master - repo: carllerche/h2 - rust: nightly - after_success: skip - - - stage: fmt - rust: nightly - install: cargo install --force rustfmt-nightly - script: cargo fmt -- --write-mode=diff - after_success: skip - +deploy: + provider: pages + skip_cleanup: true + github_token: $GH_TOKEN + target_branch: gh-pages + local_dir: target/doc + on: + branch: master + repo: carllerche/h2 + rust: nightly env: global: - secure: LkjG3IYPu7GY7zuMdYyLtdvjR4a6elX6or1Du7LTBz4JSlQXYAaj6DxhfZfm4d1kECIlnJJ2T21BqDoJDnld5lLu6VcXQ2ZEo/2f2k77GQ/9w3erwcDtqxK02rPoslFNzSd2SCdafjGKdbcvGW2HVBEu5gYEfOdu1Cdy6Av3+vLPk5To50khBQY90Kk+cmSd7J0+CHw/wSXnVgIVoO4742+aj5pxZQLx3lsi3ZPzIh1VL4QOUlaI98ybrCVNxADQCeXRRDzj0d8NzeKlkm8eXpgpiMVRJWURMa3rU2sHU9wh+YjMyoqGZWv2LlzG5LBqde3RWPQ99ebxVhlly6RgEom8yvZbavcGJ4BA0OjviLYAMb1Wjlu1paLZikEqlvTojhpzz3PVuIBZHl+rUgnUfkuhfmMzTBJTPHPMP0GtqpIAGpyRwbv56DquuEiubl70FZmz52sXGDseoABv9jQ4SNJrDrA+bfIWkPpWwqnKaWIgGPl0n3GKeceQM3RshpaE59awYUDS4ybjtacb2Fr99fx25mTO2W4x5hcDqAvBohxRPXgRB2y0ZmrcJyCV3rfkiGFUK7H8ZBqNQ6GG/GYilgj40q6TgcnXxUxyKkykDiS9VU0QAjAwz0pkCNipJ+ImS1j0LHEOcKMKZ7OsGOuSqBmF24ewBs+XzXY7dTnM/Xc= diff --git a/ci/h2spec.sh b/ci/h2spec.sh new file mode 100755 index 0000000..aec3f53 --- /dev/null +++ b/ci/h2spec.sh @@ -0,0 +1,28 @@ +#!/bin/bash +LOGFILE="h2server.log" + +if ! [ -e "h2spec" ] ; then + # if we don't already have a h2spec executable, wget it from github + wget https://github.com/summerwind/h2spec/releases/download/v2.1.0/h2spec_linux_amd64.tar.gz + tar xf h2spec_linux_amd64.tar.gz +fi + +cargo build --example server +exec 3< <(./target/debug/examples/server); +SERVER_PID=$! + +# wait 'til the server is listening before running h2spec, and pipe server's +# stdout to a log file. +sed '/listening on Ok(V4(127.0.0.1:5928))/q' <&3 ; cat <&3 > "${LOGFILE}" & + +# run h2spec against the server, printing the server log if h2spec failed +./h2spec -p 5928 +H2SPEC_STATUS=$? +if [ "${H2SPEC_STATUS}" -eq 0 ]; then + echo "h2spec passed!" +else + echo "h2spec failed! server logs:" + cat "${LOGFILE}" +fi +kill "${SERVER_PID}" +exit "${H2SPEC_STATUS}"