cargo-wasi-src 0.1.21

Subcommand for Cargo to easily build code for `wasm32-wasi`
Documentation
name: CI
on:
  push:
    branches: [master]
    tags: ['[0-9]*']
  pull_request:
    branches: [master]

jobs:
  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
    - uses: actions/checkout@master
    - name: Install Rust (rustup)
      run: rustup update stable --no-self-update && rustup default stable
      shell: bash

    - name: Install wasmtime (macos)
      run: |
        set -e
        curl -L https://github.com/CraneStation/wasmtime/releases/download/dev/wasmtime-dev-x86_64-macos.tar.xz | tar xJf -
        echo ::add-path::`pwd`/wasmtime-dev-x86_64-macos
      if: matrix.os == 'macos-latest'

    - name: Install wasmtime (linux)
      run: |
        set -e
        curl -L https://github.com/CraneStation/wasmtime/releases/download/dev/wasmtime-dev-x86_64-linux.tar.xz | tar xJf -
        echo ::add-path::`pwd`/wasmtime-dev-x86_64-linux
      if: matrix.os == 'ubuntu-latest'

    - name: Install wasmtime (windows)
      run: |
        set -e
        curl -LO https://github.com/CraneStation/wasmtime/releases/download/dev/wasmtime-dev-x86_64-windows.zip
        unzip wasmtime-dev-x86_64-windows.zip
        echo ::add-path::D:/a/cargo-wasi/cargo-wasi/wasmtime-dev-x86_64-windows
      shell: bash
      if: matrix.os == 'windows-latest'

    - run: cargo build
    - run: cargo test
    - run: cargo test -p cargo-wasi-shim
    - run: cargo build -p assemble

  examples:
    name: Examples
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Install Rust
      run: rustup update beta && rustup update stable && rustup default beta
    - run: cargo install --debug --path .

    # Verify that we can switch between channels (stable/beta) and we'll
    # automatically get the wasi target on both.
    - run: (cd examples/hello-world && cargo +stable wasi build --release -v)
    - run: (cd examples/hello-world && cargo +beta wasi build --release -v)

    # Run this twice just to make sure it's fresh the second time
    - run: (cd examples/markdown && cargo wasi build --release -v)
    - run: (cd examples/markdown && cargo wasi build --release -v)

  build:
    name: Build
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        target:
        - x86_64-apple-darwin
        - x86_64-unknown-linux-musl
        - x86_64-pc-windows-msvc
        include:
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
          - target: x86_64-apple-darwin
            os: macos-latest
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            ext: .exe
    steps:
    - uses: actions/checkout@master
    - name: Install Rust (rustup)
      run: rustup update stable --no-self-update && rustup default stable
      shell: bash
    - run: rustup target add ${{ matrix.target }}

    # Target older versions of OSX (as old as we reasonably can) to ensure we
    # can run across a wide variety of systems.
    - name: Configure OSX deployment target
      run: echo ::set-env name=MACOSX_DEPLOYMENT_TARGET::10.7
      if: matrix.os == 'macos-latest'

    # Don't link the CRT dynamically to increase our binary compatibility.
    - name: Configure Windows build flags
      run: echo ::set-env name=RUSTFLAGS::-Ctarget-feature=+crt-static
      if: matrix.os == 'windows-latest'

    # Install a musl toolchain if we're on Linux
    - name: Install musl-gcc
      run: sudo apt update -y && sudo apt install -y musl-tools
      if: matrix.os == 'ubuntu-latest'

    # Build our actual binary
    - run: cargo build --release --target ${{ matrix.target }} --features reqwest/native-tls-vendored

    # Plop the binary plus a `*.crate` file for the corresponding
    # target-specific package in `tmp` and upload the artifact.
    - run: cargo run -p assemble --bin krate ${{ matrix.target }} target/${{ matrix.target }}/release/cargo-wasi${{ matrix.ext }}
    - name: Publish binary build
      uses: actions/upload-artifact@v1
      with:
        name: cargo-wasi-${{ matrix.target }}
        path: tmp

  rustfmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Install Rust
      run: rustup update stable && rustup default stable && rustup component add rustfmt
    - run: cargo fmt -- --check

  book:
    name: Book Documentation
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Install Rust
      run: rustup update stable && rustup default stable
    - name: Install mdbook
      run: |
        set -e
        curl -L https://github.com/rust-lang-nursery/mdBook/releases/download/v0.3.0/mdbook-v0.3.0-x86_64-unknown-linux-gnu.tar.gz | tar xzf -
        echo ::add-path::`pwd`
    - run: cd doc && mdbook build
    - name: Push to gh-pages
      run: curl -LsSf https://git.io/fhJ8n | rustc - && (cd doc/book && ../../rust_out)
      env:
        GITHUB_DEPLOY_KEY: ${{ secrets.GITHUB_DEPLOY_KEY }}
        BUILD_REPOSITORY_ID: ${{ github.repository }}
        BUILD_SOURCEVERSION: ${{ github.sha }}
      if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'

  publish:
    name: Publish
    needs: build
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Install Rust
      run: rustup update stable && rustup default stable

    # Download artiacts produced in build step
    - name: Download OSX
      uses: actions/download-artifact@v1
      with:
        name: cargo-wasi-x86_64-apple-darwin
    - name: Download Linux
      uses: actions/download-artifact@v1
      with:
        name: cargo-wasi-x86_64-unknown-linux-musl
    - name: Download Windows
      uses: actions/download-artifact@v1
      with:
        name: cargo-wasi-x86_64-pc-windows-msvc

    # On tags we actually publish crates, so configure env vars if this is a git
    # tag.
    - name: Configure release env vars
      run: |
        echo ::set-env name=NO_DRY_RUN::1
        echo ::set-env name=CARGO_REGISTRY_TOKEN::${{ secrets.CARGO_REGISTRY_TOKEN }}
      if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

    # Take all the input `*.crate` files and run various checks. Additionally
    # assemble the "real" `cargo-wasi` crate which is published on crates.io.
    - run: cargo run -p assemble --bin weave