diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0fc1237..a0afee4 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -18,11 +18,11 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install nightly toolchain + - name: Install stable toolchain uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly + toolchain: stable override: true - name: Run cargo check @@ -37,11 +37,11 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install nightly toolchain + - name: Install stable toolchain uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly + toolchain: stable override: true - name: Run cargo test @@ -56,11 +56,11 @@ jobs: - name: Checkout sources uses: actions/checkout@v2 - - name: Install nightly toolchain + - name: Install stable toolchain uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly + toolchain: stable override: true components: rustfmt, clippy diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0fda4b7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,63 @@ +# Based on the "trust" template v0.1.2 +# https://github.com/japaric/trust/tree/v0.1.2 + +dist: trusty +language: rust +services: docker +sudo: required + +env: + global: + - CRATE_NAME=dot-http + +matrix: + include: + # Linux + - env: TARGET=aarch64-unknown-linux-gnu + - env: TARGET=i686-unknown-linux-gnu + - env: TARGET=x86_64-unknown-linux-gnu + + - env: TARGET=x86_64-apple-darwin + os: osx + +before_install: + - set -e + - rustup self update + +install: + - sh ci/install.sh + - source ~/.cargo/env || true + +script: + - bash ci/script.sh + +after_script: set +e + +before_deploy: + - sh ci/before_deploy.sh + +deploy: + api_key: + secure: iMEVLVkdaa3yFt3cDhCBe7s9GnNx9SlKIYQAzyrfp/Fo02Fc7STmfnKeolHTtu9BAWYNpvbZoNZuluMuhjLfKCYocD9rsKMOZAwcd9btrTs1xtK+4NXQQnfsL7CuBA2U7Wac176yV7jW6ysV5xT0PBqXs+oQOPKPbxLamRLdt72XYlm/tjEn2zLskF/+vjIJfTHp/6O80fiL2iGxqWW2Dqz9/84EJB3DgDQ6HHtNu9tCwiSD7GL+S0JXZKnTmxMIvC7RXYiWVl9bxGFtMP5fLd30LscpOZb350Myhw7ngxlGw7jpVEgY3ySyv0ItmoFnba80GfeyKHJLEmdj47mW5crKaUKrG/yqXOKUO+IHjNNCiDI7mFBDsSshtXa8RbZ7LT5pgCjhcJl2d1DHq8o+oWZfB/NoHILYWPGMOHkZDFybN95cEEWnATC7CmIE41plf99Jm62PKwVNUcc8qJsPaOW42sXmN12E0gqscMG9IDPY2WrcgAD4JavegIoqUZhLlxPiytFPsHb2mBi5dz5vKYJIajfm3EI/f/VV9kjYEMWJOpTJI1yTYT60cQEfo7MeNgvkjQjR8ahVQhoc/pxkV5PAm+BnFr9PObZooqDX9KHvaReBCx1eYX7kxRSIN8yUuQJEpjLxT/ZAMqOczNVxbtz1j/WGPCKT5lRh2ZGlxWE= + file_glob: true + file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.* + on: + condition: $TRAVIS_RUST_VERSION = stable + tags: true + provider: releases + skip_cleanup: true + +cache: cargo +before_cache: + # Travis can't cache files that are not readable by "others" + - chmod -R a+r $HOME/.cargo + +branches: + only: + # release tags + - /^v\d+\.\d+\.\d+.*$/ + - master + +notifications: + email: + on_success: never diff --git a/Cargo.toml b/Cargo.toml index e3cdb0c..00e38dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" readme = "README.md" description = "dot-http is a text-based scriptable HTTP client. It is a simple language that resembles the actual HTTP protocol but with additional features to make it practical for someone who builds and tests APIs." repository = "https://github.com/bayne/dot-http" -keywords = ["rest client", "http", "scriptable", "javascript", "API"] +keywords = ["http", "scriptable", "javascript", "API"] categories = ["command-line-utilities", "development-tools::testing", "web-programming::http-client"] license = "Apache-2.0" @@ -16,6 +16,8 @@ path = "src/main.rs" [badges] maintenance = { status = "experimental" } +travis-ci = { repository = "bayne/dot-http" } +appveyor = { repository = "bayne/dot-http", branch = "master", service = "github" } [dependencies] Boa = "0.5.1" diff --git a/README.md b/README.md index 8ec0703..4b53bfb 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ First, install [cargo](https://rustup.rs/). Then: $ cargo install dot-http ``` -You will need to use the nightly release for this to work; if in doubt run +You will need to use the stable release for this to work; if in doubt run ```bash,no_run -rustup run nightly cargo install dot-http +rustup run stable cargo install dot-http ``` ## Usage diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..d567532 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,69 @@ +# Based on the "trust" template v0.1.2 +# https://github.com/japaric/trust/tree/v0.1.2 + +environment: + global: + RUST_VERSION: stable + CRATE_NAME: dot-http + + matrix: + # MinGW + - TARGET: i686-pc-windows-gnu + - TARGET: x86_64-pc-windows-gnu + + # MSVC + - TARGET: i686-pc-windows-msvc + - TARGET: x86_64-pc-windows-msvc + +install: + - ps: >- + If ($env:TARGET -eq 'x86_64-pc-windows-gnu') { + $env:PATH += ';C:\msys64\mingw64\bin' + } ElseIf ($env:TARGET -eq 'i686-pc-windows-gnu') { + $env:PATH += ';C:\msys64\mingw32\bin' + } + - curl -sSf -o rustup-init.exe https://win.rustup.rs/ + - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION% + - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin + - rustc -Vv + - cargo -V + +test_script: + # we don't run the "test phase" when doing deploys + - if [%APPVEYOR_REPO_TAG%]==[false] ( + cargo build --target %TARGET% && + cargo build --target %TARGET% --release && + cargo test --target %TARGET% && + cargo test --target %TARGET% --release + ) + +before_deploy: + - cargo rustc --target %TARGET% --release --bin %CRATE_NAME% -- -C lto + - ps: ci\before_deploy.ps1 + +deploy: + artifact: /.*\.zip/ + auth_token: + secure: 62I0EPYa6QqOFCK4+5E/tfHhFWjOu5zPp34mdBprZsc4cGkktalSVdnQ27GtxxST + description: '' + on: + RUST_VERSION: stable + appveyor_repo_tag: true + provider: GitHub + +cache: + - C:\Users\appveyor\.cargo\registry + - target + +branches: + only: + # Release tags + - /^v\d+\.\d+\.\d+.*$/ + - master + +notifications: + - provider: Email + on_build_success: false + +# Building is done in the test phase, so we disable Appveyor's build phase. +build: false diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1 new file mode 100644 index 0000000..0788b1f --- /dev/null +++ b/ci/before_deploy.ps1 @@ -0,0 +1,23 @@ +# This script takes care of packaging the build artifacts that will go in the +# release zipfile + +$SRC_DIR = $pwd.Path +$STAGE = [System.Guid]::NewGuid().ToString() + +Set-Location $env:TEMP +New-Item -Type Directory -Name $STAGE +Set-Location $STAGE + +$ZIP = "$SRC_DIR\$($env:CRATE_NAME)-$($env:APPVEYOR_REPO_TAG_NAME)-$($env:TARGET).zip" + +# TODO Update this to package the right artifacts +Copy-Item "$SRC_DIR\target\$($env:TARGET)\release\$(env:CRATE_NAME).exe" '.\' + +7z a "$ZIP" * + +Push-AppveyorArtifact "$ZIP" + +Remove-Item *.* -Force +Set-Location .. +Remove-Item $STAGE +Set-Location $SRC_DIR diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh new file mode 100644 index 0000000..6c05c7b --- /dev/null +++ b/ci/before_deploy.sh @@ -0,0 +1,31 @@ +# This script takes care of building your crate and packaging it for release + +set -ex + +main() { + local src=$(pwd) \ + stage= + + case $TRAVIS_OS_NAME in + linux) + stage=$(mktemp -d) + ;; + osx) + stage=$(mktemp -d -t tmp) + ;; + esac + + test -f Cargo.lock || cargo generate-lockfile + + cross rustc --bin dot-http --target $TARGET --release -- -C lto + + cp target/$TARGET/release/dot-http $stage/ + + cd $stage + tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * + cd $src + + rm -rf $stage +} + +main diff --git a/ci/install.sh b/ci/install.sh new file mode 100644 index 0000000..80e18e4 --- /dev/null +++ b/ci/install.sh @@ -0,0 +1,47 @@ +set -ex + +main() { + local target= + if [ $TRAVIS_OS_NAME = linux ]; then + target=x86_64-unknown-linux-musl + sort=sort + else + target=x86_64-apple-darwin + sort=gsort # for `sort --sort-version`, from brew's coreutils. + fi + + # Builds for iOS are done on OSX, but require the specific target to be + # installed. + case $TARGET in + aarch64-apple-ios) + rustup target install aarch64-apple-ios + ;; + armv7-apple-ios) + rustup target install armv7-apple-ios + ;; + armv7s-apple-ios) + rustup target install armv7s-apple-ios + ;; + i386-apple-ios) + rustup target install i386-apple-ios + ;; + x86_64-apple-ios) + rustup target install x86_64-apple-ios + ;; + esac + + # This fetches latest stable release + local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \ + | cut -d/ -f3 \ + | grep -E '^v[0.1.0-9.]+$' \ + | $sort --version-sort \ + | tail -n1) + curl -LSfs https://japaric.github.io/trust/install.sh | \ + sh -s -- \ + --force \ + --git japaric/cross \ + --tag $tag \ + --target $target +} + +main diff --git a/ci/script.sh b/ci/script.sh new file mode 100644 index 0000000..3ccf556 --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,20 @@ +# This script takes care of testing your crate + +set -ex + +main() { + cross build --target $TARGET + cross build --target $TARGET --release + + if [ ! -z $DISABLE_TESTS ]; then + return + fi + + cross test --target $TARGET + cross test --target $TARGET --release +} + +# we don't run the "test phase" when doing deploys +if [ -z $TRAVIS_TAG ]; then + main +fi diff --git a/src/main.rs b/src/main.rs index 9b3b55c..3d79ec2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,10 +32,10 @@ //! $ cargo install dot-http //! ``` //! -//! You will need to use the nightly release for this to work; if in doubt run +//! You will need to use the stable release for this to work; if in doubt run //! //! ```bash,no_run -//! rustup run nightly cargo install dot-http +//! rustup run stable cargo install dot-http //! ``` //! //! ## Usage