pythongithub-actionsconda

Github actions to test python scripts after creating and activating conda environment not working


I have a repo where there are a bunch of python scripts, and there's a environment.yml file to create a conda environment with. I run tests by:

conda env create -f environment.yml
conda activate env_name
cd tests
pytest

I want to automate this with github actions. I have pytest.yml in .github/workflows/. It starts to run when I push, but it gets stuck with Waiting for a runner to pick up this job..., which I've understood to mean there's something wrong with my .yml file. pytest.yml contains (using this resource):

name: conda

on:
  workflow_dispatch:
  pull_request:
  push:
    branches:
      - main

jobs:
  tests:
    name: tests
    strategy:
      fail-fast: false
      matrix:
        platform: [windows-latest, macos-latest, ubuntu-latest]
        python-version: ['3.12']

    runs-on: $${{ matrix.platform }}

    steps:
    - uses: conda-incubator/setup-miniconda@v3
      with:
        miniconda-version: "latest"

    - name: tests
      run: |
        conda env create -f environment.yml
        conda activate price_predictor_env
        cd tests
        python -m pytest

What could I be missing?


Solution

  • You have double $ in the runs-on, so instead of:

    ...
        runs-on: $${{ matrix.platform }}
    ...
    

    do

    ...
        runs-on: ${{ matrix.platform }}
    ...
    

    According to this answer GitHub will not notify you of the error if one misspells the name of the platform to run on (sic)