Skip to content

Commit

Permalink
Use conda-lock to create test environments
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb committed Dec 18, 2023
1 parent 83cb28c commit b92084f
Show file tree
Hide file tree
Showing 11 changed files with 9,626 additions and 3 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
push:
branches: [main]

defaults:
run:
# Ensure activation for micromamba
shell: bash -leo pipefail {0} {0}

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -30,10 +35,18 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- name: Rename lockfile
run: |
mv conda/conda-lock-${{ matrix.python-version }}.yaml conda/conda-lock.yml
- uses: mamba-org/setup-micromamba@v1
with:
python-version: ${{ matrix.python-version }}
micromamba-version: 1.5.5-0
environment-file: conda/conda-lock.yml
environment-name: causalpy-test-${{ matrix.python-version }}
cache-environment: true
create-args: >-
--category main
--category dev
- name: Run doctests
run: |
pip install -e .[test]
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/update-lockfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Update lockfile

on:
workflow_dispatch:
schedule:
# At 06:12 UTC on Monday
- cron: 12 6 * * MON

jobs:
conda-lock:
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
defaults:
run:
# Ensure the environment is activated
# <https://github.com/mamba-org/setup-micromamba#about-login-shells>
shell: bash -l {0}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: conda/environment-conda-locker.yaml
environment-name: conda-lock-env
cache-environment: true

- name: Run conda-lock
run: |
conda-lock lock --mamba \
--extras test \
--filter-extras \
--file pyproject.toml \
--file conda/environment-test-${{ matrix.python-version }}.yaml \
--lockfile conda/conda-lock-${{ matrix.python-version }}.yaml
- name: Upload lockfile
uses: actions/upload-artifact@v4
with:
name: lockfile-${{ matrix.python-version }}
path: conda/conda-lock-${{ matrix.python-version }}.yaml

open-pr:
needs: conda-lock
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Download all lockfiles
uses: actions/download-artifact@v4
with:
path: /tmp/conda
- name: Replace existing lockfiles with downloaded ones
run: |
mv /tmp/conda/lockfile-*/* conda/
- name: Open a pull request
uses: peter-evans/create-pull-request@v5
with:
# This PAT should have read-write permissions for "Pull Requests"
# and read-write permissions for "Contents".
token: ${{ secrets.GH_PAT_FOR_PR }}
commit-message: Relock dependencies
title: Relock dependencies
body: >
This pull request relocks the dependencies with conda-lock.
It was created automatically with the GitHub Action
[update-lockfile.yml](.github/workflows/update-lockfile.yml).
branch: relock-deps
labels: conda-lock
delete-branch: true
committer: update-lockfile.yml <[email protected]>
author: update-lockfile.yml <[email protected]>
Loading

0 comments on commit b92084f

Please sign in to comment.