term-transcript 0.1.0

Snapshotting and snapshot testing for CLI / REPL applications
Documentation
name: Rust

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

env:
  # Minimum supported Rust version.
  msrv: 1.45.0
  # Nightly Rust necessary for building docs.
  nightly: nightly-2021-04-15

jobs:
  build-msrv:
    strategy:
      matrix:
        os: [ ubuntu-latest, windows-latest ]

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v2

      - name: Cache cargo build
        uses: actions/cache@v1
        with:
          path: target
          key: ${{ runner.os }}-msrv-cargo-build-target

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ env.msrv }}
          override: true

      - name: Run tests
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --all --all-targets
      - name: Run doc tests
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --all --doc

  build:
    strategy:
      matrix:
        os: [ ubuntu-latest, windows-latest ]

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v2

      - name: Cache cargo build
        uses: actions/cache@v1
        with:
          path: target
          key: ${{ runner.os }}-cargo-build-target

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
          components: rustfmt, clippy

      - name: Format
        if: matrix.os == 'ubuntu-latest'
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check
      - name: Clippy
        if: matrix.os == 'ubuntu-latest'
        uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --all --all-targets -- -D warnings
      - name: Build (no features)
        if: matrix.os == 'ubuntu-latest'
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: -p term-transcript --no-default-features --lib
      - name: Build (features = svg)
        if: matrix.os == 'ubuntu-latest'
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: -p term-transcript --no-default-features --features svg --lib

      - name: Run tests
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --all --all-features --all-targets
      - name: Run doc tests
        uses: actions-rs/cargo@v1
        with:
          command: test
          args: --all --all-features --doc

      - name: Generate snapshots
        if: matrix.os == 'ubuntu-latest'
        run: ./examples/generate-snapshots.sh

  document:
    needs:
      - build
      - build-msrv
    if: github.event_name == 'push'
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Cache cargo build
        uses: actions/cache@v1
        with:
          path: target
          key: ${{ runner.os }}-cargo-document-target

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ env.nightly }}
          profile: minimal
          override: true

      - name: Build docs
        run: |
          cargo clean --doc && \
          cargo rustdoc -p term-transcript -- --cfg docsrs

      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@releases/v3
        with:
          ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
          BRANCH: gh-pages
          FOLDER: target/doc
          SINGLE_COMMIT: true