Skip to content

Commit 0249493

Browse files
committed
Use conda-lock to create test environments
1 parent 83cb28c commit 0249493

12 files changed

+12695
-3
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
push:
77
branches: [main]
88

9+
defaults:
10+
run:
11+
# Ensure activation for micromamba
12+
shell: bash -leo pipefail {0} {0}
13+
914
jobs:
1015
lint:
1116
runs-on: ubuntu-latest
@@ -30,10 +35,12 @@ jobs:
3035

3136
steps:
3237
- uses: actions/checkout@v3
33-
- name: Set up Python
34-
uses: actions/setup-python@v3
38+
- uses: mamba-org/setup-micromamba@v1
3539
with:
36-
python-version: ${{ matrix.python-version }}
40+
micromamba-version: 1.5.5-0
41+
environment-file: conda/conda-lock-${{ matrix.python-version }}.yaml
42+
environment-name: causalpy-test-${{ matrix.python-version }}
43+
cache-environment: true
3744
- name: Run doctests
3845
run: |
3946
pip install -e .[test]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Update lockfile
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# At 06:12 UTC on Monday
7+
- cron: 12 6 * * MON
8+
9+
jobs:
10+
conda-lock:
11+
strategy:
12+
matrix:
13+
python-version: ["3.8", "3.9", "3.10"]
14+
defaults:
15+
run:
16+
# Ensure the environment is activated
17+
# <https://github.com/mamba-org/setup-micromamba#about-login-shells>
18+
shell: bash -l {0}
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Install Conda environment with Micromamba
23+
uses: mamba-org/setup-micromamba@v1
24+
with:
25+
environment-file: conda/environment-conda-lock.yaml
26+
27+
- name: Run conda-lock
28+
run: |
29+
conda-lock lock --mamba \
30+
--extras test \
31+
--filter-extras \
32+
--file conda/environment-test-${{ matrix.python-version }}.yaml \
33+
--lockfile conda/conda-lock-${{ matrix.python-version }}.yaml
34+
35+
- name: Upload lockfile
36+
uses: actions/upload-artifact@v2
37+
with:
38+
name: conda-lock-${{ matrix.python-version }}.yaml
39+
path: conda/conda-lock-${{ matrix.python-version }}.yaml
40+
41+
open-pr:
42+
needs: conda-lock
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout repo
46+
uses: actions/checkout@v4
47+
- name: Download all lockfiles
48+
uses: actions/download-artifact@v2
49+
with:
50+
name: conda-lock-*.yaml
51+
path: conda
52+
- name: Open a pull request
53+
uses: peter-evans/create-pull-request@v5
54+
with:
55+
# This PAT should have read-write permissions for "Pull Requests"
56+
# and read-write permissions for "Contents".
57+
token: ${{ secrets.GH_PAT_FOR_PR }}
58+
commit-message: Relock dependencies
59+
title: Relock dependencies
60+
body: >
61+
This pull request relocks the dependencies with conda-lock.
62+
It was created automatically with the GitHub Action
63+
[update-lockfile.yml](.github/workflows/update-lockfile.yml).
64+
branch: relock-deps
65+
labels: conda-lock
66+
delete-branch: true
67+
committer: update-lockfile.yml <nobody@pymc-labs.com>
68+
author: update-lockfile.yml <nobody@pymc-labs.com>

0 commit comments

Comments
 (0)