Skip to content

Commit bafa9d4

Browse files
Speed up CI: only build changed projects on push
1 parent 3e67f32 commit bafa9d4

4 files changed

Lines changed: 40 additions & 4 deletions

File tree

.github/workflows/anchor.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,17 @@ jobs:
5353
}
5454
5555
# Determine which projects to build and test
56-
if [[ "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "schedule" || "${{ steps.changes.outputs.workflow }}" == "true" ]]; then
56+
if [[ "${{ github.event_name }}" == "schedule" || "${{ steps.changes.outputs.workflow }}" == "true" ]]; then
57+
# Workflow file changed or schedule — build everything
5758
projects=$(get_projects)
59+
elif [[ "${{ github.event_name }}" == "push" ]]; then
60+
# On push, only build projects with changes since parent commit
61+
changed_files=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
62+
if [ -z "$changed_files" ]; then
63+
projects=$(get_projects)
64+
else
65+
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep anchor | sed 's#/anchor/.*#/anchor#g'; done | grep -vE "$ignore_pattern" | sort -u)
66+
fi
5867
elif [[ "${{ steps.changes.outputs.anchor }}" == "true" ]]; then
5968
changed_files=(${{ steps.changes.outputs.anchor_files }})
6069
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep anchor | sed 's#/anchor/.*#/anchor#g'; done | grep -vE "$ignore_pattern" | sort -u)

.github/workflows/native.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,17 @@ jobs:
5353
}
5454
5555
# Determine which projects to build and test
56-
if [[ "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "schedule" || "${{ steps.changes.outputs.workflow }}" == "true" ]]; then
56+
if [[ "${{ github.event_name }}" == "schedule" || "${{ steps.changes.outputs.workflow }}" == "true" ]]; then
57+
# Workflow file changed or schedule — build everything
5758
projects=$(get_projects)
59+
elif [[ "${{ github.event_name }}" == "push" ]]; then
60+
# On push, only build projects with changes since parent commit
61+
changed_files=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
62+
if [ -z "$changed_files" ]; then
63+
projects=$(get_projects)
64+
else
65+
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep native | sed 's#/native/.*#/native#g'; done | grep -vE "$ignore_pattern" | sort -u)
66+
fi
5867
elif [[ "${{ steps.changes.outputs.native }}" == "true" ]]; then
5968
changed_files=(${{ steps.changes.outputs.native_files }})
6069
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep native | sed 's#/native/.*#/native#g'; done | grep -vE "$ignore_pattern" | sort -u)

.github/workflows/pinocchio.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,17 @@ jobs:
5353
}
5454
5555
# Determine which projects to build and test
56-
if [[ "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "schedule" || "${{ steps.changes.outputs.workflow }}" == "true" ]]; then
56+
if [[ "${{ github.event_name }}" == "schedule" || "${{ steps.changes.outputs.workflow }}" == "true" ]]; then
57+
# Workflow file changed or schedule — build everything
5758
projects=$(get_projects)
59+
elif [[ "${{ github.event_name }}" == "push" ]]; then
60+
# On push, only build projects with changes since parent commit
61+
changed_files=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
62+
if [ -z "$changed_files" ]; then
63+
projects=$(get_projects)
64+
else
65+
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep pinocchio | sed 's#/pinocchio/.*#/pinocchio#g'; done | grep -vE "$ignore_pattern" | sort -u)
66+
fi
5867
elif [[ "${{ steps.changes.outputs.pinocchio }}" == "true" ]]; then
5968
changed_files=(${{ steps.changes.outputs.pinocchio_files }})
6069
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep pinocchio | sed 's#/pinocchio/.*#/pinocchio#g'; done | grep -vE "$ignore_pattern" | sort -u)

.github/workflows/quasar.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,17 @@ jobs:
5555
}
5656
5757
# Determine which projects to build and test
58-
if [[ "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "schedule" || "${{ steps.changes.outputs.workflow }}" == "true" ]]; then
58+
if [[ "${{ github.event_name }}" == "schedule" || "${{ steps.changes.outputs.workflow }}" == "true" ]]; then
59+
# Workflow file changed or schedule — build everything
5960
projects=$(get_projects)
61+
elif [[ "${{ github.event_name }}" == "push" ]]; then
62+
# On push, only build projects with changes since parent commit
63+
changed_files=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
64+
if [ -z "$changed_files" ]; then
65+
projects=$(get_projects)
66+
else
67+
projects=$(echo "$changed_files" | while read file; do dirname "$file" | grep quasar | sed 's#/quasar/.*#/quasar#g'; done | grep -vE "$ignore_pattern" | sort -u)
68+
fi
6069
elif [[ "${{ steps.changes.outputs.quasar }}" == "true" ]]; then
6170
changed_files=(${{ steps.changes.outputs.quasar_files }})
6271
projects=$(for file in "${changed_files[@]}"; do dirname "${file}" | grep quasar | sed 's#/quasar/.*#/quasar#g'; done | grep -vE "$ignore_pattern" | sort -u)

0 commit comments

Comments
 (0)