Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use conda-lock to create test environments #281

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading