forked from tardis-sn/tardis
-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (146 loc) · 5.84 KB
/
tests.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# For more information about TARDIS pipelines, please refer to:
#
# https://tardis-sn.github.io/tardis/development/continuous_integration.html
name: tests
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
env:
CACHE_NUMBER: 0 # increase to reset cache manually
PYTEST_FLAGS: --tardis-refdata=${{ github.workspace }}/tardis-refdata --tardis-regression-data=${{ github.workspace }}/tardis-regression-data
--cov=tardis --cov-report=xml --cov-report=html
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
jobs:
build:
if: github.repository_owner == 'tardis-sn'
strategy:
matrix:
pip: [true, false]
label: [osx-64, linux-64]
include:
- label: osx-64
os: macos-latest
prefix: /Users/runner/miniconda3/envs/tardis
- label: linux-64
os: ubuntu-latest
prefix: /usr/share/miniconda3/envs/tardis
name: ${{ matrix.label }}-pip-${{ matrix.pip }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
if: matrix.pip == false
- name: Clone tardis-sn/tardis-refdata
uses: actions/checkout@v2
with:
repository: tardis-sn/tardis-refdata
path: tardis-refdata
lfs: false
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
working-directory: tardis-refdata
- name: Restore LFS cache
uses: actions/cache/restore@v3
id: lfs-cache-refdata
with:
path: tardis-refdata/.git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('tardis-refdata/.lfs-assets-id') }}-v1
- name: Git LFS Pull
run: git lfs pull
working-directory: tardis-refdata
if: steps.lfs-cache-refdata.outputs.cache-hit != 'true'
- name: Git LFS Checkout
run: git lfs checkout
working-directory: tardis-refdata
if: steps.lfs-cache-refdata.outputs.cache-hit == 'true'
- name: Save LFS cache if not found
# uses fake ternary
# for reference: https://github.com/orgs/community/discussions/26738#discussioncomment-3253176
if: ${{ steps.lfs-cache.outputs.cache-hit != 'true' && always() || false }}
uses: actions/cache/save@v3
id: lfs-cache-refdata-save
with:
path: tardis-refdata/.git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('tardis-refdata/.lfs-assets-id') }}-v1
- name: Clone tardis-sn/tardis-regression-data
uses: actions/checkout@v4
with:
repository: tardis-sn/tardis-regression-data
path: tardis-regression-data
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
working-directory: tardis-refdata
- name: Restore LFS cache
uses: actions/cache/restore@v3
id: lfs-cache-regression-data
with:
path: tardis-regression-data/.git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('tardis-regression-data/.lfs-assets-id') }}-v1
- name: Git LFS Pull
run: git lfs pull
working-directory: tardis-regression-data
if: steps.lfs-cache-regression-data.outputs.cache-hit != 'true'
- name: Git LFS Checkout
run: git lfs checkout
working-directory: tardis-regression-data
if: steps.lfs-cache-regression-data.outputs.cache-hit == 'true'
- name: Save LFS cache if not found
# uses fake ternary
# for reference: https://github.com/orgs/community/discussions/26738#discussioncomment-3253176
if: ${{ steps.lfs-cache.outputs.cache-hit != 'true' && always() || false }}
uses: actions/cache/save@v3
id: lfs-cache-regression-data-save
with:
path: tardis-regression-data/.git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('tardis-regression-data/.lfs-assets-id') }}-v1
- name: Setup environment
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: tardis
use-mamba: true
- name: Download Lock File
run: wget -q https://raw.githubusercontent.com/tardis-sn/tardis/master/conda-${{ matrix.label }}.lock
if: matrix.pip == true
- uses: actions/cache@v2
with:
path: ${{ matrix.prefix }}
key: conda-${{ matrix.label }}-${{ hashFiles('conda-${{ matrix.label }}.lock') }}-${{ env.CACHE_NUMBER }}
id: cache-conda
- name: Update environment
run: mamba update -n tardis --file conda-${{ matrix.label }}.lock
if: steps.cache-conda.outputs.cache-hit != 'true'
- name: Install package editable
run: |
pip install -e .
echo "TARDIS_PIP_PATH=tardis" >> $GITHUB_ENV
if: matrix.pip == false
- name: Install package git
run: pip install git+https://github.com/tardis-sn/tardis.git@${{ github.ref }}
if: matrix.pip == true
- name: Set pip path
if: matrix.pip == true
run: |
location_line=$(pip show tardis | grep -i -x "Location:.*")
directory_path=$(echo $location_line | awk -F " " '{print $2}')
echo "TARDIS_PIP_PATH=$directory_path" >> $GITHUB_ENV
- name: Set install path
if: matrix.pip == false
run: |
directory_path="."
echo "TARDIS_PIP_PATH=$directory_path" >> $GITHUB_ENV
- name: Run tests
run: pytest tardis ${{ env.PYTEST_FLAGS }}
working-directory: ${{ env.TARDIS_PIP_PATH }}
- name: Upload to Codecov
run: bash <(curl -s https://codecov.io/bash)