Repository navigation
feat(gitlab/migrate): GitHub Actions → GitLab CI/CD migration tool - #99
Merged
Merged
Conversation
Translate GitHub Actions workflow YAML into GitLab CI TemplateIR with
per-key provenance recorded in a side channel. The IR keeps a single
metadata.migration marker; per-property history (rule + category +
source location) is collected by ProvenanceAccumulator for downstream
SARIF/Markdown reporting.
Covers (literal translation, no marketplace-action registry yet):
- on: {push, pull_request, schedule, workflow_dispatch} -> workflow.rules
- jobs.* -> top-level jobs + Kahn-topo-sort stage inference
- runs-on: ubuntu-* -> image; macos/windows -> tags + needs-review
- env/timeout-minutes/continue-on-error/concurrency literal renames
- strategy.matrix -> parallel.matrix; matrix.include/exclude -> review
- if: conditions -> rules:[{if}] with github.* -> \$CI_* substitution
- always()/success()/failure() -> when: clauses
- needs: passthrough; permissions/outputs/reusable workflows -> review
Unknown uses: steps emit TODO + MIG-ACTION-UNKNOWN diagnostic
pending the ActionMapping registry (#87).
Adds @intentius/chant-lexicon-github as devDep and optional peer of
the gitlab lexicon. Runtime parser import is lazy so users who never
migrate don't pay the cost.
Tests: 58 across expressions, stages, transformer (all 8 syntax-
mapping categories from upstream skill).
Add `chant migrate <file>` as a top-level command that dispatches
through a new optional `migrationSource(from)` hook on LexiconPlugin.
The gitlab plugin implements migrationSource("github") returning a
{detect, transform} pair that lazy-imports the from-github transformer
landed in #85.
Migrate does NOT require a chant project context — the handler loads
the target lexicon explicitly by --to name (default: gitlab) so users
can pipe a .github/workflows/*.yml from anywhere.
New ParsedArgs fields: migrateFrom, migrateTo, emit, strict, validate,
useComposites, reportFile, skill. --report parsing is dual: bare flag
preserves the existing `run --report` boolean; --report <path> sets
reportFile for SARIF output (wired in #90).
Help text lists migrate in the primary commands block.
Tests: 6 unit tests for migrateCommand dispatch (missing target,
no migrate support, source not recognised, --output write, --strict
escalation on/off).
Adds typed ActionMapping registry and the 14 most-used GitHub Actions
marketplace mappings from the upstream skill's marketplace-actions.md
Tier 1 list:
- actions/checkout (skipped — GitLab auto-clones)
- actions/setup-{node,python,java,go,ruby} (image substitution)
- actions/cache (native cache: keyword)
- actions/upload-artifact (native artifacts: keyword)
- actions/download-artifact (no-op — auto-passed between stages)
- docker/login-action (inline docker login)
- docker/build-push-action (docker build/push + docker:dind service)
- docker/setup-buildx-action (docker buildx create + dind)
- docker/setup-qemu-action (tonistiigi/binfmt)
- actions/github-script (needs-review — use glab CLI or REST API)
Each ActionMapping returns scriptLines + optional image/services/
cache/artifacts/variables effects + provenance records. Registry
exposes register/lookup with optional major-version filter.
Tier 1 auto-registers when from-github/index.ts is imported (single
chokepoint). Unknown actions still emit MIG-ACTION-UNKNOWN diagnostic.
Tests: 17 unit tests on tier-1 mappings + updated transformer test
asserting actions/checkout now categorises as "skipped" not "unknown".
Adds 19 marketplace action mappings from the upstream skill's tier-2 and tier-3 lists. Tier 3 actions that map to native GitLab keywords (dorny/paths-filter → rules:changes:, nick-fields/retry → retry:) emit a needs-review comment block rather than a script substitute, since the equivalent must be configured at job level. Tier 2 (14): - actions/setup-dotnet, shivammathur/setup-php, oven-sh/setup-bun, pnpm/action-setup, gradle/gradle-build-action, cypress-io/github- action: image substitution - aws-actions/configure-aws-credentials, google-github-actions/auth, azure/login: needs-review with CI/CD variable scaffolding - hashicorp/setup-terraform: hashicorp/terraform image - codecov/codecov-action: codecov-cli script - softprops/action-gh-release, peter-evans/create-pull-request: glab CLI invocations - JamesIves/github-pages-deploy-action: public/ artifact prep Tier 3 (5): - tj-actions/changed-files: git diff inline - dorny/paths-filter, nick-fields/retry: needs-review with hint to use native rules:changes: / retry: keyword - pre-commit/action: pip install + pre-commit run - slackapi/slack-github-action: curl to $SLACK_WEBHOOK_URL All three tiers now auto-register when from-github/index is imported. Tests: 20 unit tests covering all 19 mappings + registry coverage.
…ll (#98) Lifts before/after pairs from the upstream skill's references/ syntax-mapping.md and references/marketplace-actions.md into a fixture tree: fixtures/ syntax-mapping/ 01-triggers, 02-stages-needs, 03-matrix, 04-env-secrets, 05-conditional, 06-services, 07-job-control, 08-workflow-name marketplace-actions/ tier-1/{actions-checkout, actions-setup-node, actions-setup- python, docker-build-push, upload-download-artifact} tier-2/{codecov-action, setup-bun} tier-3/{paths-filter} Each fixture is `input.yml` + `expected.gitlab-ci.yml` + `expected-report.json` (shape — totals + ruleIds + needsReview line pairs + action mappings). The shape assertion is stable across cosmetic provenance message changes; raw SARIF would drift on every note edit. `fixtures.test.ts` globs the tree and asserts canonicalised YAML equality on output + deep equality on report shape. Adding a new fixture is just "drop three files in a new directory"; no manifest. Attribution lands at lexicons/gitlab/ATTRIBUTIONS.md citing the upstream skill's MIT license. fixtures/README.md documents the convention. Tests: 16 fixture-driven cases pass; full suite green.
When --emit ts is passed, run the existing GitLabGenerator over the GitLab IR and emit chant TypeScript instead of YAML. Output is annotated with: - banner: "Migrated from <file> by chant migrate" - footer: NeedsReview TODOs grouped under "TODO(migration):" The generated TS imports from @intentius/chant-lexicon-gitlab and compiles cleanly under tsc against the lexicon's types. Users own the result — they can edit, then rebuild via chant build to produce fresh .gitlab-ci.yml. Tests: 3 unit tests covering the banner, the TODO footer, and IR parity between yaml and ts emit paths.
When --report <path> is passed, write a SARIF v2.1.0 document containing every migration diagnostic alongside rich rule metadata (description + helpUri for each MIG-* rule). Reuses the existing formatSarif() from the lint side, so any CI ingest path already handling chant lint SARIF will also handle migration SARIF. Adds MIGRATION_RULES static array in lexicons/gitlab/src/migrate/ from-github/rules.ts — one entry per provenance rule emitted by the transformer, with metadata only (no check() body, since work is done in transform()). --strict already escalated needs-review diagnostics to severity: error inside the transformer (#85). This commit closes the loop: the migrate CLI now exits non-zero when --strict is set AND any error-severity diagnostic was emitted. Default (no --strict) keeps exit 0 so dirty migrations don't fail piped scripts. Tests: 7 unit tests on migrate command including SARIF file shape assertion (version 2.1.0, runs[0].results length, ruleId match). Verified end-to-end on a workflow with permissions + schedule: strict produces exit 1, no-strict produces exit 0, SARIF is valid.
When --validate is passed (and emit is yaml), shell out to glci lint (preferred, offline, no auth) or glab ci lint (fallback). Detection uses which/where to check PATH availability. Decision matrix: --validate tool present → run, report status, exit 0 --validate tool absent → warn, skip, exit 0 --validate --strict tool present → run, exit non-zero if validation fails --validate --strict tool absent → error, exit 1 (no --validate) → never invoke external tools Mirrors the upstream skill's scripts/validate.sh logic. tryValidate- External is exported for testability; the unit test asserts the no-tool-present path returns ran=false without throwing. Tests: 8 unit tests on migrate command including validator no-op path.
Opt-in IR rewriter that recognises 1-job NodeCI and 2-job NodePipeline
shapes in the post-transformer GitLab IR and replaces them with
composite resource sentinel types:
GitLab::Composite::NodePipeline
GitLab::Composite::NodeCI
The GitLab generator (lexicons/gitlab/src/import/generator.ts) gains
a COMPOSITE_TYPE_TO_FN map so it emits `NodePipeline({...})` /
`NodeCI({...})` factory calls instead of `new Job({...})` for those
sentinels. Imports are updated to pull from @intentius/chant-lexicon-
gitlab so the generated TS compiles immediately.
Recogniser detection:
- NodePipeline: 2 jobs, both image: node:*, one has install+build,
the other has install+test. Package manager auto-detected from
install command (npm, yarn, pnpm, bun).
- NodeCI: 1 job, image: node:*, install + (build OR test).
Off by default — the literal-translation path remains the default
to keep migrations transparent. --use-composites is the upgrade
moment: 5+ jobs collapse to one composite call.
Tests: 6 unit tests on the rewriter (positive matches, non-node
rejection, missing install rejection, pnpm detection, no-match
fall-through). Smoke test verified --use-composites collapses a
2-job pipeline to `app = NodePipeline({...})`.
Adds migrate-samples.sh + migrate-helper.ts modelled after the existing import-gitlab-samples.sh pattern. Clones a small set of diverse public GitHub repos (actions/checkout, actions/setup-node, sveltejs/svelte, vercel/next.js), iterates their .github/workflows/ *.yml files, runs transform() on each, asserts a configurable pass-rate threshold (default 70%). Out of CI by design — mirrors import-gitlab-samples.sh which also clones real repos and is not part of the main PR workflow. Run locally: bash lexicons/gitlab/scripts/migrate-samples.sh --verbose The 70% threshold is intentionally lower than the gitlab-samples 80%: GitHub Actions surface area is broader (composite actions, reusable workflows with typed inputs, etc.) and many real-world workflows have at least one needs-review item.
…95) Adds a new operational skill (src/skills/chant-gitlab-migrate.md) that teaches Claude/Cursor/opencode how to invoke chant migrate, read the report, surface NeedsReview items, and suggest --use- composites upgrade moments. The skill is registered in the gitlab plugin's skills loader with file-pattern triggers on .github/workflows/* so AI agents pick it up automatically when a workflow appears in context. Also adds --skill <name> filter to chant init: when set, installs only the named skill rather than every skill the plugin exports. Wired through ParsedArgs, the init handler, and initCommand. When omitted, behaviour is unchanged (all skills install). Verified end-to-end: `chant init --lexicon gitlab --skill chant- gitlab-migrate` writes only skills/chant-gitlab-migrate/SKILL.md. Distinction from the upstream gitlab-org/ci-cd/github-actions-to- gitlab-ci skill is documented in the skill body: the upstream skill *is* a compiler (stateless LLM); this one *calls* a compiler (chant migrate) for reproducible, testable translations.
Adds a migrate tool to the gitlab plugin's mcpTools() return so AI
agents (Claude/Cursor/opencode/GitLab Duo) can invoke the migrator
programmatically instead of shelling out.
Tool surface:
name: "migrate" (server auto-namespaces to gitlab:migrate)
inputSchema:
content: string (required) — raw .github/workflows/*.yml
emit: "yaml" | "ts" (default: yaml)
useComposites: boolean — recognise NodePipeline/NodeCI shapes
strict: boolean — escalate needs-review to errors
returns:
output, diagnostics, provenance, stages
Handler lazy-imports the transformer so the gitlab lexicon doesn't
take a runtime hit on @intentius/chant-lexicon-github unless the
MCP tool is actually invoked.
Tests: 3 smoke tests calling the handler directly — registration,
trivial workflow translation, useComposites toggle parity with the
CLI behaviour.
New Starlight page at lexicons/gitlab/docs/src/content/docs/ migration.mdx covering chant migrate end-to-end: - Quickstart + when-to-use vs writing chant from scratch - All flags (--from, --to, --output, --emit, --report, --strict, --validate, --use-composites) - The two emit modes and when to pick each - Literal-translation table (15+ GH→GL key renames) - Tier 1/2/3 marketplace action coverage table (33 actions) - NeedsReview rule catalog (12 MIG-* rules with explanations) - --use-composites worked example (before: 25 lines, after: 4) - glci/glab validator setup - SARIF report shape and CI ingest - v1 limitations (composite actions, reusable workflow inputs, multi-file trees, reverse direction) - Inspiration / lineage section crediting gitlab-org/ci-cd/ github-actions-to-gitlab-ci (MIT) and the four-category model - Sample roundtrip harness pointer Cross-links added from: - index.mdx (nav) - skills.mdx (new chant-gitlab-migrate skill section + MCP table) - lexicons/gitlab/README.md (one-line acknowledgement) This closes the umbrella checklist (#97).
The pre-existing test assertion expected exactly 1 MCP tool (gitlab:diff). Commit 6ead8f3 added a second tool (migrate), so the assertion needs widening: assert >=2 tools and that both expected names are present.
This was referenced May 23, 2026
Addresses the 10 items surfaced by the first-user audit on PR #99: 1. migration.mdx: insert Install section above Quickstart so the `npx chant migrate ...` command actually works for a fresh user; add :::note about the unmerged-branch / next-release availability 2. New docs/src/content/docs/cli/migrate.mdx reference page; register `migrate` in cli/overview.mdx Commands table 3. lexicons/overview.mdx: GitLab row notes migration capability; new "Cross-lexicon migration" subsection links to docs 4. docs/index.mdx: new "Cross-Platform Migration" feature card in the landing carousel 5. lexicons/github/docs/src/content/docs/index.mdx: "Migrating to GitLab CI/CD?" breadcrumb so users on the source-side lexicon find the tool 6. docs/whats-new.mdx: dedicated "Cross-lexicon migration" section listing all 14 commits with issue/PR links 7. migration.mdx line 64: fix doubled URL path (.../master/github-actions-to-gitlab-ci/references/... → .../master/references/...) 8. SARIF informationUri + default helpUri: chant.dev → intentius.io/chant in both stylish.ts (SARIF formatter) and rule-registry.ts (post-synth check fallback) 9. New lexicons/gitlab/examples/migrate-from-github/ with realistic 3-job input, both yaml + ts goldens, and README documenting what the example translates and what limitation it exposes 10. (Folded into #1) availability note in migration.mdx Full test suite: 499 files, 5887 tests pass, 5 skipped.
…iables The audit on PR #99 caught that `image: node:\${{ matrix.node }}` was flowing through to output verbatim because expression substitution only ran on `script:` lines and `if:` conditions, not on `image:` or `variables.*` values. Fix: new substituteValueExpressions() helper applied at every site that assigns a string-typed property the user can populate with expressions — runs-on image, container.image, action-mapping image result, env → variables values, and action-mapping variables result. The helper is a no-op when the value doesn't contain \${{ . Result: `image: node:$node` instead of `image: node:\${{ matrix.node }}`; `TOKEN: $API_TOKEN` instead of `TOKEN: \${{ secrets.API_TOKEN }}`; `my-registry/app:$CI_COMMIT_SHA` instead of `my-registry/app:\${{ github.sha }}`. Regression tests cover all three classes (matrix, secrets, container). Example golden regenerated; the "Known limitations" note that flagged this bug in lexicons/gitlab/examples/migrate-from-github/README.md removed. All 16 syntax-mapping + marketplace fixtures pass unchanged — none of them happened to exercise the buggy code paths.
Contributor
Author
|
CI green on the latest commit
Branch is now at 16 commits ahead of
Total test count: 5890 passing, 5 skipped, 0 failing (up from 5813 on PR remains draft per the original instruction. Ready for review whenever you want to merge. |
Audit against the upstream gitlab-org/ci-cd/github-actions-to-gitlab-ci SKILL.md surfaced four output-format gaps the chant migrate translation covered functionally but did not surface to the user. This commit closes those gaps and sharpens the docs positioning. Code (packages/core/src/cli/commands/migrate.ts — formatMarkdownSummary): - Overview line: workflow name + job count + trigger summary - Workflow classification banner: detects repo-automation events (issues, labels, discussions, etc.) and flags them upfront with the gitlab-triage recommendation; mixed-trigger workflows get a separate informational note - Aggregated "Manual setup steps" numbered list: collects per-rule actionable instructions from needs-review diagnostics (de-duped, human-readable, tied to specific GitLab UI paths) - "Suggested GitLab improvements" section: heuristic detection of DAG-eligible workflows, path-based filtering via rules:changes, local reusable workflows via include:, --use-composites candidates, protected environments for deploy jobs, GitLab CI templates for SAST/DAST/Terraform mentions - "Honest caveats" footer when any error/warning fires Docs (lexicons/gitlab/docs/src/content/docs/migration.mdx): - New "Why chant migrate over the upstream skill" section with an 11-row comparison table selling the differential value (reproducibility, testability, SARIF, --strict, --emit ts, --use-composites, MCP, lint integration, action registry extensibility, no install for the skill's quick-paste UX) - New "Coverage vs the upstream skill" matrix table: every capability the skill's SKILL.md claims, mapped to the chant equivalent. Confirms 100% coverage of documented features + the new output-format additions - Inspiration section tightened: explicitly notes all 33 entries from the upstream marketplace-actions.md are present in chant Example: regenerated expected.gitlab-ci.yml / expected.ts with the substitution fix from 521153e (no Markdown report in the goldens; that's stderr-only). Verified: 5890 tests passing. Smoke test on a 3-job workflow shows all four new report sections rendering. Smoke test on a stale-issues workflow correctly flags mixed triggers (git + automation).
lex00
marked this pull request as ready for review
May 23, 2026 16:59
This was referenced Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the chant migration tool umbrella tracked at #97.
What this PR delivers
A typed-compiler port of
gitlab-org/ci-cd/github-actions-to-gitlab-ci(MIT). Translates.github/workflows/*.yml→.gitlab-ci.yml(or chant TypeScript) with per-key provenance, SARIF reporting, native marketplace-action mappings, and composite-pattern recognition.Status
Draft, do not merge. This PR sits open for CI visibility and code review; per the planning conversation it stays unmerged until the user decides.
Commits (each closes its issue)
Verification
npx tsc --noEmit -p packages/core/tsconfig.json→ cleannpx vitest run→ 5887 tests passing, 5 skipped, 0 failingnpm run --prefix lexicons/gitlab prepack→ all validation checks pass--use-compositescollapses 2-job Node setups into singleNodePipeline({...})calls;--strictexits non-zero on NeedsReview items as designedOut of scope (deferred follow-ups)
.github/actions/*/action.yml) recursive translationinputs:/outputs:@intentius/chant-migratepackageInspired by
gitlab-org/ci-cd/github-actions-to-gitlab-ci— full attribution in lexicons/gitlab/ATTRIBUTIONS.md and the Migration docs page inspiration section.