-
Notifications
You must be signed in to change notification settings - Fork 21
51 lines (47 loc) · 1.55 KB
/
CodeFormat.yml
File metadata and controls
51 lines (47 loc) · 1.55 KB
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
name: Code Format
on: [push]
permissions:
# needed to allow actions to create and delete old caches
actions: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4
- name: Check notebook outputs
id: notebooks
uses: ResearchSoftwareActions/EnsureCleanNotebooksAction@1.1
- name: Notebook check failed message
if: ${{ steps.notebooks.outcome == 'failure' }}
run: |
echo "::error::❌ Some Jupyter notebooks contain execution output or metadata."
echo "Please clear outputs before committing."
echo "To fix locally, open the notebook and use:"
echo " Kernel → Restart & Clear Output"
echo "Then save and commit."
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Black
run: pip install black
- name: Run Black
id: black
run: |
set -e
black --check --diff .
echo "✅ Code is formatted correctly!"
shell: bash
- name: Black check failed message
if: ${{ steps.black.outcome == 'failure' }}
run: |
echo "::error::❌ Black found formatting issues."
echo "To fix them locally, run in your MBM Python environment:"
echo ""
echo " black ."
echo ""
echo "Make sure to commit the changes after running Black."