-
-
Notifications
You must be signed in to change notification settings - Fork 638
Open
Labels
Description
Problem
The exclude logic in our GitHub Actions workflows has a potential issue where conditional expressions can produce empty strings that won't match any matrix values:
exclude:
- ruby-version: ${{ github.event_name == 'pull_request' && github.ref \!= 'refs/heads/master' && '3.2' || '' }}
node-version: ${{ github.event_name == 'pull_request' && github.ref \!= 'refs/heads/master' && '20' || '' }}
dependency-level: ${{ github.event_name == 'pull_request' && github.ref \!= 'refs/heads/master' && 'minimum' || '' }}When the condition is false (e.g., on master branch), this produces empty strings ('') which won't match any actual matrix values. This makes the exclusion ineffective in those cases.
Impact
Currently, this works as intended on PRs (excludes minimum dependency tests). However, the logic is fragile and could cause issues if:
- Matrix values change
- Someone expects exclusions to work differently
- We add more conditional exclusions
Affected Files
.github/workflows/main.yml: Lines 55-58, 146-149.github/workflows/examples.yml: Lines 54-56
Proposed Solutions
Option 1: Use separate jobs with conditions
jobs:
test-latest:
# Always runs
test-minimum:
if: github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch'Option 2: Use conditional includes instead of excludes
include:
- ruby-version: '3.4'
node-version: '22'
dependency-level: 'latest'
- ${{ github.ref == 'refs/heads/master' && { ruby-version: '3.2', node-version: '20', dependency-level: 'minimum' } || {} }}Option 3: Use reusable workflows
Create separate workflow files for latest vs minimum dependency testing.
Priority
Medium - The current implementation works but is fragile and could break with future changes.
Related
Part of the CI reliability improvements from PR #1995.