-
Notifications
You must be signed in to change notification settings - Fork 5
60 lines (48 loc) · 1.41 KB
/
python-package-conda-cache.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Python Package with caching
# taken from https://github.com/epassaro/cache-conda-envs
# cancel any previous running or pending jobs from the same branch
concurrency:
group: python-package-conda-cache-${{ github.head_ref }}
cancel-in-progress: true
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
env:
CACHE_NUMBER: 0 # increase to reset cache manually
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
label: linux-64
prefix: /usr/share/miniconda3/envs/my-env
name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup Miniforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-version: latest
activate-environment: my-env
- name: Set cache date
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
- uses: actions/cache@v2
with:
path: ${{ matrix.prefix }}
key: ${{ matrix.label }}-conda-${{ hashFiles('environment.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
id: cache
- name: Update environment
run: conda env update -n my-env -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Run tests
shell: bash -l {0}
run: pytest ./tests