name: lotus-test

on:
  push:
    branches:
      - main
      - feature-ci-*
  pull_request:
    branches:
      - main
      - feature-ci-*

jobs:
  lotus-test:
    name: lotus-${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [
          'ubuntu-latest', 
          # 'macos-latest'
          # 'windows-latest'
        ]
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with:
          distribution: 'adopt-hotspot'
          java-version: '17'
          cache: 'gradle'      
      - uses: r-lib/actions/setup-r@v2
      - uses: mamba-org/provision-with-micromamba@main
        with:
          cache-downloads: true
          cache-env: true
          environment-file: environment.yml
          extra-specs: |
            python=3.11
      - name: Create and populate .Renviron file
        env:
          CROSSREF_EMAIL: ${{ secrets.CROSSREF_EMAIL }}
        run: |
          touch .Renviron
          echo crossref_email="$CROSSREF_EMAIL" >> .Renviron
      - name: Run tests
        env:
          R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
          GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
        shell: bash -l {0}
        run: |
           bash tests/integration_test.sh
