diff --git a/.github/actions/test/action.yaml b/.github/actions/test/action.yaml index 05788dd2d10..fea623d04d0 100644 --- a/.github/actions/test/action.yaml +++ b/.github/actions/test/action.yaml @@ -8,7 +8,7 @@ runs: using: 'composite' steps: - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'yarn' @@ -20,14 +20,18 @@ runs: shell: bash run: yarn --prefer-offline --frozen-lockfile - - name: Run prettier + - name: Build all packages shell: bash - run: yarn prettier:check + run: yarn build --filter=${{ inputs.args }} --concurrency=1 - - name: Run lint + - name: Start backstage shell: bash - run: yarn lint --filter=${{ inputs.args }} + run: ls;yarn start:backstage - - name: Run tests + - name: Wait for backstage shell: bash - run: yarn test --filter=${{ inputs.args }} + run: timeout 15 bash -c 'until echo > /dev/tcp/localhost/7007; do sleep 3; done' + + - name: Test get notifications + shell: bash + run: curl http://localhost:7007/api/notifications/notifications diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index a79cd11da4a..6a104969bb8 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -3,7 +3,7 @@ name: Push on: push: branches: - - main + - flpath799 concurrency: group: push @@ -19,24 +19,3 @@ jobs: - name: Test uses: ./.github/actions/test - - release: - name: Release - needs: - - test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Build all packages - uses: ./.github/actions/build - - - name: Release via semantic-release - run: | - npm config set workspaces-update false - yarn release --ignore-private-packages - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - NODE_OPTIONS: '--max-old-space-size=8192' diff --git a/app-config.yaml b/app-config.yaml index cd01d53707c..2f0654283b5 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -28,7 +28,25 @@ backend: # This is for local development only, it is not recommended to use this in production # The production database configuration is stored in app-config.production.yaml database: - connection: ':memory:' + client: better-sqlite3 + connection: + ':memory:' + #directory: ./mydb.sqlite + useNullAsDefault: true + #plugin: + #notifications: + #connection: + #filename: ./mydb.sqlite/thedb.sqlite + #host: 127.0.0.1 + #port: 5432 + #user: postgres + #password: secret + #knexConfig: + # pool: + # min: 3 + # max: 12 + # acquireTimeoutMillis: 60000 + # idleTimeoutMillis: 60000 cache: store: memory # workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir @@ -84,8 +102,11 @@ catalog: entityFilename: catalog-info.yaml pullRequestBranchName: backstage-integration rules: - - allow: [Component, System, API, Resource, Location] + - allow: [Component, System, API, Resource, Location, User, Group] locations: + - type: file + # *** Here is new change, referes to a file stored in the root of the Backstage: + target: /home/ydayagi/work/src/github.com/ydayagi/backstage-plugins/plugins/notifications-backend/users.yaml # Local example data, file locations are relative to the backend process, typically `packages/backend` - type: file target: ../../examples/entities.yaml diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index a15ad6bc792..ebaba1b8db4 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -28,6 +28,7 @@ import Router from 'express-promise-router'; import app from './plugins/app'; import auth from './plugins/auth'; import catalog from './plugins/catalog'; +import notifications from './plugins/notifications'; import permission from './plugins/permissions'; import proxy from './plugins/proxy'; import scaffolder from './plugins/scaffolder'; @@ -104,6 +105,10 @@ async function main() { getPluginIds: () => ['catalog', 'scaffolder', 'permission'], }), ); + const notificationsEnv = useHotMemoize(module, () => + createEnv('notifications'), + ); + apiRouter.use('/notifications', await notifications(notificationsEnv)); // Add backends ABOVE this line; this 404 handler is the catch-all fallback apiRouter.use(notFoundHandler()); diff --git a/packages/backend/src/plugins/notifications.ts b/packages/backend/src/plugins/notifications.ts new file mode 100644 index 00000000000..f64d7b3dcae --- /dev/null +++ b/packages/backend/src/plugins/notifications.ts @@ -0,0 +1,18 @@ +import { CatalogClient } from '@backstage/catalog-client'; +import { createRouter } from '@backstage/plugin-notifications-backend'; + +import { Router } from 'express'; + +import { PluginEnvironment } from '../types'; + +export default async function createPlugin( + env: PluginEnvironment, +): Promise { + const catalogClient = new CatalogClient({ discoveryApi: env.discovery }); + const dbConfig = env.config.getConfig('backend.database'); + return await createRouter({ + logger: env.logger, + dbConfig, + catalogClient, + }); +} diff --git a/plugins/notifications-backend/users.yaml b/plugins/notifications-backend/users.yaml index 60fb810885a..288e52c6f45 100644 --- a/plugins/notifications-backend/users.yaml +++ b/plugins/notifications-backend/users.yaml @@ -1,6 +1,7 @@ apiVersion: backstage.io/v1alpha1 kind: User metadata: + namespace: default name: guest spec: profile: