-
Notifications
You must be signed in to change notification settings - Fork 15
92 lines (76 loc) · 2.75 KB
/
CI.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
name: CI
on: [push, pull_request]
env:
PYTEST_ADDOPTS: --color=yes
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
# lstchain dependency
python-version: ['3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
. $CONDA/etc/profile.d/conda.sh
conda config --set always_yes yes --set changeps1 no
sed -i -e "s/- python=.*/- python=$PYTHON_VERSION/g" environment.yml
echo "Creating conda env"
conda env create -n ci -f environment.yml
conda activate ci
echo "Installing additional pip packages"
pip install \
pytest-cov \
pyflakes
echo "pip install ."
pip install .
- name: Static codechecks
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate ci
pyflakes lstmcpipe
- name: Download test data
env:
TEST_DATA_USER: ${{ secrets.TEST_DATA_USER }}
TEST_DATA_PASSWORD: ${{ secrets.TEST_DATA_PASSWORD }}
run: |
./download_test_data.sh
- name: Tests
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate ci
pytest --cov=lstmcpipe --cov-report=xml lstmcpipe
- uses: codecov/codecov-action@v1
- name: Detect added configs
uses: tj-actions/changed-files@v39
id: verify-changed-files
with:
files: |
production_configs/*/*.yml
production_configs/*/*.yaml
# production_configs/*/*.json
# TODO: solve issue in github actions extracting sublist of yaml files, see below
- name: Validate added configs.
if: steps.verify-changed-files.outputs.any_changed == 'true'
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate ci
export filelist="${{ steps.verify-changed-files.outputs.all_changed_files }}"
# export filelist=`grep -P '\.yaml$|\.yml$' <<< ${filelist[*]}`
# the above line works on ubuntu but fails on github action, not following the given pattern
echo "Added yaml files: $filelist"
for file in $filelist; do
echo "Checking $file";
echo "lstmcpipe_validate_config $file -lc `dirname $file`/*lstchain*.json"
lstmcpipe_validate_config $file -lc `dirname $file`/*lstchain*.json ;
echo "Valid!";
done