From 1c3f69ace80b4cc8bcf5486ea7c43c2dc02365d9 Mon Sep 17 00:00:00 2001 From: Mateusz Wiszniewski Date: Tue, 3 Nov 2026 10:01:04 +0100 Subject: [PATCH] ci: add a basic GitHub Actions workflow The repository has no .github/ directory. This adds the equivalent branch and pull request checks for GitHub Actions, so it gets a signal on every PR and push to master. One job on ubuntu-latest, node 22, and 24: install, lint, type check, test, build, prettier. The order puts the gates that find real breakage first and formatting last, since prettier failures are trivial to fix with `yarn fix` and shouldn't be what masks a type or test error. CI=true is set for the whole job, without it `backstage-cli repo test` drops into jest's watch mode and the job hangs. Also adds a pull request template and a dependabot config limited to the action versions. --- .github/PULL_REQUEST_TEMPLATE.md | 9 ++ .github/dependabot.yml | 13 +++ .github/workflows/ci.yml | 86 +++++++++++++++++++ .../migrations/20261028120000_init.js | 70 +++++++-------- 4 files changed, 139 insertions(+), 39 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..2b2ddae --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,9 @@ +## What does this change? + + + +## Checklist + +- [ ] `yarn lint`, `yarn tsc`, `yarn test` and `yarn prettier:check` pass locally +- [ ] A changeset is included if a published package changed (`yarn changeset`, see CONTRIBUTING.md) +- [ ] Docs (`README.md` / `docs/`) updated if the behaviour or configuration changed diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1d1ddbe --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +version: 2 +updates: + # Keeps the action versions in .github/workflows up to date. The npm + # dependencies are deliberately left out: this is a Yarn 4 monorepo whose root + # package.json carries a long `resolutions` block, and per-package PRs against + # it are more churn than they are worth. Bump those with `yarn upgrade` and + # the Backstage version bumps instead. + - package-ecosystem: github-actions + directory: / + schedule: + interval: monthly + commit-message: + prefix: ci diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8e68fa5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,86 @@ +# Branch and pull request checks. Mirrors what CONTRIBUTING.md asks you to run +# before pushing (`yarn lint`, `yarn tsc`, `yarn test`, `yarn prettier:check`) +name: CI + +on: + pull_request: + push: + branches: [master] + +# One run per branch or pull request. A new push supersedes the run in flight. +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + ci: + name: CI (node ${{ matrix.node-version }}) + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + # package.json engines allow "22 || 24"; .nvmrc pins v24, so that is the + # version the checks run on. Add 24.x here to cover both. + node-version: [22.x, 24.x] + + env: + # `backstage-cli repo test` drops into jest's watch mode without this and + # the job would hang until the timeout. Also what the backend's + # setupTests.ts reads to let TestDatabases spawn its Postgres container. + CI: true + NODE_OPTIONS: --max-old-space-size=8192 + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + # Full history, so `changeset status --since=origin/` below can + # diff the branch against the base branch. + fetch-depth: 0 + + - name: Set up node ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: yarn + + - name: Install dependencies + run: yarn install --immutable + + - name: Lint + run: yarn lint + + # Plain `tsc`, not `tsc:full`: the latter passes --skipLibCheck false and + # then fails inside @testing-library/react's own .d.ts files because + # @types/react-dom isn't resolvable from there. That is a dependency + # problem, not a problem with this repo's sources. + - name: Type check + run: yarn tsc + + # The backend's integration tests use Backstage's TestDatabases with + # POSTGRES_16, which starts its own Postgres through testcontainers on the + # runner's Docker daemon. No `services:` block is needed; set + # BACKSTAGE_TEST_DATABASE_POSTGRES16_CONNECTION_STRING here instead if you + # ever want to point them at an external database. + - name: Test + run: yarn test + + - name: Build + run: yarn build + + # Runs after the gates above on purpose: formatting is the cheapest thing + # to fix and the least interesting failure, so it shouldn't be what hides + # a type or test error. `yarn fix` formats whatever this reports. Add + # `continue-on-error: true` here if you'd rather it never failed a build. + - name: Prettier + run: yarn prettier:check + + # Advisory only. `yarn changeset:check` isn't used here + - name: Changeset check (advisory) + if: github.event_name == 'pull_request' + continue-on-error: true + run: yarn changeset status --since=origin/${{ github.base_ref }} diff --git a/workspaces/ownership-matcher/plugins/ownership-matcher-backend/migrations/20261028120000_init.js b/workspaces/ownership-matcher/plugins/ownership-matcher-backend/migrations/20261028120000_init.js index b36bd3a..cff7cbf 100644 --- a/workspaces/ownership-matcher/plugins/ownership-matcher-backend/migrations/20261028120000_init.js +++ b/workspaces/ownership-matcher/plugins/ownership-matcher-backend/migrations/20261028120000_init.js @@ -92,27 +92,23 @@ exports.up = async function up(knex) { // reconciliation pass compares the catalog's `spec.owner` with the accepted // owner, using `pr_id` to read the PR's state and `pr_checked_at` to // throttle itself. - table - .string('pr_status') - .notNullable() - .defaultTo('none') - .checkIn( - [ - 'none', - 'pending', - 'raised', - 'failed', - // No installed SCM provider can raise PRs for this repository host. - 'unsupported_scm', - // Catalog owner matches the accepted team. - 'completed', - // PR declined; retryable. - 'declined', - // Someone else changed the owner. - 'superseded', - ], - 'ownership_entities_pr_status_check', - ); + table.string('pr_status').notNullable().defaultTo('none').checkIn( + [ + 'none', + 'pending', + 'raised', + 'failed', + // No installed SCM provider can raise PRs for this repository host. + 'unsupported_scm', + // Catalog owner matches the accepted team. + 'completed', + // PR declined; retryable. + 'declined', + // Someone else changed the owner. + 'superseded', + ], + 'ownership_entities_pr_status_check', + ); table.text('pr_url').nullable(); table.string('pr_branch').nullable(); // Failed attempts since the last (re)enqueue. @@ -152,24 +148,20 @@ exports.up = async function up(knex) { table.string('confidence_reason').notNullable(); table.float('confidence_score').nullable(); table.integer('proposal_order').notNullable().defaultTo(1); - table - .string('status') - .notNullable() - .defaultTo('pending') - .checkIn( - [ - 'queued', - 'pending', - 'accepted', - 'rejected', - 'expired', - 'cancelled', - // Candidate below the configured notificationThreshold: offered for - // voluntary claiming in the UI instead of being notified. - 'possible_owner', - ], - 'ownership_proposals_status_check', - ); + table.string('status').notNullable().defaultTo('pending').checkIn( + [ + 'queued', + 'pending', + 'accepted', + 'rejected', + 'expired', + 'cancelled', + // Candidate below the configured notificationThreshold: offered for + // voluntary claiming in the UI instead of being notified. + 'possible_owner', + ], + 'ownership_proposals_status_check', + ); table.integer('escalation_level').notNullable().defaultTo(0); table.timestamp('notified_at').nullable(); table.timestamp('responded_at').nullable();