name: Aerospike Rust Client Tests

on:
  push:
    branches:
      - master
      - gh-actions
  pull_request:
    branches: 
      - master

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1
  AEROSPIKE_HOSTS: 127.0.0.1:3000

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        rust: [stable, nightly]
        runtime: [rt-tokio, rt-async-std]
        version: [async, sync]

    steps:
    - uses: actions/checkout@v2
    - name: Install Rust ${{ matrix.rust }} toolchain
      uses: actions-rs/toolchain@v1
      with:
        toolchain: ${{ matrix.rust }}
        override: true
    - run: rustc --version
    - name: Set up Aerospike Database
      uses: reugn/github-action-aerospike@v1
    - name: Clear cache before building
      run: rm -rf target/debug/deps/*
    - name: Build client
      run: cargo build --verbose --no-default-features --features serialization,${{ matrix.version }},${{ matrix.runtime }} # Turn off default features since async is default and this also builds sync
    - name: Run tests
      if: matrix.version == 'async' # Unit tests only include the async interface
      run: cargo test --verbose --no-default-features --features serialization,${{ matrix.version }},${{ matrix.runtime }} # Turn off default features since async is default and this also builds sync
