cached-path 0.5.1

Download and cache HTTP resources.
Documentation
name: CI

on:
  pull_request:
    branches:
    - master
  push:
    branches:
    - master
  release:
    types: [published]
  schedule:
    - cron: '0 10 * * *' # run at 10 AM UTC

jobs:
  changelog:
    name: CHANGELOG
    runs-on: ubuntu-latest
    # Only run this on pull requests.
    if: github.event_name == 'pull_request'

    steps:
    # Note that checkout@v2 will not work with the git command below!
    - uses: actions/checkout@v1

    - name: Debugging info
      run: |
        git remote -v

    - name: Check that CHANGELOG has been updated
      run: |
        # If this step fails, this means you haven't updated the CHANGELOG.md
        # file with notes on your contribution.
        git diff --name-only $(git merge-base origin/master HEAD) | grep '^CHANGELOG.md$' && echo "Thanks for helping keep our CHANGELOG up-to-date!"

  build:
    name: Build
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
    steps:
    - uses: actions/checkout@v2

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

    - name: Set build variables
      run: |
        # We use these variables as part of the cache keys.
        echo "RUST_VERSION=$(rustc --version)" >> $GITHUB_ENV
        echo "CARGO_VERSION=$(cargo --version)" >> $GITHUB_ENV

    - name: Cache cargo registry
      uses: actions/cache@v2
      with:
        path: ~/.cargo/registry
        key: cargo registry ${{ github.job }} ${{ runner.os }} ${{ env.RUST_VERSION }} ${{ env.CARGO_VERSION }} ${{ hashFiles('**/Cargo.toml') }}

    - name: Cache cargo build
      uses: actions/cache@v2
      with:
        path: target
        key: cargo build ${{ github.job }} ${{ runner.os }} ${{ env.RUST_VERSION }} ${{ env.CARGO_VERSION }} ${{ hashFiles('**/Cargo.toml') }}

    - name: Lint with rustfmt
      if: always()
      uses: actions-rs/cargo@v1
      with:
        command: fmt
        args: -- --check

    - name: Lint with clippy
      if: always()
      uses: actions-rs/cargo@v1
      with:
        command: clippy
        args: --all-targets --all-features -- -D warnings

    - name: Build
      if: always()
      uses: actions-rs/cargo@v1
      with:
        command: build
        args: --all-features

    - name: Run unit tests
      if: always()
      uses: actions-rs/cargo@v1
      with:
        command: test
        args: --lib --all-features

    - name: Run integration tests
      if: always()
      uses: actions-rs/cargo@v1
      with:
        command: test
        args: --test cli

    - name: Run doc tests
      if: always()
      uses: actions-rs/cargo@v1
      with:
        command: test
        args: --doc --all-features

  publish:
    name: Publish
    needs: [build]
    runs-on: ubuntu-latest
    # Only run on main repo releases .
    if: github.repository == 'epwalsh/rust-cached-path' && github.event_name == 'release'
    steps:
    - uses: actions/checkout@v2

    - name: Install rust stable
      uses: actions-rs/toolchain@v1
      with:
        toolchain: stable

    - name: Log in to crates.io
      uses: actions-rs/cargo@v1
      with:
        command: login
        args: ${{ secrets.CARGO_TOKEN }}

    - name: Publish
      uses: actions-rs/cargo@v1
      with:
        command: publish