name: mdio
on: [push, pull_request]
jobs:
  cargo-fmt-check:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install stable
      uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: stable
        override: true
        components: rustfmt
    - name: Run rustfmt
      uses: actions-rs/cargo@v1
      with:
        command: fmt
        args: -- --check

  cargo-test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install stable
      uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: stable
        override: true
    - name: cargo test
      uses: actions-rs/cargo@v1
      with:
        command: test
        args: --verbose
    - name: cargo test all features
      uses: actions-rs/cargo@v1
      with:
        command: test
        args: --all-features --verbose

  cargo-doc:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install stable
      uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: stable
        override: true
    - name: cargo doc
      uses: actions-rs/cargo@v1
      with:
        command: doc
        args: --verbose

  cargo-publish:
    if: github.event_name == 'push' && github.ref == 'refs/heads/master'
    env:
      CRATESIO_TOKEN: ${{ secrets.CRATESIO_TOKEN }}
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: cargo publish
      continue-on-error: true
      run: cargo publish --token $CRATESIO_TOKEN
