Update python-package-conda.yml #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Jupyter Notebooks | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 0 * * 0' # Runs once a week on Sunday at midnight | |
jobs: | |
run-notebooks: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' # Adjust this to your preferred Python version | |
- name: Install dependencies | |
run: | | |
python3.8 -m pip install --upgrade pip | |
pip install jupyter nbconvert flake8 ipython | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
shell: bash | |
- name: Convert Jupyter notebooks to Python scripts | |
run: | | |
mkdir -p converted_scripts | |
for notebook in PM1/*.ipynb; do | |
[ -e "$notebook" ] || continue | |
jupyter nbconvert --to script "$notebook" | |
mv "${notebook%.ipynb}.py" converted_scripts/ | |
done | |
shell: bash | |
- name: Run Flake8 linting | |
run: | | |
mkdir -p linting_logs | |
for script in converted_scripts/*.py; do | |
[ -e "$script" ] || continue | |
flake8 "$script" > "linting_logs/$(basename "$script" .py)_linting.log" 2>&1 || true | |
done | |
shell: bash | |
- name: Run Python scripts with IPython | |
run: | | |
mkdir -p logs | |
for script in converted_scripts/*.py; do | |
[ -e "$script" ] || continue | |
echo "Running $script" | |
ipython "$script" > "logs/$(basename "$script" .py).log" 2>&1 || true | |
done | |
shell: bash | |
- name: Aggregate and report errors and warnings | |
run: | | |
echo "Aggregating errors and warnings..." | |
grep -E "Error|Warning" logs/*.log linting_logs/*.log > logs/errors_and_warnings.log || true | |
echo "Errors and Warnings:" | |
cat logs/errors_and_warnings.log | |
shell: bash | |
- name: Zip the Python scripts | |
run: | | |
zip -r converted_scripts.zip converted_scripts | |
shell: bash | |
- name: Upload the zip file | |
uses: actions/upload-artifact@v2 | |
with: | |
name: converted-scripts | |
path: converted_scripts.zip |