Minimize workflow complexity

Keep GitHub Actions workflows efficient and maintainable by eliminating redundant configurations and ensuring comprehensive test coverage: 1. **Avoid redundant environment variables** - Use the minimum number of variables needed to achieve your workflow goals. When one variable can be derived from another, don't store both.

copy reviewer prompt

Prompt

Reviewer Prompt

Keep GitHub Actions workflows efficient and maintainable by eliminating redundant configurations and ensuring comprehensive test coverage:

  1. Avoid redundant environment variables - Use the minimum number of variables needed to achieve your workflow goals. When one variable can be derived from another, don’t store both.

Example refactoring:

# Not recommended
- name: Filter files
  run: |
    YAML_JSON_FILES=$(echo $ | grep -E '\.ya?ml$|\.json$')
    echo "YAML_JSON_FILES=$YAML_JSON_FILES" >> "$GITHUB_ENV"
    echo "RELEVANT_FILES_CHANGED=true" >> "$GITHUB_ENV"

# Recommended
- name: Filter files
  run: |
    YAML_JSON_FILES=$(echo $ | grep -E '\.ya?ml$|\.json$')
    echo "YAML_JSON_FILES=$YAML_JSON_FILES" >> "$GITHUB_ENV"
    
- name: Next step
  if: env.YAML_JSON_FILES != ''
  # Use YAML_JSON_FILES directly instead of a redundant flag
  1. Define comprehensive test matrices - Ensure matrix strategies include all relevant versions of languages, tools, or environments needed for thorough testing.
# Not recommended
strategy:
  matrix:
    python: ["3.8"]  # Incomplete coverage

# Recommended
strategy:
  matrix:
    python: ["3.8", "3.9", "3.10", "3.11"]  # Complete coverage

Keeping workflows streamlined improves maintainability, reduces debugging time, and makes your CI processes more reliable.

Source discussions