---
name: tests
on:
  push:
  pull_request:
  schedule:
    - cron: 0 0 * * 2

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    strategy:
      fail-fast: false
    steps:
      - uses: actions/checkout@v2

      - name: Run tests
        run: cargo test --color always -- --nocapture

      - name: Add clippy
        run: rustup component add clippy

      - uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --all-features

      - name: Build docs
        run: |
          cargo rustdoc
          cat <<EOF > target/doc/index.html
          <!DOCTYPE html>
          <meta charset="utf-8">
          <title>Redirecting to pep440</title>
          <meta http-equiv="refresh" content="0; URL=./pep440/">
          EOF

      - name: Deploy docs
        uses: JamesIves/github-pages-deploy-action@4.0.0
        with:
          branch: gh-pages
          folder: target/doc
