-
Notifications
You must be signed in to change notification settings - Fork 40
129 lines (113 loc) · 4.83 KB
/
python-package-conda.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
name: Run Jupyter Notebooks
on:
push:
branches:
- main
schedule:
- cron: '0 0 * * 0' # Runs once a week on Sunday at midnight
concurrency:
group: run-notebooks-${{ github.ref }}
cancel-in-progress: true
jobs:
run-notebooks:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
folder: [PM1, PM2, PM3, PM4, PM5, CM1, CM2, CM3, AC1, AC2, T]
steps:
- name: Checkout repository
if: "! (matrix.folder == 'CM3' && (matrix.os == 'windows-latest' || matrix.os == 'macos-latest'))"
uses: actions/checkout@v2
- name: Install git
if: "! (matrix.folder == 'CM3' && (matrix.os == 'windows-latest' || matrix.os == 'macos-latest'))"
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update
sudo apt-get install -y git
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install git
elif [ "$RUNNER_OS" == "Windows" ]; then
choco install git -y --no-progress || powershell -Command "Start-Sleep -Seconds 30; choco install git -y --no-progress"
fi
shell: bash
- name: Install libgraphviz-dev if folder is CM3
if: matrix.folder == 'CM3' && matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y libgraphviz-dev
shell: bash
- name: Install R if folder is CM3
if: matrix.folder == 'CM3' && matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y r-base
shell: bash
- name: Set up Python
if: "! (matrix.folder == 'CM3' && (matrix.os == 'windows-latest' || matrix.os == 'macos-latest'))"
uses: actions/setup-python@v2
with:
python-version: '3.10' # Use Python 3.10
- name: Install dependencies
if: "! (matrix.folder == 'CM3' && (matrix.os == 'windows-latest' || matrix.os == 'macos-latest'))"
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install jupyter nbconvert flake8 flake8-nb ipython
shell: bash
- name: Run Flake8 linting on notebooks
if: "! (matrix.folder == 'CM3' && (matrix.os == 'windows-latest' || matrix.os == 'macos-latest'))"
id: lint
run: |
mkdir -p linting_logs
flake8_errors=0
for notebook in ${{ matrix.folder }}/*.ipynb; do
[ "$(basename "$notebook")" = "python-dosearch.ipynb" ] && continue
flake8-nb --config=.flake8 "$notebook" > "linting_logs/$(basename "$notebook" .ipynb)_linting.txt" 2>&1 || flake8_errors=$((flake8_errors+1))
done
echo "flake8_errors=$flake8_errors" >> $GITHUB_ENV
shell: bash
- name: Convert Jupyter notebooks to Python scripts
if: "! (matrix.folder == 'CM3' && (matrix.os == 'windows-latest' || matrix.os == 'macos-latest'))"
id: convert
run: |
mkdir -p converted_scripts
for notebook in ${{ matrix.folder }}/*.ipynb; do
[ -e "$notebook" ] || continue
jupyter nbconvert --to script "$notebook" --output-dir converted_scripts
done
shell: bash
- name: Run converted Python scripts with IPython
if: "! (matrix.folder == 'CM3' && (matrix.os == 'windows-latest' || matrix.os == 'macos-latest'))"
id: execute
run: |
mkdir -p logs
script_errors=0
for script in converted_scripts/*.py; do
[ -e "$script" ] || continue
echo "Running $script"
ipython "$script" > "logs/$(basename "$script" .py).txt" 2>&1 || script_errors=$((script_errors+1))
done
echo "script_errors=$script_errors" >> $GITHUB_ENV
shell: bash
- name: Aggregate and report errors and warnings
if: "! (matrix.folder == 'CM3' && (matrix.os == 'windows-latest' || matrix.os == 'macos-latest'))"
run: |
echo "Aggregating errors and warnings..."
grep -E "Traceback|Error:|Exception:|ModuleNotFoundError|FutureWarning|TypeError" logs/*.txt linting_logs/*.txt > logs/errors_and_warnings.txt || true
echo "Errors and Warnings:"
cat logs/errors_and_warnings.txt
shell: bash
- name: Upload linting logs
if: "! (matrix.folder == 'CM3' && (matrix.os == 'windows-latest' || matrix.os == 'macos-latest'))"
uses: actions/upload-artifact@v2
with:
name: linting-logs-${{ matrix.folder }}
path: linting_logs
- name: Upload execution logs
if: "! (matrix.folder == 'CM3' && (matrix.os == 'windows-latest' || matrix.os == 'macos-latest'))"
uses: actions/upload-artifact@v2
with:
name: execution-logs-${{ matrix.folder }}
path: logs
- name: Check for errors
if: "! (matrix.folder == 'CM3' && (matrix.os == 'windows-latest' || matrix.os == 'macos-latest')) && (env.flake8_errors != '0' || env.script_errors != '0')"
run: exit 1