From c490e50922e66ceb4d4b04181ec3b5f2cc28f765 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Fri, 22 Mar 2024 15:50:35 +0100 Subject: [PATCH] Switch to setup-micromamba action --- .github/workflows/pre-commit.yml | 44 ++----- .github/workflows/tests.yml | 200 ++++++------------------------- 2 files changed, 45 insertions(+), 199 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index cf37ccc779c..125bf51287b 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -5,6 +5,9 @@ on: push: branches: [main] +defaults: + run: + shell: bash -leo pipefail {0} jobs: pre-commit: runs-on: ubuntu-latest @@ -18,50 +21,21 @@ jobs: - uses: pre-commit/action@v3.0.1 mypy: runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - name: Cache conda - uses: actions/cache@v4 - env: - # Increase this value to reset cache if environment-test.yml has not changed - CACHE_NUMBER: 0 + - uses: mamba-org/setup-micromamba@v1 with: - path: ~/conda_pkgs_dir - key: ${{ runner.os }}-py39-conda-${{ env.CACHE_NUMBER }}-${{ - hashFiles('conda-envs/environment-test.yml') }} - - name: Cache multiple paths - uses: actions/cache@v4 - env: - # Increase this value to reset cache if requirements.txt has not changed - CACHE_NUMBER: 0 - with: - path: | - ~/.cache/pip - $RUNNER_TOOL_CACHE/Python/* - ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{ - hashFiles('requirements.txt') }} - - uses: conda-incubator/setup-miniconda@v2 - with: - miniforge-variant: Mambaforge - miniforge-version: latest - mamba-version: "*" - activate-environment: pymc-test - channel-priority: strict environment-file: conda-envs/environment-test.yml - python-version: "3.9" # Run pre-commit on oldest supported Python version - use-mamba: true - use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267 + create-args: >- + python=3.9 + environment-name: pymc-test + init-shell: bash + cache-environment: true - name: Install-pymc and mypy dependencies run: | - conda activate pymc-test pip install -e . pip install --pre -U polyagamma python --version - name: Run mypy run: | - conda activate pymc-test python ./scripts/run_mypy.py --verbose diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a735feccbb4..21c2edaf80e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -127,50 +127,24 @@ jobs: PYTENSOR_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native' defaults: run: - shell: bash -l {0} + shell: bash -leo pipefail {0} steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - name: Cache conda - uses: actions/cache@v4 - env: - # Increase this value to reset cache if environment-test.yml has not changed - CACHE_NUMBER: 0 + - uses: mamba-org/setup-micromamba@v1 with: - path: ~/conda_pkgs_dir - key: ${{ runner.os }}-py${{matrix.python-version}}-conda-${{ env.CACHE_NUMBER }}-${{ - hashFiles('conda-envs/environment-test.yml') }} - - name: Cache multiple paths - uses: actions/cache@v4 - env: - # Increase this value to reset cache if requirements.txt has not changed - CACHE_NUMBER: 0 - with: - path: | - ~/.cache/pip - $RUNNER_TOOL_CACHE/Python/* - ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{ - hashFiles('requirements.txt') }} - - uses: conda-incubator/setup-miniconda@v2 - with: - miniforge-variant: Mambaforge - miniforge-version: latest - mamba-version: "*" - activate-environment: pymc-test - channel-priority: strict environment-file: conda-envs/environment-test.yml - python-version: ${{matrix.python-version}} - use-mamba: true - use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267 + create-args: >- + python=${{matrix.python-version}} + environment-name: pymc-test + init-shell: bash + cache-environment: true - name: Install-pymc run: | - conda activate pymc-test pip install -e . pip install --pre -U polyagamma python --version - name: Run tests run: | - conda activate pymc-test python -m pytest -vv --cov=pymc --cov-report=xml --no-cov-on-fail --cov-report term --durations=50 $TEST_SUBSET - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 @@ -201,44 +175,19 @@ jobs: PYTENSOR_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=core2' defaults: run: - shell: cmd + shell: cmd /C call {0} steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - name: Cache conda - uses: actions/cache@v4 - env: - # Increase this value to reset cache if conda-envs/windows-environment-test.yml has not changed - CACHE_NUMBER: 0 - with: - path: ~/conda_pkgs_dir - key: ${{ runner.os }}-py${{matrix.python-version}}-conda-${{ env.CACHE_NUMBER }}-${{ - hashFiles('conda-envs/windows-environment-test.yml') }} - - name: Cache multiple paths - uses: actions/cache@v4 - env: - # Increase this value to reset cache if requirements.txt has not changed - CACHE_NUMBER: 0 + - uses: mamba-org/setup-micromamba@v1 with: - path: | - ~/.cache/pip - $RUNNER_TOOL_CACHE/Python/* - ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{ - hashFiles('requirements.txt') }} - - uses: conda-incubator/setup-miniconda@v2 - with: - miniforge-variant: Mambaforge - miniforge-version: latest - mamba-version: "*" - activate-environment: pymc-test - channel-priority: strict - environment-file: conda-envs/windows-environment-test.yml - python-version: ${{matrix.python-version}} - use-mamba: true - use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267 + environment-file: conda-envs/environment-test.yml + create-args: >- + python=${{matrix.python-version}} + environment-name: pymc-test + init-shell: cmd.exe + cache-environment: true - name: Install-pymc run: | - conda activate pymc-test pip install -e . pip install --pre -U polyagamma python --version @@ -246,7 +195,6 @@ jobs: # This job uses a cmd shell, therefore the environment variable syntax is different! # The ">-" in the next line replaces newlines with spaces (see https://stackoverflow.com/a/66809682). run: >- - conda activate pymc-test && python -m pytest -vv --cov=pymc --cov-report=xml --no-cov-on-fail --cov-report term --durations=50 %TEST_SUBSET% - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 @@ -284,44 +232,19 @@ jobs: PYTENSOR_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native' defaults: run: - shell: bash -l {0} + shell: bash -leo pipefail {0} steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - name: Cache conda - uses: actions/cache@v4 - env: - # Increase this value to reset cache if environment-test.yml has not changed - CACHE_NUMBER: 0 + - uses: mamba-org/setup-micromamba@v1 with: - path: ~/conda_pkgs_dir - key: ${{ runner.os }}-py${{matrix.python-version}}-conda-${{ env.CACHE_NUMBER }}-${{ - hashFiles('conda-envs/environment-test.yml') }} - - name: Cache multiple paths - uses: actions/cache@v4 - env: - # Increase this value to reset cache if requirements.txt has not changed - CACHE_NUMBER: 0 - with: - path: | - ~/.cache/pip - $RUNNER_TOOL_CACHE/Python/* - ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{ - hashFiles('requirements.txt') }} - - uses: conda-incubator/setup-miniconda@v2 - with: - miniforge-variant: Mambaforge - miniforge-version: latest - mamba-version: "*" - activate-environment: pymc-test - channel-priority: strict environment-file: conda-envs/environment-test.yml - python-version: ${{matrix.python-version}} - use-mamba: true - use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267 + create-args: >- + python=${{matrix.python-version}} + environment-name: pymc-test + init-shell: bash + cache-environment: true - name: Install pymc run: | - conda activate pymc-test pip install -e . python --version - name: Run tests @@ -352,44 +275,19 @@ jobs: PYTENSOR_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native' defaults: run: - shell: bash -l {0} + shell: bash -leo pipefail {0} steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - name: Cache conda - uses: actions/cache@v4 - env: - # Increase this value to reset cache if environment-jax.yml has not changed - CACHE_NUMBER: 0 - with: - path: ~/conda_pkgs_dir - key: ${{ runner.os }}-py${{matrix.python-version}}-conda-${{ env.CACHE_NUMBER }}-${{ - hashFiles('conda-envs/environment-jax.yml') }} - - name: Cache multiple paths - uses: actions/cache@v4 - env: - # Increase this value to reset cache if requirements.txt has not changed - CACHE_NUMBER: 0 + - uses: mamba-org/setup-micromamba@v1 with: - path: | - ~/.cache/pip - $RUNNER_TOOL_CACHE/Python/* - ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{ - hashFiles('requirements.txt') }} - - uses: conda-incubator/setup-miniconda@v2 - with: - miniforge-variant: Mambaforge - miniforge-version: latest - mamba-version: "*" - activate-environment: pymc-test - channel-priority: strict environment-file: conda-envs/environment-jax.yml - python-version: ${{matrix.python-version}} - use-mamba: true - use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267 + create-args: >- + python=${{matrix.python-version}} + environment-name: pymc-test + init-shell: bash + cache-environment: true - name: Install pymc run: | - conda activate pymc-test pip install -e . python --version - name: Run tests @@ -420,44 +318,19 @@ jobs: PYTENSOR_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=core2' defaults: run: - shell: cmd + shell: cmd /C call {0} steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - name: Cache conda - uses: actions/cache@v4 - env: - # Increase this value to reset cache if conda-envs/windows-environment-test.yml has not changed - CACHE_NUMBER: 0 - with: - path: ~/conda_pkgs_dir - key: ${{ runner.os }}-py${{matrix.python-version}}-conda-${{ env.CACHE_NUMBER }}-${{ - hashFiles('conda-envs/windows-environment-test.yml') }} - - name: Cache multiple paths - uses: actions/cache@v4 - env: - # Increase this value to reset cache if requirements.txt has not changed - CACHE_NUMBER: 0 - with: - path: | - ~/.cache/pip - $RUNNER_TOOL_CACHE/Python/* - ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{ - hashFiles('requirements.txt') }} - - uses: conda-incubator/setup-miniconda@v2 + - uses: mamba-org/setup-micromamba@v1 with: - miniforge-variant: Mambaforge - miniforge-version: latest - mamba-version: "*" - activate-environment: pymc-test - channel-priority: strict environment-file: conda-envs/windows-environment-test.yml - python-version: ${{matrix.python-version}} - use-mamba: true - use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267 + create-args: >- + python=${{matrix.python-version}} + environment-name: pymc-test + init-shell: cmd.exe + cache-environment: true - name: Install-pymc run: | - conda activate pymc-test pip install -e . pip install --pre -U polyagamma python --version @@ -465,7 +338,6 @@ jobs: # This job uses a cmd shell, therefore the environment variable syntax is different! # The ">-" in the next line replaces newlines with spaces (see https://stackoverflow.com/a/66809682). run: >- - conda activate pymc-test && python -m pytest -vv --cov=pymc --cov-report=xml --no-cov-on-fail --cov-report term --durations=50 %TEST_SUBSET% - name: Upload coverage to Codecov uses: codecov/codecov-action@v4