Skip to content

Commit 50cd900

Browse files
committed
ci: filter usermod matrix to only build changed usermod directories
Instead of building every usermod with a library.json on each PR, use git diff to identify which usermods/ subdirectories were actually touched and intersect that with the known-good library.json list. This reduces CI time significantly for PRs that only modify one or two usermods (previously every PR triggered ~40 usermods × 4 chipsets). Also removes the unnecessary PlatformIO install from get_usermod_envs (the step only uses shell/jq, not pio) and adds fetch-depth: 0 to ensure the base branch is available for the diff.
1 parent e68bd2a commit 50cd900

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

.github/workflows/usermods.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,35 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v4
23-
- uses: actions/setup-python@v5
2423
with:
25-
python-version: '3.12'
26-
cache: 'pip'
27-
- name: Install PlatformIO
28-
run: pip install -r requirements.txt
29-
- name: Get default environments
24+
fetch-depth: 0
25+
- name: Get changed usermod environments
3026
id: envs
3127
run: |
32-
echo "usermods=$(find usermods/ -name library.json | xargs dirname | xargs -n 1 basename | jq -R | grep -v PWM_fan | grep -v BME68X_v2| grep -v pixels_dice_tray | jq --slurp -c)" >> $GITHUB_OUTPUT
28+
# Usermods whose directories changed in this PR
29+
changed=$(git diff --name-only origin/${{ github.base_ref }}...HEAD \
30+
| grep '^usermods/' | cut -d/ -f2 | sort -u || true)
31+
32+
# All usermods with a library.json (excluding known-incompatible ones)
33+
all=$(find usermods/ -name library.json \
34+
| xargs dirname | xargs -n 1 basename \
35+
| grep -v PWM_fan | grep -v BME68X_v2 | grep -v pixels_dice_tray \
36+
| sort || true)
37+
38+
if [ -z "$changed" ] || [ -z "$all" ]; then
39+
echo "usermods=[]" >> $GITHUB_OUTPUT
40+
else
41+
usermods=$(comm -12 <(echo "$all") <(echo "$changed") | jq -R | jq --slurp -c)
42+
echo "usermods=$usermods" >> $GITHUB_OUTPUT
43+
fi
3344
outputs:
3445
usermods: ${{ steps.envs.outputs.usermods }}
3546

3647

3748
build:
3849
# Only run for pull requests from forks (not from branches within wled/WLED)
39-
if: github.event.pull_request.head.repo.full_name != github.repository
50+
# Skip when no changed usermods were found (e.g. only non-library changes)
51+
if: github.event.pull_request.head.repo.full_name != github.repository && needs.get_usermod_envs.outputs.usermods != '[]'
4052
name: Build Enviornments
4153
runs-on: ubuntu-latest
4254
needs: get_usermod_envs

0 commit comments

Comments
 (0)