From 00afbcb9e80262ac2113236f986ea0157be04062 Mon Sep 17 00:00:00 2001 From: William Calderipe Date: Thu, 4 Jan 2024 13:59:38 +0100 Subject: [PATCH 1/5] Add Dependabot --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..aff82a102 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "weekly" From efc9ecc8978ddd5059ec4961492d54fdd9c40cd5 Mon Sep 17 00:00:00 2001 From: William Calderipe Date: Thu, 4 Jan 2024 14:16:43 +0100 Subject: [PATCH 2/5] First attempt on Orchestration CI --- .github/workflows/ci_orchestration.yml | 86 +++++++++++++++++++ Makefile | 15 ++++ .../transaction-engine-module/package.json | 3 +- 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci_orchestration.yml diff --git a/.github/workflows/ci_orchestration.yml b/.github/workflows/ci_orchestration.yml new file mode 100644 index 000000000..0e43ec907 --- /dev/null +++ b/.github/workflows/ci_orchestration.yml @@ -0,0 +1,86 @@ +name: Orchestration CI + +on: + push: + paths: + - apps/orchestration/** + - .github/workflows/** + - Makefile + - jest.config.ts + - jest.preset.js + - .eslintrc.json + - .prettierrc + +jobs: + build-and-test: + name: Build and test + + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:14 + ports: + - '5432:5432' + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + redis: + image: redis + ports: + - '6379:6379' + env: + REDIS_PORT: 6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout + uses: actions/checkout@master + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.4.0' + + - name: Install dependencies + run: make install/ci + + - name: Code format + shell: bash + run: | + make format/check + make lint/check + + - name: Setup database and Prisma types + shell: bash + run: | + make orchestration/test/copy-default-env + make orchestration/test/db/setup + make orchestration/db/generate-types + + # - name: Test types + # shell: bash + # run: npm run test:type + + # - name: Test unit + # shell: bash + # run: npm run test:unit + + # - name: Test integration + # shell: bash + # run: | + # npm run test:integration + + # - name: Test E2E + # shell: bash + # run: | + # npm run test:e2e diff --git a/Makefile b/Makefile index 50af4df0f..bffe5ee26 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +install/ci: + npm ci + docker/stop: docker-compose stop @@ -12,6 +15,15 @@ format/check: npx prettier \ --check "apps/**/*.ts" "packages/**/*.ts" "./*.{js,json}" +lint: + npx nx run-many \ + --target lint \ + --fix + +lint/check: + npx nx run-many \ + --target lint + orchestration/db/generate-types: npx prisma generate \ --schema ./apps/orchestration/src/persistence/schema/schema.prisma @@ -34,3 +46,6 @@ orchestration/test/db/setup: --schema ./apps/orchestration/src/persistence/schema/schema.prisma \ --skip-seed \ --force + +orchestration/test/copy-default-env: + cp ./apps/orchestration/.env.test.default ./apps/orchestration/.env.test diff --git a/packages/transaction-engine-module/package.json b/packages/transaction-engine-module/package.json index d3a3230a1..65fd7d0c2 100644 --- a/packages/transaction-engine-module/package.json +++ b/packages/transaction-engine-module/package.json @@ -2,7 +2,8 @@ "name": "@narval/transaction-engine-module", "version": "0.0.1", "dependencies": { - "tslib": "^2.3.0" + "tslib": "^2.3.0", + "@nestjs/common": "^10.0.2" }, "type": "commonjs", "main": "./src/index.js", From a345d83bf22ab949abe678a89ec7b182852c9006 Mon Sep 17 00:00:00 2001 From: William Calderipe Date: Thu, 4 Jan 2024 15:01:37 +0100 Subject: [PATCH 3/5] Run orchestration tests in the CI --- .github/workflows/ci_orchestration.yml | 30 +++++++++++------------ Makefile | 28 ++------------------- apps/orchestration/Makefile | 34 ++++++++++++++++++++++++++ apps/orchestration/project.json | 6 +++++ 4 files changed, 56 insertions(+), 42 deletions(-) create mode 100644 apps/orchestration/Makefile diff --git a/.github/workflows/ci_orchestration.yml b/.github/workflows/ci_orchestration.yml index 0e43ec907..578563bea 100644 --- a/.github/workflows/ci_orchestration.yml +++ b/.github/workflows/ci_orchestration.yml @@ -52,7 +52,8 @@ jobs: node-version: '20.4.0' - name: Install dependencies - run: make install/ci + run: | + make install/ci - name: Code format shell: bash @@ -67,20 +68,17 @@ jobs: make orchestration/test/db/setup make orchestration/db/generate-types - # - name: Test types - # shell: bash - # run: npm run test:type - - # - name: Test unit - # shell: bash - # run: npm run test:unit + - name: Test types + shell: bash + run: | + make orchestration/test/type - # - name: Test integration - # shell: bash - # run: | - # npm run test:integration + - name: Test unit + shell: bash + run: | + make orchestration/test/unit - # - name: Test E2E - # shell: bash - # run: | - # npm run test:e2e + - name: Test E2E + shell: bash + run: | + make orchestration/test/e2e diff --git a/Makefile b/Makefile index bffe5ee26..7a67416ad 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +include ./apps/orchestration/Makefile + install/ci: npm ci @@ -23,29 +25,3 @@ lint: lint/check: npx nx run-many \ --target lint - -orchestration/db/generate-types: - npx prisma generate \ - --schema ./apps/orchestration/src/persistence/schema/schema.prisma - -orchestration/db/migrate: - npx dotenv -e ./apps/orchestration/.env -- \ - prisma migrate dev \ - --schema ./apps/orchestration/src/persistence/schema/schema.prisma - -# Reference: https://www.prisma.io/docs/orm/prisma-migrate/workflows/seeding#seeding-your-database-with-typescript-or-javascript -orchestration/db/seed: - npx dotenv -e ./apps/orchestration/.env -- \ - ts-node \ - --compiler-options "{\"module\":\"CommonJS\"}" \ - ./apps/orchestration/src/persistence/seed.ts - -orchestration/test/db/setup: - npx dotenv -e ./apps/orchestration/.env.test --override -- \ - prisma migrate reset \ - --schema ./apps/orchestration/src/persistence/schema/schema.prisma \ - --skip-seed \ - --force - -orchestration/test/copy-default-env: - cp ./apps/orchestration/.env.test.default ./apps/orchestration/.env.test diff --git a/apps/orchestration/Makefile b/apps/orchestration/Makefile new file mode 100644 index 000000000..80ac016e6 --- /dev/null +++ b/apps/orchestration/Makefile @@ -0,0 +1,34 @@ +orchestration/db/generate-types: + npx prisma generate \ + --schema ./apps/orchestration/src/persistence/schema/schema.prisma + +orchestration/db/migrate: + npx dotenv -e ./apps/orchestration/.env -- \ + prisma migrate dev \ + --schema ./apps/orchestration/src/persistence/schema/schema.prisma + +# Reference: https://www.prisma.io/docs/orm/prisma-migrate/workflows/seeding#seeding-your-database-with-typescript-or-javascript +orchestration/db/seed: + npx dotenv -e ./apps/orchestration/.env -- \ + ts-node \ + --compiler-options "{\"module\":\"CommonJS\"}" \ + ./apps/orchestration/src/persistence/seed.ts + +orchestration/test/db/setup: + npx dotenv -e ./apps/orchestration/.env.test --override -- \ + prisma migrate reset \ + --schema ./apps/orchestration/src/persistence/schema/schema.prisma \ + --skip-seed \ + --force + +orchestration/test/copy-default-env: + cp ./apps/orchestration/.env.test.default ./apps/orchestration/.env.test + +orchestration/test/unit: + npx nx test:unit apps/orchestration + +orchestration/test/type: + npx nx test:type apps/orchestration + +orchestration/test/e2e: + npx nx test:e2e apps/orchestration diff --git a/apps/orchestration/project.json b/apps/orchestration/project.json index d02c8a9e3..40776af09 100644 --- a/apps/orchestration/project.json +++ b/apps/orchestration/project.json @@ -57,6 +57,12 @@ "options": { "jestConfig": "apps/orchestration/jest.e2e.ts" } + }, + "test:type": { + "executor": "nx:run-commands", + "options": { + "command": "npx tsc --noEmit --project apps/orchestration/tsconfig.app.json" + } } }, "tags": [] From 4abee630cd3a788ba508048cb120c71c081f268b Mon Sep 17 00:00:00 2001 From: William Calderipe Date: Thu, 4 Jan 2024 15:25:27 +0100 Subject: [PATCH 4/5] Add AuthZ CI --- .github/workflows/authz_ci.yml | 89 +++++++++++++++++++ ...orchestration.yml => orchestration_ci.yml} | 5 ++ Makefile | 1 + README.md | 56 +----------- apps/authz-node/.env.test.default | 2 + apps/authz-node/Makefile | 17 ++++ apps/authz-node/jest.config.ts | 2 +- apps/authz-node/jest.integration.ts | 9 ++ apps/authz-node/jest.setup.ts | 28 ++++++ apps/authz-node/project.json | 14 +++ .../app/__test__/integration/example.spec.ts | 5 ++ .../src/app/__test__/unit/example.spec.ts | 5 ++ apps/orchestration/Makefile | 31 ++++--- apps/orchestration/jest.integration.ts | 9 ++ apps/orchestration/jest.setup.ts | 2 +- apps/orchestration/project.json | 17 ++-- .../src/__test__/integration/example.spec.ts | 5 ++ 17 files changed, 223 insertions(+), 74 deletions(-) create mode 100644 .github/workflows/authz_ci.yml rename .github/workflows/{ci_orchestration.yml => orchestration_ci.yml} (94%) create mode 100644 apps/authz-node/.env.test.default create mode 100644 apps/authz-node/Makefile create mode 100644 apps/authz-node/jest.integration.ts create mode 100644 apps/authz-node/jest.setup.ts create mode 100644 apps/authz-node/src/app/__test__/integration/example.spec.ts create mode 100644 apps/authz-node/src/app/__test__/unit/example.spec.ts create mode 100644 apps/orchestration/jest.integration.ts create mode 100644 apps/orchestration/src/__test__/integration/example.spec.ts diff --git a/.github/workflows/authz_ci.yml b/.github/workflows/authz_ci.yml new file mode 100644 index 000000000..d54860a45 --- /dev/null +++ b/.github/workflows/authz_ci.yml @@ -0,0 +1,89 @@ +name: AuthZ CI + +on: + push: + paths: + - apps/authz-node/** + - .github/workflows/** + - Makefile + - jest.config.ts + - jest.preset.js + - .eslintrc.json + - .prettierrc + +jobs: + build-and-test: + name: Build and test + + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:14 + ports: + - '5432:5432' + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + redis: + image: redis + ports: + - '6379:6379' + env: + REDIS_PORT: 6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout + uses: actions/checkout@master + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.4.0' + + - name: Install dependencies + run: | + make install/ci + + - name: Code format + shell: bash + run: | + make format/check + make lint/check + + # - name: Setup database and Prisma types + # shell: bash + # run: | + # make orchestration/test/copy-default-env + # make orchestration/test/db/setup + # make orchestration/db/generate-types + + - name: Test types + shell: bash + run: | + make authz/test/type + + - name: Test unit + shell: bash + run: | + make authz/test/unit + + - name: Test integration + shell: bash + run: | + make authz/test/integration + + # - name: Test E2E + # shell: bash + # run: | + # make orchestration/test/e2e diff --git a/.github/workflows/ci_orchestration.yml b/.github/workflows/orchestration_ci.yml similarity index 94% rename from .github/workflows/ci_orchestration.yml rename to .github/workflows/orchestration_ci.yml index 578563bea..e78dfefbf 100644 --- a/.github/workflows/ci_orchestration.yml +++ b/.github/workflows/orchestration_ci.yml @@ -78,6 +78,11 @@ jobs: run: | make orchestration/test/unit + - name: Test integration + shell: bash + run: | + make orchestration/test/integration + - name: Test E2E shell: bash run: | diff --git a/Makefile b/Makefile index 7a67416ad..e7bf3d6bd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ include ./apps/orchestration/Makefile +include ./apps/authz-node/Makefile install/ci: npm ci diff --git a/README.md b/README.md index 213254788..fefdb0aff 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,3 @@ # Narval - - -✨ **This workspace has been generated by [Nx, a Smart, fast and extensible build system.](https://nx.dev)** ✨ - -## Generate code - -If you happen to use Nx plugins, you can leverage code generators that might come with it. - -Run `nx list` to get a list of available plugins and whether they have generators. Then run `nx list ` to see what generators are available. - -Learn more about [Nx generators on the docs](https://nx.dev/plugin-features/use-code-generators). - -## Running tasks - -To execute tasks with Nx use the following syntax: - -``` -nx <...options> -``` - -You can also run multiple targets: - -``` -nx run-many -t -``` - -..or add `-p` to filter specific projects - -``` -nx run-many -t -p -``` - -Targets can be defined in the `package.json` or `projects.json`. Learn more [in the docs](https://nx.dev/core-features/run-tasks). - -## Want better Editor Integration? - -Have a look at the [Nx Console extensions](https://nx.dev/nx-console). It provides autocomplete support, a UI for exploring and running tasks & generators, and more! Available for VSCode, IntelliJ and comes with a LSP for Vim users. - -## Ready to deploy? - -Just run `nx build demoapp` to build the application. The build artifacts will be stored in the `dist/` directory, ready to be deployed. - -## Set up CI! - -Nx comes with local caching already built-in (check your `nx.json`). On CI you might want to go a step further. - -- [Set up remote caching](https://nx.dev/core-features/share-your-cache) -- [Set up task distribution across multiple machines](https://nx.dev/nx-cloud/features/distribute-task-execution) -- [Learn more how to setup CI](https://nx.dev/recipes/ci) - -## Connect with us! - -- [Join the community](https://nx.dev/community) -- [Subscribe to the Nx Youtube Channel](https://www.youtube.com/@nxdevtools) -- [Follow us on Twitter](https://twitter.com/nxdevtools) +[![Orchestration CI](https://github.com/narval-xyz/narval/actions/workflows/ci_orchestration.yml/badge.svg?branch=main)](https://github.com/narval-xyz/narval/actions/workflows/ci_orchestration.yml) diff --git a/apps/authz-node/.env.test.default b/apps/authz-node/.env.test.default new file mode 100644 index 000000000..45837be39 --- /dev/null +++ b/apps/authz-node/.env.test.default @@ -0,0 +1,2 @@ +# IMPORTANT: The variables defined here will override other variables. +# See `./apps/authz-node/jest.setup.ts`. diff --git a/apps/authz-node/Makefile b/apps/authz-node/Makefile new file mode 100644 index 000000000..d2d4b5224 --- /dev/null +++ b/apps/authz-node/Makefile @@ -0,0 +1,17 @@ +AUTHZ_PROJECT_NAME := apps/authz-node +AUTHZ_PROJECT_DIR := ./apps/authz-node + +authz/test/copy-default-env: + cp ${AUTHZ_PROJECT_DIR}/.env.test.default ${AUTHZ_PROJECT_DIR}/.env.test + +authz/test/type: + npx nx test:type ${AUTHZ_PROJECT_NAME} + +authz/test/unit: + npx nx test:unit ${AUTHZ_PROJECT_NAME} + +authz/test/integration: + npx nx test:integration ${AUTHZ_PROJECT_NAME} + +authz/test/e2e: + npx nx test:e2e ${AUTHZ_PROJECT_NAME} diff --git a/apps/authz-node/jest.config.ts b/apps/authz-node/jest.config.ts index 5a8f4c8c6..48dc38b1c 100644 --- a/apps/authz-node/jest.config.ts +++ b/apps/authz-node/jest.config.ts @@ -1,7 +1,7 @@ import type { Config } from 'jest' const config: Config = { - displayName: 'apps/orchestration', + displayName: 'apps/authz-node', preset: '../../jest.preset.js', testEnvironment: 'node', transform: { diff --git a/apps/authz-node/jest.integration.ts b/apps/authz-node/jest.integration.ts new file mode 100644 index 000000000..533d40428 --- /dev/null +++ b/apps/authz-node/jest.integration.ts @@ -0,0 +1,9 @@ +import type { Config } from 'jest' +import sharedConfig from './jest.config' + +const config: Config = { + ...sharedConfig, + testMatch: ['/**/__test__/integration/**/*.spec.ts'] +} + +export default config diff --git a/apps/authz-node/jest.setup.ts b/apps/authz-node/jest.setup.ts new file mode 100644 index 000000000..dbf5bd0bc --- /dev/null +++ b/apps/authz-node/jest.setup.ts @@ -0,0 +1,28 @@ +import dotenv from 'dotenv' +import fs from 'fs' +import nock from 'nock' + +const testEnvFile = `${__dirname}/.env.test` +const envFile = `${__dirname}/.env` + +// Ensure a test environment variable file exists because of the override config +// loading mechanics below. +if (!fs.existsSync(testEnvFile)) { + throw new Error('No .env.test file found. Please create one by running "make authz/test/copy-default-env".') +} + +// We don't want to have two dotenv files that are exactly the same, so we +// override the default with .env.test. +// +// If a .env.test file is not found, the DATABASE_URL will fallback to the +// default. Consequently, you'll lose your development database during the +// integration tests teardown. Hence, the check above. +dotenv.config({ path: envFile }) +dotenv.config({ path: testEnvFile, override: true }) + +// Disable outgoing HTTP requests to avoid flaky tests. +nock.disableNetConnect() + +// Enable outgoing HTTP requests to 127.0.0.1 to allow E2E tests with +// supertestwith supertest to work. +nock.enableNetConnect('127.0.0.1') diff --git a/apps/authz-node/project.json b/apps/authz-node/project.json index e0d3e40c9..745b32963 100644 --- a/apps/authz-node/project.json +++ b/apps/authz-node/project.json @@ -44,6 +44,13 @@ "lintFilePatterns": ["apps/authz-node/**/*.ts"] } }, + + "test:type": { + "executor": "nx:run-commands", + "options": { + "command": "npx tsc --noEmit --project apps/orchestration/tsconfig.app.json" + } + }, "test:unit": { "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], @@ -51,6 +58,13 @@ "jestConfig": "apps/authz-node/jest.unit.ts" } }, + "test:integration": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "apps/authz-node/jest.integration.ts" + } + }, "test:e2e": { "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], diff --git a/apps/authz-node/src/app/__test__/integration/example.spec.ts b/apps/authz-node/src/app/__test__/integration/example.spec.ts new file mode 100644 index 000000000..2f673e194 --- /dev/null +++ b/apps/authz-node/src/app/__test__/integration/example.spec.ts @@ -0,0 +1,5 @@ +describe('Example integration test', () => { + it('foo', () => { + expect(1).toEqual(1) + }) +}) diff --git a/apps/authz-node/src/app/__test__/unit/example.spec.ts b/apps/authz-node/src/app/__test__/unit/example.spec.ts new file mode 100644 index 000000000..b9383243d --- /dev/null +++ b/apps/authz-node/src/app/__test__/unit/example.spec.ts @@ -0,0 +1,5 @@ +describe('Example unit test', () => { + it('foo', () => { + expect(1).toEqual(1) + }) +}) diff --git a/apps/orchestration/Makefile b/apps/orchestration/Makefile index 80ac016e6..3d6e00279 100644 --- a/apps/orchestration/Makefile +++ b/apps/orchestration/Makefile @@ -1,34 +1,41 @@ +ORCHESTRATION_PROJECT_NAME := apps/orchestration +ORCHESTRATION_PROJECT_DIR := ./apps/orchestration +ORCHESTRATION_DATABASE_SCHEMA := ${ORCHESTRATION_PROJECT_DIR}/src/persistence/schema/schema.prisma + orchestration/db/generate-types: npx prisma generate \ - --schema ./apps/orchestration/src/persistence/schema/schema.prisma + --schema ${ORCHESTRATION_DATABASE_SCHEMA} orchestration/db/migrate: - npx dotenv -e ./apps/orchestration/.env -- \ + npx dotenv -e ${ORCHESTRATION_PROJECT_DIR}/.env -- \ prisma migrate dev \ - --schema ./apps/orchestration/src/persistence/schema/schema.prisma + --schema ${ORCHESTRATION_DATABASE_SCHEMA} # Reference: https://www.prisma.io/docs/orm/prisma-migrate/workflows/seeding#seeding-your-database-with-typescript-or-javascript orchestration/db/seed: - npx dotenv -e ./apps/orchestration/.env -- \ + npx dotenv -e ${ORCHESTRATION_PROJECT_DIR}/.env -- \ ts-node \ --compiler-options "{\"module\":\"CommonJS\"}" \ - ./apps/orchestration/src/persistence/seed.ts + ${ORCHESTRATION_PROJECT_DIR}/src/persistence/seed.ts orchestration/test/db/setup: - npx dotenv -e ./apps/orchestration/.env.test --override -- \ + npx dotenv -e ${ORCHESTRATION_PROJECT_DIR}/.env.test --override -- \ prisma migrate reset \ - --schema ./apps/orchestration/src/persistence/schema/schema.prisma \ + --schema ${ORCHESTRATION_DATABASE_SCHEMA} \ --skip-seed \ --force orchestration/test/copy-default-env: - cp ./apps/orchestration/.env.test.default ./apps/orchestration/.env.test + cp ${ORCHESTRATION_PROJECT_DIR}/.env.test.default ${ORCHESTRATION_PROJECT_DIR}/.env.test + +orchestration/test/type: + npx nx test:type ${ORCHESTRATION_PROJECT_NAME} orchestration/test/unit: - npx nx test:unit apps/orchestration + npx nx test:unit ${ORCHESTRATION_PROJECT_NAME} -orchestration/test/type: - npx nx test:type apps/orchestration +orchestration/test/integration: + npx nx test:integration ${ORCHESTRATION_PROJECT_NAME} orchestration/test/e2e: - npx nx test:e2e apps/orchestration + npx nx test:e2e ${ORCHESTRATION_PROJECT_NAME} diff --git a/apps/orchestration/jest.integration.ts b/apps/orchestration/jest.integration.ts new file mode 100644 index 000000000..533d40428 --- /dev/null +++ b/apps/orchestration/jest.integration.ts @@ -0,0 +1,9 @@ +import type { Config } from 'jest' +import sharedConfig from './jest.config' + +const config: Config = { + ...sharedConfig, + testMatch: ['/**/__test__/integration/**/*.spec.ts'] +} + +export default config diff --git a/apps/orchestration/jest.setup.ts b/apps/orchestration/jest.setup.ts index a65efd89b..529d7423f 100644 --- a/apps/orchestration/jest.setup.ts +++ b/apps/orchestration/jest.setup.ts @@ -8,7 +8,7 @@ const envFile = `${__dirname}/.env` // Ensure a test environment variable file exists because of the override config // loading mechanics below. if (!fs.existsSync(testEnvFile)) { - throw new Error('No .env.test file found. Please create one by running "cp .env.test.defaults .env.test".') + throw new Error('No .env.test file found. Please create one by running "make orchestration/test/copy-default-env".') } // We don't want to have two dotenv files that are exactly the same, so we diff --git a/apps/orchestration/project.json b/apps/orchestration/project.json index 40776af09..a4f550db8 100644 --- a/apps/orchestration/project.json +++ b/apps/orchestration/project.json @@ -44,6 +44,12 @@ "lintFilePatterns": ["apps/orchestration/**/*.ts"] } }, + "test:type": { + "executor": "nx:run-commands", + "options": { + "command": "npx tsc --noEmit --project apps/authz-node/tsconfig.app.json" + } + }, "test:unit": { "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], @@ -51,17 +57,18 @@ "jestConfig": "apps/orchestration/jest.unit.ts" } }, - "test:e2e": { + "test:integration": { "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "apps/orchestration/jest.e2e.ts" + "jestConfig": "apps/orchestration/jest.integration.ts" } }, - "test:type": { - "executor": "nx:run-commands", + "test:e2e": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "command": "npx tsc --noEmit --project apps/orchestration/tsconfig.app.json" + "jestConfig": "apps/orchestration/jest.e2e.ts" } } }, diff --git a/apps/orchestration/src/__test__/integration/example.spec.ts b/apps/orchestration/src/__test__/integration/example.spec.ts new file mode 100644 index 000000000..2f673e194 --- /dev/null +++ b/apps/orchestration/src/__test__/integration/example.spec.ts @@ -0,0 +1,5 @@ +describe('Example integration test', () => { + it('foo', () => { + expect(1).toEqual(1) + }) +}) From a5a57d438789bd08c5e59edfc5c564bf7f1afc64 Mon Sep 17 00:00:00 2001 From: William Calderipe Date: Thu, 4 Jan 2024 15:47:48 +0100 Subject: [PATCH 5/5] Generate orchestration Prisma types --- .github/workflows/authz_ci.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/authz_ci.yml b/.github/workflows/authz_ci.yml index d54860a45..e6c7a1bac 100644 --- a/.github/workflows/authz_ci.yml +++ b/.github/workflows/authz_ci.yml @@ -61,12 +61,16 @@ jobs: make format/check make lint/check - # - name: Setup database and Prisma types - # shell: bash - # run: | - # make orchestration/test/copy-default-env - # make orchestration/test/db/setup - # make orchestration/db/generate-types + # TODO: Finish once the authz-node has a database. + - name: Setup database and Prisma types + shell: bash + run: | + # make orchestration/test/copy-default-env + # make orchestration/test/db/setup + + # Generate the orchestration Prisma client types to prevent the type + # tests to fail. + make orchestration/db/generate-types - name: Test types shell: bash