Skip to content

Commit ec67513

Browse files
committed
Add code formatting CI workflow
- Created new GitHub Actions workflow 'code-formatting.yml' that runs the formatting script - Workflow checks if code meets formatting standards and fails if any changes are needed - Updated pull_request.yml to include the new formatting check - Ensures PRs cannot be merged until code passes formatting checks
1 parent a02a30b commit ec67513

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

.github/workflows/code-formatting.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Code Formatting
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
formatting-check:
12+
name: Code Formatting Check
13+
runs-on: ubuntu-latest
14+
if: github.event.pull_request.draft == false
15+
env:
16+
ZENML_DEBUG: 1
17+
ZENML_ANALYTICS_OPT_IN: false
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.9'
26+
27+
- name: Install ruff
28+
run: pip install ruff
29+
30+
- name: Run formatting script
31+
run: bash scripts/format.sh
32+
33+
- name: Check for changes
34+
id: git-check
35+
run: |
36+
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT
37+
38+
- name: Fail if changes were made
39+
if: steps.git-check.outputs.changes == 'true'
40+
run: |
41+
echo "::error::Formatting check failed. Please run 'scripts/format.sh' locally and commit the changes."
42+
exit 1

.github/workflows/pull_request.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Spell Checking
1+
name: Pull Request Checks
22

33
on:
44
pull_request:
@@ -25,3 +25,7 @@ jobs:
2525
markdown-link-check:
2626
uses: ./.github/workflows/markdown-link-check.yml
2727
if: github.event.pull_request.draft == false
28+
29+
code-formatting-check:
30+
uses: ./.github/workflows/code-formatting.yml
31+
if: github.event.pull_request.draft == false

0 commit comments

Comments
 (0)