From f902dba7b49594b9be8939e2dcaeeac90e93bc3a Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Tue, 2 Jun 2026 09:38:09 +0200 Subject: [PATCH] chore(x2a): add AGENTS.md Signed-off-by: Marek Libra --- workspaces/x2a/AGENTS.md | 205 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 workspaces/x2a/AGENTS.md diff --git a/workspaces/x2a/AGENTS.md b/workspaces/x2a/AGENTS.md new file mode 100644 index 0000000000..7943e628ed --- /dev/null +++ b/workspaces/x2a/AGENTS.md @@ -0,0 +1,205 @@ +# X2Ansible Backstage Plugin + +Backstage plugin workspace providing a web UI for the [X2Ansible](https://github.com/x2ansible/x2a-convertor) project — LLM-powered migration of applications to Ansible playbooks. + +## Dev Environment + +Prerequisites: Node.js 22 or 24, Yarn. + +```sh +yarn install +``` + +Optional environment variables for OAuth sign-in (see `app-config.yaml` `auth:` section): + +```sh +export AUTH_GITHUB_CLIENT_ID=... +export AUTH_GITHUB_CLIENT_SECRET=... +export AUTH_GITLAB_CLIENT_ID=... +export AUTH_GITLAB_CLIENT_SECRET=... +export AUTH_BITBUCKET_CLIENT_ID=... +export AUTH_BITBUCKET_CLIENT_SECRET=... +``` + +Start the frontend and backend plugins only: + +```sh +yarn dev +``` + +Start the full Backstage application (includes scaffolder, RBAC, catalog): + +```sh +yarn start +``` + +Frontend: `http://localhost:3000`, backend: `http://localhost:7007`. + +## Build + +```sh +yarn build:all # Build all packages +yarn build:backend # Build backend only +yarn tsc:full # Full TypeScript check (no incremental) +``` + +Build dynamic plugin OCI images: + +```sh +./scripts/build-dynamic-plugins.sh # Build all +./scripts/build-dynamic-plugins.sh --report # Print image report (no build) +``` + +## Test + +Unit tests use Jest via `backstage-cli`. Backend tests require `NODE_OPTIONS='--experimental-vm-modules'` (already set in per-package scripts). + +```sh +yarn test # Unit tests (SQLite only) +yarn test:pg # Unit tests (SQLite + PostgreSQL via testcontainers, requires Docker/Podman) +yarn test:all # Full suite: openapi-generate + prettier + lint + test --coverage +yarn test:all:pg # Full suite with PostgreSQL +``` + +Run a single package's tests: + +```sh +yarn workspace @red-hat-developer-hub/backstage-plugin-x2a-backend test +``` + +PostgreSQL tests use `testcontainers` and need `CI=true` plus a running Docker/Podman daemon. On Fedora/RHEL with Podman: + +```sh +systemctl --user enable --now podman.socket +export DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock +``` + +Test files live next to the source they test, named `*.test.ts` / `*.test.tsx`. + +E2E tests use Playwright (`packages/app/e2e-tests/`). Currently a placeholder — the scaffold is in place but no real tests yet. + +```sh +yarn test:e2e # (skipped until tests exist) +``` + +## Code Style + +Prettier config: `@backstage/cli/config/prettier`. ESLint config inherits from `../../.eslintrc.cjs` (root repo). + +```sh +yarn prettier:check # Check formatting +yarn prettier:fix # Fix formatting +yarn lint # Lint changed packages (since origin/main) +yarn lint:all # Lint all packages +yarn lint:all --fix # Auto-fix lint issues +``` + +Key lint rules (from root `.eslintrc.cjs`): + +- Copyright header required: `Copyright (The Backstage Authors|Red Hat, Inc.|...)`. +- Use `.toLocaleLowerCase('en-US')` / `.toLocaleUpperCase('en-US')` instead of `.toLowerCase()` / `.toUpperCase()`. +- Production code: avoid raw `