Skip to content

Commit 19036b5

Browse files
committed
Stop early if no relevant changes
1 parent a5276b6 commit 19036b5

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

.github/workflows/python-package.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ concurrency:
2424

2525
jobs:
2626
build:
27-
2827
runs-on: ${{ matrix.os }}
2928
strategy:
3029
fail-fast: false
@@ -33,6 +32,28 @@ jobs:
3332
python-version: ["3.9", "3.10", "3.11"]
3433
steps:
3534
- uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0 # Required to get full history for diff
37+
- name: Check for relevant file changes
38+
id: changes
39+
run: |
40+
echo "Changed files:"
41+
git fetch origin main
42+
CHANGED_FILES=$(git diff --name-only origin/main...HEAD)
43+
echo "$CHANGED_FILES"
44+
45+
MATCH=$(echo "$CHANGED_FILES" | grep -E '^flaml/|^test/|^notebook/|^setup.py|^\.github/workflows/python-package.yml' || true)
46+
47+
if [ -z "$MATCH" ]; then
48+
echo "No relevant changes detected. Skipping build."
49+
echo "skip=true" >> $GITHUB_OUTPUT
50+
else
51+
echo "Relevant changes detected. Proceeding with build."
52+
echo "skip=false" >> $GITHUB_OUTPUT
53+
fi
54+
- name: Stop early if no relevant changes
55+
if: steps.changes.outputs.skip == 'true'
56+
run: echo "Skipping rest of the build job." && exit 0
3657
- name: Set up Python ${{ matrix.python-version }}
3758
uses: actions/setup-python@v5
3859
with:

0 commit comments

Comments
 (0)