Files
tree-sitter-shellspec/.serena/memories/github_workflows_optimization_2025.md
Ismo Vuorinen ccb9121b89 fix: resolve documentation inconsistencies and add ExampleGroup variants
Documentation Fixes:
- README.md: Update test count from 59 to 63 (badge, features, test command)
- README.md: Fix lint script references to actual npm scripts
- CONTRIBUTING.md: Correct format script reference to npm run format:check
- package.json: Remove non-existent yamllint script, split lint:markdown into check/fix variants

Grammar Enhancements:
- Add fExampleGroup and xExampleGroup to Context block variants
- Regenerate parser with new grammar (63/63 tests passing, 100% success rate)

Syntax Highlighting:
- Add fExampleGroup and xExampleGroup to focused/skipped block highlights
- Remove non-matching Data modifier tokens (:raw, :expand, #|)
- Add "End" keyword as block terminator

Memory File Corrections:
- Remove incorrect merge_group trigger references
- Remove pr-lint.yml workflow references (deleted in previous optimization)
- Update test counts with timestamps (59→63, added 2025-12-11)
- Update conflict count (13→5, optimized)

Code Style:
- Auto-format renovate.json and tree-sitter.json with prettier
2026-01-04 15:33:00 +02:00

6.9 KiB

GitHub Workflows Optimization (2025)

Problem Analysis

The project had significant duplication in GitHub Actions workflows, causing unnecessary resource consumption and longer execution times.

Original Issues Identified

1. Critical Duplication - Linting (3x redundancy)

  • test.yml: Ran linting in lint job
  • pr-lint.yml: Ran identical linting with same action (ivuorinen/actions/pr-lint)
  • release.yml: Ran identical linting again in lint job
  • Impact: Same linting executed 3 times for every PR + push event

2. High Duplication - Test Suite (2x redundancy)

  • test.yml: Full test suite with matrix (Node 22, 24)
  • release.yml: Identical test suite with same matrix
  • Impact: 4 test jobs (2x2 matrix) running twice on every main branch push

3. Medium Duplication - Environment Setup

  • Multiple workflows using ./.github/actions/setup-dev and ./.github/actions/setup-node
  • Same Node.js setup repeated across jobs

4. Trigger Overlap

  • Both test.yml and pr-lint.yml triggering on push/PR to main
  • merge_group trigger in multiple workflows causing additional runs

Optimization Implementation

1. Consolidated Main CI Workflow

File: .github/workflows/test.yml → Renamed to "CI"

  • Purpose: Single source of truth for all continuous integration
  • Triggers: push, pull_request to main/master
  • Jobs: test (matrix), lint, coverage
  • Result: Eliminated duplicate linting, maintained full functionality

2. Removed Redundant Workflow

Action: Deleted .github/workflows/pr-lint.yml

  • Reason: Identical functionality already covered by CI workflow
  • Impact: Eliminated 1 runner job per PR/push event

3. Optimized Release Workflow

File: .github/workflows/release.yml Changes:

  • Removed: Duplicate test and lint jobs
  • Added: check-ci job that verifies CI workflow passed
  • Logic: Only proceed with release if CI already passed for the commit
  • Dependencies: needs: [validate, check-ci, security] (was [validate, test, lint, security])

Technical Implementation:

check-ci:
  name: ✅ Verify CI Status
  steps:
    - name: 📋 Check CI Workflow Status
      uses: actions/github-script@e1ec48de9e3eaf9b93b1c5f88eaf97ae19d7b7bb
      with:
        script: |
          const { data: workflows } = await github.rest.actions.listWorkflowRuns({
            owner: context.repo.owner,
            repo: context.repo.repo,
            workflow_id: 'test.yml',
            head_sha: context.sha,
            status: 'completed'
          });

          const latestRun = workflows.workflow_runs[0];
          if (!latestRun || latestRun.conclusion !== 'success') {
            core.setFailed('CI workflow has not passed for this commit');
          }

4. Reduced Trigger Scope

Files: codeql.yml, sync-labels.yml Change: Removed merge_group trigger Reason: CI workflow already covers merge group testing Impact: Fewer unnecessary runs on merge queue events

Resource Savings Analysis

Before Optimization

Per PR/Push to main:

  • CI Jobs: 4 (test matrix 2x2)
  • Linting Jobs: 3 (test.yml + pr-lint.yml + potential release)
  • Total Runner Minutes: ~45-60 minutes
  • Redundant Executions: High

Per Release:

  • Test Jobs: 2 (CI + Release duplicate)
  • Lint Jobs: 2 (CI + Release duplicate)
  • Setup Jobs: Multiple redundant setups
  • Total Runner Minutes: ~30-45 minutes

After Optimization

Per PR/Push to main:

  • CI Jobs: 4 (test matrix 2x2)
  • Linting Jobs: 1 (consolidated in CI)
  • Total Runner Minutes: ~15-20 minutes
  • Redundant Executions: Eliminated

Per Release:

  • Test Jobs: 0 (relies on CI status check)
  • Lint Jobs: 0 (relies on CI status check)
  • Setup Jobs: Minimal (only for release-specific tasks)
  • Total Runner Minutes: ~5-10 minutes

Resource Reduction Summary

  • Linting: 67% reduction (3 → 1 job per event)
  • Testing: 50% reduction for releases (eliminated duplicate test matrix)
  • Overall Runtime: ~60% reduction in total runner minutes
  • Complexity: Simplified workflow dependencies and logic

Current Workflow Structure

1. CI Workflow (test.yml)

  • Triggers: push, pull_request, merge_group
  • Jobs: test (Node 22,24), lint, coverage
  • Purpose: Primary quality gate for all code changes

2. Release Workflow (release.yml)

  • Triggers: tags (v*.*.*), manual dispatch
  • Jobs: validate, check-ci, security, release
  • Purpose: Streamlined release process with CI dependency

3. Security Workflows

  • CodeQL: push/PR analysis + weekly scans
  • Release Security: npm audit before release

4. Maintenance Workflows

  • Stale: Daily cleanup of old issues/PRs
  • Sync Labels: Daily label synchronization

Quality Assurance

Validation Steps Taken

  1. YAML Syntax: All workflows pass yamllint validation
  2. Action References: Verified all custom actions exist (.github/actions/*)
  3. Dependency Logic: Confirmed workflow dependencies are correctly structured
  4. Trigger Coverage: Ensured all necessary events still trigger appropriate workflows

Risk Mitigation

  1. CI Status Check: Release workflow validates CI passed before proceeding
  2. Fallback Options: Manual workflow dispatch available for releases
  3. Security Maintained: All security scanning workflows preserved
  4. Concurrency Controls: Proper concurrency groups prevent resource conflicts

Future Optimization Opportunities

Potential Further Improvements

  1. Conditional Jobs: Skip certain jobs based on file changes (e.g., skip tests if only docs changed)
  2. Caching Optimization: Enhanced npm/node_modules caching across workflows
  3. Matrix Reduction: Consider reducing Node.js versions (keep only LTS + latest)
  4. Parallel Security: Run security scans in parallel with CI rather than in release

Monitoring Recommendations

  1. Track Runner Usage: Monitor GitHub Actions usage metrics
  2. Performance Metrics: Measure workflow completion times
  3. Failure Analysis: Ensure optimization doesn't increase failure rates
  4. Cost Analysis: Evaluate runner minute consumption reduction

Implementation Impact

Immediate Benefits

  • Faster CI: Reduced redundant executions
  • Cleaner Logs: Simplified workflow status
  • Resource Efficiency: ~60% reduction in runner minutes
  • Maintainability: Consolidated logic, fewer files to manage

Maintained Capabilities

  • Quality Gates: All testing and linting preserved
  • Security: Full security scanning maintained
  • Release Process: Streamlined but complete release pipeline
  • Development Workflow: No impact on developer experience

The optimization successfully eliminated redundant workflow executions while maintaining all quality assurance and automation capabilities, resulting in significant resource savings and improved CI/CD efficiency.