https://github.com/RadioAstronomySoftwareGroup/pyuvdata
Raw File
Tip revision: c04379a692c3771630240a6f5a4d8d10163fb1ed authored by Matthew Kolopanis on 07 June 2022, 21:14:45 UTC
add setup-conda option necessary for caching to work
Tip revision: c04379a
macosx_windows_ci.yaml
name: Run Tests
on: [push, pull_request]

jobs:
  tests:
    name: Run Tests
    env:
      PYTHON: ${{ matrix.python-version }}
    runs-on: ${{ matrix.os }}
    defaults:
     run:
       # Adding -l {0} helps ensure conda can be found properly in windows.
       shell: bash -l {0}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, windows-latest]
        python-version: [3.8, 3.9, "3.10"]
    steps:
      - uses: actions/checkout@main
        with:
          fetch-depth: 1

      - name: Set ENV NAME
        run: |
          if [[ "${{ runner.os }}" = "Windows" ]]; then
            echo "::set-output name=ENV_NAME::pyuvdata_tests_windows"
          else
            echo "::set-output name=ENV_NAME::pyuvdata_tests"
          fi
        id: env_name

      - name: Cache conda
        uses: actions/cache@v2
        env:
          # Increase this value to reset cache if etc/example-environment.yml has not changed
          CACHE_NUMBER: 0
        with:
          path: ~/conda_pkgs_dir
          key:
            ${{ format('{0}-conda-{1}-{2}',
              runner.os,
              env.CACHE_NUMBER,
              hashFiles(format('./ci/{0}.yml',steps.env_name.outputs.ENV_NAME))) }}

      - name: Setup Minimamba
        uses: conda-incubator/setup-miniconda@v2
        with:
          miniforge-variant: Mambaforge
          miniforge-version: latest
          use-mamba: true
          python-version: ${{ matrix.python-version }}
          environment-file: ci/${{ steps.env_name.outputs.ENV_NAME }}.yml
          activate-environment: ${{ steps.env_name.outputs.ENV_NAME }}
          use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!

      - name: Conda Info
        run: |
          conda info -a
          conda list
          PYVER=`python -c "import sys; print('{:d}.{:d}'.format(sys.version_info.major, sys.version_info.minor))"`
          if [[ $PYVER != $PYTHON ]]; then
            exit 1;
          fi

      - name: Install
        run: |
          CFLAGS="-DCYTHON_TRACE=1 -DCYTHON_TRACE_NOGIL=1" pip install .

      - name: Run Tests
        run: |
          mkdir -p empty
          cd empty
          pytest --pyargs pyuvdata -n auto --dist=loadfile --cov=pyuvdata --cov-config=../.coveragerc --cov-report xml:../coverage.xml
          cd ..

      - name: Upload Coverage
        if: success()
        run: |
          bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
back to top