From 8310000cf10b27f84867cc70e02f27c1ac0a74fd Mon Sep 17 00:00:00 2001 From: Yiming Date: Wed, 24 Apr 2024 08:57:40 +0800 Subject: [PATCH] chore: split test runs in CI (#1277) --- .github/workflows/integration-test.yml | 104 ++++++++++++++++ .github/workflows/regression-test.yml | 104 ++++++++++++++++ package.json | 4 +- .../testtools/src}/jest-ext.ts | 1 + pnpm-lock.yaml | 114 ++++++++---------- tests/integration/test-setup.ts | 2 +- tests/integration/tsconfig.json | 2 +- tests/integration/utils/index.ts | 1 - tests/regression/.eslintrc.json | 13 ++ tests/regression/jest.config.ts | 10 ++ tests/regression/jest.d.ts | 16 +++ tests/regression/package.json | 24 ++++ tests/regression/test-setup.ts | 17 +++ .../tests}/issue-1014.test.ts | 0 .../tests}/issue-1078.test.ts | 0 .../tests}/issue-1080.test.ts | 0 .../tests}/issue-1129.test.ts | 0 .../tests}/issue-1167.test.ts | 0 .../tests}/issue-1179.test.ts | 0 .../tests}/issue-1186.test.ts | 0 .../tests}/issue-1210.test.ts | 0 .../tests}/issue-1235.test.ts | 0 .../tests}/issue-1241.test.ts | 0 .../tests}/issue-1257.test.ts | 0 .../tests}/issue-1265.test.ts | 0 .../tests}/issue-177.test.ts | 0 .../tests}/issue-416.test.ts | 0 .../tests}/issue-646.test.ts | 0 .../tests}/issue-657.test.ts | 0 .../tests}/issue-665.test.ts | 0 .../tests}/issue-674.test.ts | 0 .../tests}/issue-689.test.ts | 0 .../tests}/issue-703.test.ts | 0 .../tests}/issue-714.test.ts | 0 .../tests}/issue-724.test.ts | 0 .../tests}/issue-735.test.ts | 0 .../tests}/issue-744.test.ts | 0 .../tests}/issue-756.test.ts | 0 .../tests}/issue-764.test.ts | 0 .../tests}/issue-765.test.ts | 0 .../tests}/issue-804.test.ts | 0 .../tests}/issue-811.test.ts | 0 .../tests}/issue-814.test.ts | 0 .../tests}/issue-825.test.ts | 0 .../tests}/issue-864.test.ts | 0 .../tests}/issue-886.test.ts | 0 .../tests}/issue-925.test.ts | 0 .../tests}/issue-947.test.ts | 0 .../tests}/issue-961.test.ts | 0 .../tests}/issue-965.test.ts | 0 .../tests}/issue-971.test.ts | 0 .../tests}/issue-992.test.ts | 0 .../tests}/issues.test.ts | 0 tests/regression/tsconfig.json | 12 ++ 54 files changed, 355 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/integration-test.yml create mode 100644 .github/workflows/regression-test.yml rename {tests/integration/utils => packages/testtools/src}/jest-ext.ts (98%) delete mode 100644 tests/integration/utils/index.ts create mode 100644 tests/regression/.eslintrc.json create mode 100644 tests/regression/jest.config.ts create mode 100644 tests/regression/jest.d.ts create mode 100644 tests/regression/package.json create mode 100644 tests/regression/test-setup.ts rename tests/{integration/tests/regression => regression/tests}/issue-1014.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-1078.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-1080.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-1129.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-1167.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-1179.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-1186.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-1210.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-1235.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-1241.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-1257.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-1265.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-177.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-416.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-646.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-657.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-665.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-674.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-689.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-703.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-714.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-724.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-735.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-744.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-756.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-764.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-765.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-804.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-811.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-814.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-825.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-864.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-886.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-925.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-947.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-961.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-965.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-971.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issue-992.test.ts (100%) rename tests/{integration/tests/regression => regression/tests}/issues.test.ts (100%) create mode 100644 tests/regression/tsconfig.json diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 000000000..fb3c0bfb0 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,104 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Integration Tests + +env: + TELEMETRY_TRACKING_TOKEN: ${{ secrets.TELEMETRY_TRACKING_TOKEN }} + DO_NOT_TRACK: '1' + +on: + merge_group: + push: + branches: + - main + - dev + - release/* + - v2 + pull_request: + branches: + - main + - dev + - release/* + - v2 + +permissions: + contents: read + +jobs: + build-test: + runs-on: buildjet-8vcpu-ubuntu-2204 + + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: abc123 + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + strategy: + matrix: + node-version: [20.x] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: ^7.15.0 + + - name: Use Node.js ${{ matrix.node-version }} + uses: buildjet/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Setup pnpm cache + uses: buildjet/cache@v3 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Gradle Wrapper Validation + uses: gradle/wrapper-validation-action@v1.1.0 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2.4.2 + with: + gradle-home-cache-cleanup: true + + - name: Build + run: DEFAULT_NPM_TAG=latest pnpm run build + + # install again for internal dependencies + - name: Install internal dependencies + run: pnpm install --frozen-lockfile + + - name: Integration Test + run: pnpm run test-scaffold && pnpm run test-integration diff --git a/.github/workflows/regression-test.yml b/.github/workflows/regression-test.yml new file mode 100644 index 000000000..679cc2b4c --- /dev/null +++ b/.github/workflows/regression-test.yml @@ -0,0 +1,104 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Regression Tests + +env: + TELEMETRY_TRACKING_TOKEN: ${{ secrets.TELEMETRY_TRACKING_TOKEN }} + DO_NOT_TRACK: '1' + +on: + merge_group: + push: + branches: + - main + - dev + - release/* + - v2 + pull_request: + branches: + - main + - dev + - release/* + - v2 + +permissions: + contents: read + +jobs: + build-test: + runs-on: buildjet-8vcpu-ubuntu-2204 + + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: abc123 + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + strategy: + matrix: + node-version: [20.x] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: ^7.15.0 + + - name: Use Node.js ${{ matrix.node-version }} + uses: buildjet/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Setup pnpm cache + uses: buildjet/cache@v3 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Gradle Wrapper Validation + uses: gradle/wrapper-validation-action@v1.1.0 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2.4.2 + with: + gradle-home-cache-cleanup: true + + - name: Build + run: DEFAULT_NPM_TAG=latest pnpm run build + + # install again for internal dependencies + - name: Install internal dependencies + run: pnpm install --frozen-lockfile + + - name: Regression Test + run: pnpm run test-scaffold && pnpm run test-regression diff --git a/package.json b/package.json index 61a941bbf..d28d5eb68 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "build": "pnpm -r build", "lint": "pnpm -r lint", "test": "pnpm -r --parallel run test --silent --forceExit", - "test-ci": "pnpm -r --parallel run test --silent --forceExit", + "test-ci": "pnpm -r --parallel run --filter=\"./packages/**\" test --silent --forceExit", + "test-integration": "pnpm run --filter=integration test --silent --forceExit", + "test-regression": "pnpm run --filter=regression test --silent --forceExit", "test-scaffold": "tsx script/test-scaffold.ts", "publish-all": "pnpm --filter \"./packages/**\" -r publish --access public", "publish-preview": "pnpm --filter \"./packages/**\" -r publish --force --registry https://preview.registry.zenstack.dev/", diff --git a/tests/integration/utils/jest-ext.ts b/packages/testtools/src/jest-ext.ts similarity index 98% rename from tests/integration/utils/jest-ext.ts rename to packages/testtools/src/jest-ext.ts index ee24741a5..244ba40f3 100644 --- a/tests/integration/utils/jest-ext.ts +++ b/packages/testtools/src/jest-ext.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import { format } from 'util'; import { isPrismaClientKnownRequestError } from '@zenstackhq/runtime'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8f14f0dee..a86c803b7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -853,6 +853,31 @@ importers: specifier: 'workspace: *' version: link:../../packages/schema/dist + tests/regression: + dependencies: + '@types/node': + specifier: ^18.0.0 + version: 18.0.0 + '@zenstackhq/sdk': + specifier: workspace:* + version: link:../../packages/sdk/dist + '@zenstackhq/testtools': + specifier: workspace:* + version: link:../../packages/testtools/dist + decimal.js: + specifier: ^10.4.2 + version: 10.4.2 + devDependencies: + '@zenstackhq/runtime': + specifier: workspace:* + version: link:../../packages/runtime/dist + '@zenstackhq/server': + specifier: workspace:* + version: link:../../packages/server/dist + zenstack: + specifier: 'workspace: *' + version: link:../../packages/schema/dist + packages: /@aashutoshrathi/word-wrap@1.2.6: @@ -2742,7 +2767,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 18.0.0 + '@types/node': 20.10.2 chalk: 4.1.2 jest-message-util: 29.7.0 jest-util: 29.7.0 @@ -2763,14 +2788,14 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.0.0 + '@types/node': 20.10.2 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.8.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@18.0.0)(ts-node@10.9.1) + jest-config: 29.7.0(@types/node@20.10.2)(ts-node@10.9.1) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -2798,7 +2823,7 @@ packages: dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.0.0 + '@types/node': 20.10.2 jest-mock: 29.7.0 dev: true @@ -2825,7 +2850,7 @@ packages: dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 18.0.0 + '@types/node': 20.10.2 jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -2858,7 +2883,7 @@ packages: '@jest/transform': 29.7.0 '@jest/types': 29.6.3 '@jridgewell/trace-mapping': 0.3.18 - '@types/node': 18.0.0 + '@types/node': 20.10.2 chalk: 4.1.2 collect-v8-coverage: 1.0.1 exit: 0.1.2 @@ -2946,7 +2971,7 @@ packages: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.4 '@types/istanbul-reports': 3.0.1 - '@types/node': 18.0.0 + '@types/node': 20.10.2 '@types/yargs': 17.0.24 chalk: 4.1.2 dev: true @@ -4706,7 +4731,7 @@ packages: /@types/connect@3.4.35: resolution: {integrity: sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==} dependencies: - '@types/node': 18.0.0 + '@types/node': 20.10.2 dev: true /@types/cookie@0.5.1: @@ -4724,7 +4749,7 @@ packages: /@types/express-serve-static-core@4.17.35: resolution: {integrity: sha512-wALWQwrgiB2AWTT91CB62b6Yt0sNHpznUXeZEcnPU3DRdlDIz74x8Qg1UUYKSVFi+va5vKOLYRBI1bRKiLLKIg==} dependencies: - '@types/node': 18.0.0 + '@types/node': 20.10.2 '@types/qs': 6.9.7 '@types/range-parser': 1.2.4 '@types/send': 0.17.1 @@ -4759,7 +4784,7 @@ packages: /@types/http-proxy@1.17.12: resolution: {integrity: sha512-kQtujO08dVtQ2wXAuSFfk9ASy3sug4+ogFR8Kd8UgP8PEuc1/G/8yjYRmp//PcDNJEUKOza/MrQu15bouEUCiw==} dependencies: - '@types/node': 18.0.0 + '@types/node': 20.10.2 dev: true /@types/is-ci@3.0.0: @@ -4794,7 +4819,7 @@ packages: /@types/jsdom@20.0.1: resolution: {integrity: sha512-d0r18sZPmMQr1eG35u12FZfhIXNrnsPU/g5wvRKCUf/tOGilKKwYMYGqh33BNR6ba+2gkHw1EUiHoN3mn7E5IQ==} dependencies: - '@types/node': 18.0.0 + '@types/node': 20.10.2 '@types/tough-cookie': 4.0.4 parse5: 7.1.2 dev: true @@ -4810,7 +4835,7 @@ packages: /@types/jsonfile@6.1.1: resolution: {integrity: sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png==} dependencies: - '@types/node': 18.0.0 + '@types/node': 20.10.2 dev: true /@types/line-column@1.0.0: @@ -4920,7 +4945,7 @@ packages: resolution: {integrity: sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==} dependencies: '@types/mime': 1.3.2 - '@types/node': 18.0.0 + '@types/node': 20.10.2 dev: true /@types/serve-static@1.15.2: @@ -4928,7 +4953,7 @@ packages: dependencies: '@types/http-errors': 2.0.1 '@types/mime': 3.0.1 - '@types/node': 18.0.0 + '@types/node': 20.10.2 dev: true /@types/stack-utils@2.0.1: @@ -4943,7 +4968,7 @@ packages: resolution: {integrity: sha512-LOWgpacIV8GHhrsQU+QMZuomfqXiqzz3ILLkCtKx3Us6AmomFViuzKT9D693QTKgyut2oCytMG8/efOop+DB+w==} dependencies: '@types/cookiejar': 2.1.2 - '@types/node': 18.0.0 + '@types/node': 20.10.2 dev: true /@types/supertest@2.0.12: @@ -9610,7 +9635,7 @@ packages: '@jest/expect': 29.7.0 '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.0.0 + '@types/node': 20.10.2 chalk: 4.1.2 co: 4.6.0 dedent: 1.5.1 @@ -9659,47 +9684,6 @@ packages: - ts-node dev: true - /jest-config@29.7.0(@types/node@18.0.0)(ts-node@10.9.1): - resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - '@types/node': '*' - ts-node: '>=9.0.0' - peerDependenciesMeta: - '@types/node': - optional: true - ts-node: - optional: true - dependencies: - '@babel/core': 7.23.2 - '@jest/test-sequencer': 29.7.0 - '@jest/types': 29.6.3 - '@types/node': 18.0.0 - babel-jest: 29.7.0(@babel/core@7.23.2) - chalk: 4.1.2 - ci-info: 3.8.0 - deepmerge: 4.3.1 - glob: 7.2.3 - graceful-fs: 4.2.11 - jest-circus: 29.7.0 - jest-environment-node: 29.7.0 - jest-get-type: 29.6.3 - jest-regex-util: 29.6.3 - jest-resolve: 29.7.0 - jest-runner: 29.7.0 - jest-util: 29.7.0 - jest-validate: 29.7.0 - micromatch: 4.0.5 - parse-json: 5.2.0 - pretty-format: 29.7.0 - slash: 3.0.0 - strip-json-comments: 3.1.1 - ts-node: 10.9.1(@types/node@20.10.2)(typescript@5.4.4) - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - dev: true - /jest-config@29.7.0(@types/node@20.10.2)(ts-node@10.9.1): resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -9799,7 +9783,7 @@ packages: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.0.0 + '@types/node': 20.10.2 jest-mock: 29.7.0 jest-util: 29.7.0 dev: true @@ -9824,7 +9808,7 @@ packages: dependencies: '@jest/types': 29.6.3 '@types/graceful-fs': 4.1.6 - '@types/node': 18.0.0 + '@types/node': 20.10.2 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -9875,7 +9859,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 18.0.0 + '@types/node': 20.10.2 jest-util: 29.7.0 dev: true @@ -9930,7 +9914,7 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.0.0 + '@types/node': 20.10.2 chalk: 4.1.2 emittery: 0.13.1 graceful-fs: 4.2.11 @@ -9961,7 +9945,7 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.0.0 + '@types/node': 20.10.2 chalk: 4.1.2 cjs-module-lexer: 1.2.3 collect-v8-coverage: 1.0.1 @@ -10013,7 +9997,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 18.0.0 + '@types/node': 20.10.2 chalk: 4.1.2 ci-info: 3.8.0 graceful-fs: 4.2.11 @@ -10038,7 +10022,7 @@ packages: dependencies: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 18.0.0 + '@types/node': 20.10.2 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.13.1 @@ -10050,7 +10034,7 @@ packages: resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: - '@types/node': 18.0.0 + '@types/node': 20.10.2 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 diff --git a/tests/integration/test-setup.ts b/tests/integration/test-setup.ts index 6936a0cd4..b6147c287 100644 --- a/tests/integration/test-setup.ts +++ b/tests/integration/test-setup.ts @@ -5,7 +5,7 @@ import { toResolveFalsy, toResolveNull, toBeRejectedWithCode, -} from './utils/jest-ext'; +} from '@zenstackhq/testtools/jest-ext'; expect.extend({ toBeRejectedByPolicy, diff --git a/tests/integration/tsconfig.json b/tests/integration/tsconfig.json index 2771cd805..c6cc8d4a7 100644 --- a/tests/integration/tsconfig.json +++ b/tests/integration/tsconfig.json @@ -8,5 +8,5 @@ "skipLibCheck": true, "experimentalDecorators": true }, - "include": ["**/*.ts", "**/*.d.ts"] + "include": ["**/*.ts", "**/*.d.ts", "../regression/tests/issue-177.test.ts", "../regression/tests/issue-416.test.ts", "../regression/tests/issue-646.test.ts", "../regression/tests/issue-657.test.ts", "../regression/tests/issue-665.test.ts", "../regression/tests/issue-674.test.ts", "../regression/tests/issue-689.test.ts", "../regression/tests/issue-703.test.ts", "../regression/tests/issue-714.test.ts", "../regression/tests/issue-724.test.ts", "../regression/tests/issue-735.test.ts", "../regression/tests/issue-744.test.ts", "../regression/tests/issue-756.test.ts", "../regression/tests/issue-764.test.ts", "../regression/tests/issue-765.test.ts", "../regression/tests/issue-804.test.ts", "../regression/tests/issue-811.test.ts", "../regression/tests/issue-814.test.ts", "../regression/tests/issue-825.test.ts", "../regression/tests/issue-864.test.ts", "../regression/tests/issue-886.test.ts", "../regression/tests/issue-925.test.ts", "../regression/tests/issue-947.test.ts", "../regression/tests/issue-961.test.ts", "../regression/tests/issue-965.test.ts", "../regression/tests/issue-971.test.ts", "../regression/tests/issue-992.test.ts", "../regression/tests/issue-1014.test.ts", "../regression/tests/issue-1078.test.ts", "../regression/tests/issue-1080.test.ts", "../regression/tests/issue-1129.test.ts", "../regression/tests/issue-1167.test.ts", "../regression/tests/issue-1179.test.ts", "../regression/tests/issue-1186.test.ts", "../regression/tests/issue-1210.test.ts", "../regression/tests/issue-1235.test.ts", "../regression/tests/issue-1241.test.ts", "../regression/tests/issue-1257.test.ts", "../regression/tests/issue-1265.test.ts", "../regression/tests/issues.test.ts"] } diff --git a/tests/integration/utils/index.ts b/tests/integration/utils/index.ts deleted file mode 100644 index 04bca77e0..000000000 --- a/tests/integration/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './utils'; diff --git a/tests/regression/.eslintrc.json b/tests/regression/.eslintrc.json new file mode 100644 index 000000000..24ebad85a --- /dev/null +++ b/tests/regression/.eslintrc.json @@ -0,0 +1,13 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module" + }, + "plugins": ["@typescript-eslint"], + "extends": ["plugin:jest/recommended"], + "rules": { + "jest/expect-expect": "off" + } +} diff --git a/tests/regression/jest.config.ts b/tests/regression/jest.config.ts new file mode 100644 index 000000000..67a118269 --- /dev/null +++ b/tests/regression/jest.config.ts @@ -0,0 +1,10 @@ +import baseConfig from '../../jest.config'; + +/* + * For a detailed explanation regarding each configuration property and type check, visit: + * https://jestjs.io/docs/configuration + */ +export default { + ...baseConfig, + setupFilesAfterEnv: ['./test-setup.ts'], +}; diff --git a/tests/regression/jest.d.ts b/tests/regression/jest.d.ts new file mode 100644 index 000000000..ff066029a --- /dev/null +++ b/tests/regression/jest.d.ts @@ -0,0 +1,16 @@ +interface CustomMatchers { + toBeRejectedByPolicy(expectedMessages?: string[]): Promise; + toBeNotFound(): Promise; + toResolveTruthy(): Promise; + toResolveFalsy(): Promise; + toResolveNull(): Promise; + toBeRejectedWithCode(code: string): Promise; +} +declare global { + namespace jest { + interface Expect extends CustomMatchers {} + interface Matchers extends CustomMatchers {} + interface InverseAsymmetricMatchers extends CustomMatchers {} + } +} +export {}; diff --git a/tests/regression/package.json b/tests/regression/package.json new file mode 100644 index 000000000..20f5cbc30 --- /dev/null +++ b/tests/regression/package.json @@ -0,0 +1,24 @@ +{ + "name": "regression", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "lint": "eslint . --ext .ts", + "test": "jest" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@zenstackhq/runtime": "workspace:*", + "@zenstackhq/server": "workspace:*", + "zenstack": "workspace: *" + }, + "dependencies": { + "@types/node": "^18.0.0", + "@zenstackhq/sdk": "workspace:*", + "@zenstackhq/testtools": "workspace:*", + "decimal.js": "^10.4.2" + } +} diff --git a/tests/regression/test-setup.ts b/tests/regression/test-setup.ts new file mode 100644 index 000000000..89142216d --- /dev/null +++ b/tests/regression/test-setup.ts @@ -0,0 +1,17 @@ +import { + toBeNotFound, + toBeRejectedByPolicy, + toBeRejectedWithCode, + toResolveFalsy, + toResolveNull, + toResolveTruthy, +} from '@zenstackhq/testtools/jest-ext'; + +expect.extend({ + toBeRejectedByPolicy, + toBeNotFound, + toResolveTruthy, + toResolveFalsy, + toResolveNull, + toBeRejectedWithCode, +}); diff --git a/tests/integration/tests/regression/issue-1014.test.ts b/tests/regression/tests/issue-1014.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1014.test.ts rename to tests/regression/tests/issue-1014.test.ts diff --git a/tests/integration/tests/regression/issue-1078.test.ts b/tests/regression/tests/issue-1078.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1078.test.ts rename to tests/regression/tests/issue-1078.test.ts diff --git a/tests/integration/tests/regression/issue-1080.test.ts b/tests/regression/tests/issue-1080.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1080.test.ts rename to tests/regression/tests/issue-1080.test.ts diff --git a/tests/integration/tests/regression/issue-1129.test.ts b/tests/regression/tests/issue-1129.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1129.test.ts rename to tests/regression/tests/issue-1129.test.ts diff --git a/tests/integration/tests/regression/issue-1167.test.ts b/tests/regression/tests/issue-1167.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1167.test.ts rename to tests/regression/tests/issue-1167.test.ts diff --git a/tests/integration/tests/regression/issue-1179.test.ts b/tests/regression/tests/issue-1179.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1179.test.ts rename to tests/regression/tests/issue-1179.test.ts diff --git a/tests/integration/tests/regression/issue-1186.test.ts b/tests/regression/tests/issue-1186.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1186.test.ts rename to tests/regression/tests/issue-1186.test.ts diff --git a/tests/integration/tests/regression/issue-1210.test.ts b/tests/regression/tests/issue-1210.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1210.test.ts rename to tests/regression/tests/issue-1210.test.ts diff --git a/tests/integration/tests/regression/issue-1235.test.ts b/tests/regression/tests/issue-1235.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1235.test.ts rename to tests/regression/tests/issue-1235.test.ts diff --git a/tests/integration/tests/regression/issue-1241.test.ts b/tests/regression/tests/issue-1241.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1241.test.ts rename to tests/regression/tests/issue-1241.test.ts diff --git a/tests/integration/tests/regression/issue-1257.test.ts b/tests/regression/tests/issue-1257.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1257.test.ts rename to tests/regression/tests/issue-1257.test.ts diff --git a/tests/integration/tests/regression/issue-1265.test.ts b/tests/regression/tests/issue-1265.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-1265.test.ts rename to tests/regression/tests/issue-1265.test.ts diff --git a/tests/integration/tests/regression/issue-177.test.ts b/tests/regression/tests/issue-177.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-177.test.ts rename to tests/regression/tests/issue-177.test.ts diff --git a/tests/integration/tests/regression/issue-416.test.ts b/tests/regression/tests/issue-416.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-416.test.ts rename to tests/regression/tests/issue-416.test.ts diff --git a/tests/integration/tests/regression/issue-646.test.ts b/tests/regression/tests/issue-646.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-646.test.ts rename to tests/regression/tests/issue-646.test.ts diff --git a/tests/integration/tests/regression/issue-657.test.ts b/tests/regression/tests/issue-657.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-657.test.ts rename to tests/regression/tests/issue-657.test.ts diff --git a/tests/integration/tests/regression/issue-665.test.ts b/tests/regression/tests/issue-665.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-665.test.ts rename to tests/regression/tests/issue-665.test.ts diff --git a/tests/integration/tests/regression/issue-674.test.ts b/tests/regression/tests/issue-674.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-674.test.ts rename to tests/regression/tests/issue-674.test.ts diff --git a/tests/integration/tests/regression/issue-689.test.ts b/tests/regression/tests/issue-689.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-689.test.ts rename to tests/regression/tests/issue-689.test.ts diff --git a/tests/integration/tests/regression/issue-703.test.ts b/tests/regression/tests/issue-703.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-703.test.ts rename to tests/regression/tests/issue-703.test.ts diff --git a/tests/integration/tests/regression/issue-714.test.ts b/tests/regression/tests/issue-714.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-714.test.ts rename to tests/regression/tests/issue-714.test.ts diff --git a/tests/integration/tests/regression/issue-724.test.ts b/tests/regression/tests/issue-724.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-724.test.ts rename to tests/regression/tests/issue-724.test.ts diff --git a/tests/integration/tests/regression/issue-735.test.ts b/tests/regression/tests/issue-735.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-735.test.ts rename to tests/regression/tests/issue-735.test.ts diff --git a/tests/integration/tests/regression/issue-744.test.ts b/tests/regression/tests/issue-744.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-744.test.ts rename to tests/regression/tests/issue-744.test.ts diff --git a/tests/integration/tests/regression/issue-756.test.ts b/tests/regression/tests/issue-756.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-756.test.ts rename to tests/regression/tests/issue-756.test.ts diff --git a/tests/integration/tests/regression/issue-764.test.ts b/tests/regression/tests/issue-764.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-764.test.ts rename to tests/regression/tests/issue-764.test.ts diff --git a/tests/integration/tests/regression/issue-765.test.ts b/tests/regression/tests/issue-765.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-765.test.ts rename to tests/regression/tests/issue-765.test.ts diff --git a/tests/integration/tests/regression/issue-804.test.ts b/tests/regression/tests/issue-804.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-804.test.ts rename to tests/regression/tests/issue-804.test.ts diff --git a/tests/integration/tests/regression/issue-811.test.ts b/tests/regression/tests/issue-811.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-811.test.ts rename to tests/regression/tests/issue-811.test.ts diff --git a/tests/integration/tests/regression/issue-814.test.ts b/tests/regression/tests/issue-814.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-814.test.ts rename to tests/regression/tests/issue-814.test.ts diff --git a/tests/integration/tests/regression/issue-825.test.ts b/tests/regression/tests/issue-825.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-825.test.ts rename to tests/regression/tests/issue-825.test.ts diff --git a/tests/integration/tests/regression/issue-864.test.ts b/tests/regression/tests/issue-864.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-864.test.ts rename to tests/regression/tests/issue-864.test.ts diff --git a/tests/integration/tests/regression/issue-886.test.ts b/tests/regression/tests/issue-886.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-886.test.ts rename to tests/regression/tests/issue-886.test.ts diff --git a/tests/integration/tests/regression/issue-925.test.ts b/tests/regression/tests/issue-925.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-925.test.ts rename to tests/regression/tests/issue-925.test.ts diff --git a/tests/integration/tests/regression/issue-947.test.ts b/tests/regression/tests/issue-947.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-947.test.ts rename to tests/regression/tests/issue-947.test.ts diff --git a/tests/integration/tests/regression/issue-961.test.ts b/tests/regression/tests/issue-961.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-961.test.ts rename to tests/regression/tests/issue-961.test.ts diff --git a/tests/integration/tests/regression/issue-965.test.ts b/tests/regression/tests/issue-965.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-965.test.ts rename to tests/regression/tests/issue-965.test.ts diff --git a/tests/integration/tests/regression/issue-971.test.ts b/tests/regression/tests/issue-971.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-971.test.ts rename to tests/regression/tests/issue-971.test.ts diff --git a/tests/integration/tests/regression/issue-992.test.ts b/tests/regression/tests/issue-992.test.ts similarity index 100% rename from tests/integration/tests/regression/issue-992.test.ts rename to tests/regression/tests/issue-992.test.ts diff --git a/tests/integration/tests/regression/issues.test.ts b/tests/regression/tests/issues.test.ts similarity index 100% rename from tests/integration/tests/regression/issues.test.ts rename to tests/regression/tests/issues.test.ts diff --git a/tests/regression/tsconfig.json b/tests/regression/tsconfig.json new file mode 100644 index 000000000..c6cc8d4a7 --- /dev/null +++ b/tests/regression/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "esnext", + "module": "commonjs", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "experimentalDecorators": true + }, + "include": ["**/*.ts", "**/*.d.ts", "../regression/tests/issue-177.test.ts", "../regression/tests/issue-416.test.ts", "../regression/tests/issue-646.test.ts", "../regression/tests/issue-657.test.ts", "../regression/tests/issue-665.test.ts", "../regression/tests/issue-674.test.ts", "../regression/tests/issue-689.test.ts", "../regression/tests/issue-703.test.ts", "../regression/tests/issue-714.test.ts", "../regression/tests/issue-724.test.ts", "../regression/tests/issue-735.test.ts", "../regression/tests/issue-744.test.ts", "../regression/tests/issue-756.test.ts", "../regression/tests/issue-764.test.ts", "../regression/tests/issue-765.test.ts", "../regression/tests/issue-804.test.ts", "../regression/tests/issue-811.test.ts", "../regression/tests/issue-814.test.ts", "../regression/tests/issue-825.test.ts", "../regression/tests/issue-864.test.ts", "../regression/tests/issue-886.test.ts", "../regression/tests/issue-925.test.ts", "../regression/tests/issue-947.test.ts", "../regression/tests/issue-961.test.ts", "../regression/tests/issue-965.test.ts", "../regression/tests/issue-971.test.ts", "../regression/tests/issue-992.test.ts", "../regression/tests/issue-1014.test.ts", "../regression/tests/issue-1078.test.ts", "../regression/tests/issue-1080.test.ts", "../regression/tests/issue-1129.test.ts", "../regression/tests/issue-1167.test.ts", "../regression/tests/issue-1179.test.ts", "../regression/tests/issue-1186.test.ts", "../regression/tests/issue-1210.test.ts", "../regression/tests/issue-1235.test.ts", "../regression/tests/issue-1241.test.ts", "../regression/tests/issue-1257.test.ts", "../regression/tests/issue-1265.test.ts", "../regression/tests/issues.test.ts"] +}