name: Rust 1.12 compile test

on:
  push:
  pull_request:
  schedule:
    - cron: "35 2 * * *"

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Work around incompatible crates.io
        shell: bash
        # Point cargo at a rewound copy of crates.io that would be understood
        # at 1.10.0.  Unfortunately, pointing at a registry like this is only
        # supported from 1.12.0 and beyond.
        run: |
          set -ex
          # Tell cargo to use a different copy of crates.io.
          mkdir -p .cargo
          cat <<EOF > .cargo/config
          [source.crates-io]
          registry = "file://$(pwd)/../crates-io-rewound"
          EOF
          cat .cargo/config
          # create copy of crates.io, reset back to when rand 0.8.0 didn't
          # exist in index.
          cd ..
          git clone https://github.com/rust-lang/crates.io-index.git crates-io-rewound
          cd crates-io-rewound
          git reset --hard 46a429eac9f
      - name: Set default Rust
        run: rustup default 1.12.0
      - name: Run build
        run: cargo build --verbose
      # tests can't be run because they use ONCE which needs a newer compiler
      # - name: Run unit tests
      #   run: cargo test --verbose
