Skip to content

ci: extract inline scripts from all workflows into standalone testable files #755

Closed

Description

@diberry

Problem

GitHub Actions workflow YAML files should not contain inline JavaScript, Python, or PowerShell scripts. Inline scripts in workflows are:

  • Untestable — no way to unit test logic embedded in YAML
  • Hard to review — YAML + embedded code is noisy and error-prone
  • Hard to reuse — logic locked inside a specific workflow can't be shared

This was discovered during PR #753 review, where inline JS spam-scoring logic had to be extracted into scripts/comment-moderation.mjs with its own test file.

Proposed Convention

All workflow logic should live in standalone script files with their own tests:

  1. Scripts go in scripts/ (or a workflow-specific subdirectory)
  2. Tests go in test/ following existing vitest patterns
  3. Workflows use run: node scripts/my-script.mjs instead of actions/github-script with inline code
  4. Context is passed via environment variables (GITHUB_TOKEN, event data, etc.)

Scope

Audit all existing workflows in .github/workflows/ for inline scripts:

Acceptance Criteria

  • Zero inline script: blocks in workflow YAML files
  • All extracted scripts have corresponding test files
  • Workflows pass context via env vars, call scripts via run:
  • Existing CI behavior unchanged (no regressions)

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions