From afb34ee862f67dce6645a126edd0735fa2d01056 Mon Sep 17 00:00:00 2001 From: Camilo Diaz Date: Fri, 21 Jun 2024 10:49:06 -0400 Subject: [PATCH] MAINT: Testing Ifs in workflow to test multiple OS --- .github/workflows/macos_unit_tests.yml | 105 +++++++++++++++---------- 1 file changed, 64 insertions(+), 41 deletions(-) diff --git a/.github/workflows/macos_unit_tests.yml b/.github/workflows/macos_unit_tests.yml index aaceeda9f..27a55eb09 100644 --- a/.github/workflows/macos_unit_tests.yml +++ b/.github/workflows/macos_unit_tests.yml @@ -1,45 +1,68 @@ -name: Unit tests + name: Unit tests -on: - push: - branches: ['**'] - pull_request: - branches: ['**'] + on: + push: + branches: ['**'] + pull_request: + branches: ['**'] -jobs: - build: + jobs: + build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-latest] - python-version: [3.8, 3.9, "3.10"] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest,macos-latest] + python-version: [3.8] - steps: - - uses: actions/checkout@v4 - - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: test - python-version: ${{ matrix.python-version }} - fetch-depth: 2 - - name: Install dependencies - shell: bash -el {0} - run: | - python -m pip install --upgrade pip - conda install --yes -c conda-forge mpi4py openmpi - - name: Install HNN-core - shell: bash -el {0} - run: | - pip install --verbose '.[opt, parallel, test, gui]' - - name: Lint with flake8 - shell: bash -el {0} - run: | - flake8 --count hnn_core - - name: Test with pytest - shell: bash -el {0} - run: | - python -m pytest ./hnn_core/tests/ --cov=hnn_core --cov-report=xml - - name: Upload coverage to Codecov - shell: bash -el {0} - run: | - bash <(curl -s https://codecov.io/bash) -f ./coverage.xml \ No newline at end of file + steps: + - uses: actions/checkout@4 + + - name: Install Ubuntu System dependencies + if: matrix.os == 'ubuntu-latest' + shell: bash -el {0} + run: | + sudo add-apt-repository ppa:ubuntu-toolchain-r/test + sudo apt-get update + sudo apt-get install libopenmpi-dev openmpi-bin + + - name: Activate conda environment for macOS + if: matrix.os == 'macos-latest' + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: test + python-version: ${{ matrix.python-version }} + fetch-depth: 2 + + - name: Activate Python environment for Ubuntu + if: matrix.os == 'ubuntu-latest' + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Python dependencies + shell: bash -el {0} + run: | + if [ ${{ matrix.os }} == 'macos-latest' ]; then + python -m pip install --upgrade pip + conda install --yes -c conda-forge mpi4py openmpi + elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then + python -m pip install --upgrade pip + python -m pip install mpi4py + fi + - name: Install HNN-core + shell: bash -el {0} + run: | + pip install --verbose '.[opt, parallel, test, gui]' + - name: Lint with flake8 + shell: bash -el {0} + run: | + flake8 --count hnn_core + - name: Test with pytest + shell: bash -el {0} + run: | + python -m pytest ./hnn_core/tests/ --cov=hnn_core --cov-report=xml + - name: Upload coverage to Codecov + shell: bash -el {0} + run: | + bash <(curl -s https://codecov.io/bash) -f ./coverage.xml \ No newline at end of file