From 2e14f46b3f7221ae51ffa12313997f007c300e21 Mon Sep 17 00:00:00 2001 From: Rauno Viskus Date: Thu, 20 Jan 2022 19:35:08 +0200 Subject: [PATCH] feat: re-enable TAV (#823) Co-authored-by: Valentin Marchaud --- .github/PULL_REQUEST_TEMPLATE.md | 4 + .github/workflows/test-all-versions.yml | 106 ++++++++++++++---- .nycrc | 3 +- .../src/test-utils.ts | 4 +- plugins/node/instrumentation-tedious/.tav.yml | 2 +- .../node/instrumentation-tedious/test/api.ts | 5 +- .../test/instrumentation.test.ts | 4 +- .../.tav.yml | 3 + .../package.json | 2 +- .../.tav.yml | 2 +- .../opentelemetry-instrumentation-pg/.tav.yml | 2 + .../.tav.yml | 2 +- 12 files changed, 105 insertions(+), 34 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8a17e1d13d..f4fa70647d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -20,3 +20,7 @@ Before creating a pull request, please make sure: ## Short description of the changes - + +## Checklist + +- [ ] Ran `npm run test-all-versions` for the edited package(s) on the latest commit if applicable. diff --git a/.github/workflows/test-all-versions.yml b/.github/workflows/test-all-versions.yml index dce4097773..617e2ebc28 100644 --- a/.github/workflows/test-all-versions.yml +++ b/.github/workflows/test-all-versions.yml @@ -1,13 +1,30 @@ -name: Test-all-versions +name: Test All Versions on: - pull_request: - branches: [main] + push: + branches: + - "main" + - "release/**" + - "release-please/**" + schedule: + - cron: "30 4 * * *" + workflow_dispatch: jobs: tav: - # skip the workflow for now #816 - if: false - name: run test-all-version (tav) + name: Run test-all-versions + strategy: + fail-fast: false + matrix: + node: ["8", "10", "12", "14", "16"] + include: + - node: "8" + lerna-extra-args: >- + --ignore @opentelemetry/instrumentation-aws-sdk + --ignore @opentelemetry/instrumentation-pino + --ignore @opentelemetry/instrumentation-tedious + - node: "10" + lerna-extra-args: >- + --ignore @opentelemetry/instrumentation-pino runs-on: ubuntu-latest services: memcached: @@ -18,6 +35,19 @@ jobs: image: mongo ports: - 27017:27017 + mssql: + image: mcr.microsoft.com/mssql/server:2017-latest + env: + SA_PASSWORD: mssql_passw0rd + ACCEPT_EULA: Y + ports: + - 1433:1433 + options: >- + --health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P $SA_PASSWORD -Q 'select 1' -b -o /dev/null" + --health-interval 1s + --health-timeout 30s + --health-start-period 10s + --health-retries 20 mysql: image: circleci/mysql:5.7 env: @@ -62,33 +92,61 @@ jobs: RUN_MEMCACHED_TESTS: 1 RUN_MONGODB_TESTS: 1 RUN_MYSQL_TESTS: 1 + RUN_MSSQL_TESTS: 1 RUN_POSTGRES_TESTS: 1 RUN_REDIS_TESTS: 1 - OPENTELEMETRY_MEMCACHED_HOST: memcached - OPENTELEMETRY_MEMCACHED_PORT: 11211 - POSTGRES_USER: postgres - POSTGRES_DB: circle_database - POSTGRES_HOST: postgres - POSTGRES_PORT: 5432 - OPENTELEMETRY_REDIS_HOST: redis - OPENTELEMETRY_REDIS_PORT: 6379 + CASSANDRA_HOST: localhost MONGODB_DB: opentelemetry-tests MONGODB_HOST: 127.0.0.1 MONGODB_PORT: 27017 - MYSQL_USER: otel - MYSQL_PASSWORD: secret + MSSQL_PASSWORD: mssql_passw0rd MYSQL_DATABASE: circle_database - MYSQL_HOST: mysql + MYSQL_HOST: localhost + MYSQL_PASSWORD: secret MYSQL_PORT: 3306 + MYSQL_USER: otel + OPENTELEMETRY_MEMCACHED_HOST: localhost + OPENTELEMETRY_MEMCACHED_PORT: 11211 + OPENTELEMETRY_REDIS_HOST: localhost + OPENTELEMETRY_REDIS_PORT: 6379 + POSTGRES_DB: circle_database + POSTGRES_HOST: localhost + POSTGRES_PORT: 5432 + POSTGRES_USER: postgres NPM_CONFIG_UNSAFE_PERM: true - CASSANDRA_HOST: cassandra - CASSANDRA_PORT: 9042 steps: - - name: checkout + - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - - run: npm install --ignore-scripts - - run: lerna bootstrap --since origin/main --include-dependencies - - run: lerna run compile --since origin/main --include-dependencies - - run: lerna run test-all-versions --since origin/main --stream --concurrency=1 \ No newline at end of file + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + - name: Cache Dependencies + uses: actions/cache@v2 + with: + path: | + node_modules + package-lock.json + detectors/node/*/node_modules + detectors/node/*/package-lock.json + metapackages/*/node_modules + metapackages/*/package-lock.json + packages/*/node_modules + packages/*/package-lock.json + plugins/node/*/node_modules + plugins/node/*/package-lock.json + plugins/web/*/node_modules + plugins/web/*/package-lock.json + propagators/*/node_modules + propagators/*/package-lock.json + key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package.json', 'detectors/node/*/package.json', 'metapackages/*/package.json', 'packages/*/package.json', 'plugins/node/*/package.json', 'plugins/web/*/package.json', 'propagators/*/package.json') }} + - name: Legacy Peer Dependencies for npm 7 + if: matrix.node == '16' + run: npm config set legacy-peer-deps=true + - name: Install Root Dependencies + run: npm install --ignore-scripts + - name: Bootstrap Dependencies + run: lerna bootstrap --no-ci --hoist --nohoist='zone.js' --nohoist='mocha' --nohoist='ts-mocha' + - name: Run test-all-versions + run: lerna run test-all-versions ${{ matrix.lerna-extra-args }} --stream --concurrency 1 diff --git a/.nycrc b/.nycrc index 603b7fc56f..1034a3b8ae 100644 --- a/.nycrc +++ b/.nycrc @@ -6,9 +6,10 @@ "**/*.d.ts", "build/**/**/*.js", "src/index.ts", + "src/version.ts", "karma.conf.js", "src/platform/browser/*.ts", - "test/index-webpack.ts", + "test/*.ts", "webpack/*.js", ".eslintrc.js" ], diff --git a/packages/opentelemetry-test-utils/src/test-utils.ts b/packages/opentelemetry-test-utils/src/test-utils.ts index de3338b974..e2b0220d73 100644 --- a/packages/opentelemetry-test-utils/src/test-utils.ts +++ b/packages/opentelemetry-test-utils/src/test-utils.ts @@ -144,7 +144,9 @@ export interface TimedEvent { } export const getPackageVersion = (packageName: string) => { - const packagePath = require.resolve(packageName); + const packagePath = require?.resolve(packageName, { + paths: require?.main?.paths, + }); const packageJsonPath = path.join(path.dirname(packagePath), 'package.json'); return require(packageJsonPath).version; }; diff --git a/plugins/node/instrumentation-tedious/.tav.yml b/plugins/node/instrumentation-tedious/.tav.yml index 6c0737e66e..22db589193 100644 --- a/plugins/node/instrumentation-tedious/.tav.yml +++ b/plugins/node/instrumentation-tedious/.tav.yml @@ -1,6 +1,6 @@ tedious: # 4.0.0 is broken: https://github.com/tediousjs/tedious/commit/4eceb48 - versions: ">=1.11.0 <4 || >=4.0.1" + versions: "1.11.0 || 1.14.0 || 2.7.1 || 3.0.1 || 4.2.0 || ^6.7.0 || 8.3.0 || 9.2.3 || 11.0.9 || 11.2.0 || 11.4.0 || ^11.8.0 || ^12.3.0 || ^13.2.0 || ^14.0.0" commands: npm run test # Fix missing `test-utils` package diff --git a/plugins/node/instrumentation-tedious/test/api.ts b/plugins/node/instrumentation-tedious/test/api.ts index d01a986d31..452cf27ea0 100644 --- a/plugins/node/instrumentation-tedious/test/api.ts +++ b/plugins/node/instrumentation-tedious/test/api.ts @@ -250,6 +250,7 @@ export const makeApi = (tedious: tedious) => { const bulkLoad = { tableName: '[dbo].[test_bulk]', + tableNameShort: 'test_bulk', createTable: (connection: Connection): Promise => { return new Promise((resolve, reject) => { const sql = ` @@ -276,9 +277,9 @@ export const makeApi = (tedious: tedious) => { // <2.2.0 didn't take bulkOptions const request = connection.newBulkLoad.length === 2 - ? connection.newBulkLoad(bulkLoad.tableName, requestDoneCb) + ? connection.newBulkLoad(bulkLoad.tableNameShort, requestDoneCb) : (connection.newBulkLoad as any)( - bulkLoad.tableName, + bulkLoad.tableNameShort, { keepNulls: true }, requestDoneCb ); diff --git a/plugins/node/instrumentation-tedious/test/instrumentation.test.ts b/plugins/node/instrumentation-tedious/test/instrumentation.test.ts index 245f2d9f3c..0f8f8a74b6 100644 --- a/plugins/node/instrumentation-tedious/test/instrumentation.test.ts +++ b/plugins/node/instrumentation-tedious/test/instrumentation.test.ts @@ -296,9 +296,9 @@ describe('tedious', () => { procCount: 0, }); assertSpan(spans[2], { - name: 'execBulkLoad [dbo].[test_bulk] master', + name: 'execBulkLoad test_bulk master', procCount: 0, - table: '[dbo].[test_bulk]', + table: 'test_bulk', }); }); }); diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/.tav.yml b/plugins/node/opentelemetry-instrumentation-mongodb/.tav.yml index 837d38d856..d5c0521307 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/.tav.yml +++ b/plugins/node/opentelemetry-instrumentation-mongodb/.tav.yml @@ -1,3 +1,6 @@ mongodb: versions: ">=3.3 <4" commands: npm run test + + # Fix missing `contrib-test-utils` package + pretest: npm run --prefix ../../../ lerna:link diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/package.json b/plugins/node/opentelemetry-instrumentation-mongodb/package.json index 74ae24488b..570e1ddd08 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/package.json +++ b/plugins/node/opentelemetry-instrumentation-mongodb/package.json @@ -7,7 +7,7 @@ "repository": "open-telemetry/opentelemetry-js-contrib", "scripts": { "docker:start": "docker run -e MONGODB_DB=opentelemetry-tests -e MONGODB_PORT=27017 -e MONGODB_HOST=localhost -p 27017:27017 --rm mongo", - "test": "nyc ts-mocha --parallel -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/**/*.test.ts'", + "test": "nyc ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/**/*.test.ts'", "test-all-versions": "tav", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "tdd": "npm run test -- --watch-extensions ts --watch", diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/.tav.yml b/plugins/node/opentelemetry-instrumentation-mysql2/.tav.yml index d792dfa3d1..eebc9f9b35 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/.tav.yml +++ b/plugins/node/opentelemetry-instrumentation-mysql2/.tav.yml @@ -3,4 +3,4 @@ mysql2: commands: npm run test # Fix missing `test-utils` package - pretest: npm run --prefix ../../../ lerna:link + pretest: npm run --prefix ../../../ lerna:link diff --git a/plugins/node/opentelemetry-instrumentation-pg/.tav.yml b/plugins/node/opentelemetry-instrumentation-pg/.tav.yml index 754874d467..42321ea8b8 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/.tav.yml +++ b/plugins/node/opentelemetry-instrumentation-pg/.tav.yml @@ -2,7 +2,9 @@ pg: # a sample from supported versions - versions: "8.5.1 || 8.6.0 || 8.7.1" peerDependencies: pg-pool@^3 + pretest: npm run --prefix ../../../ lerna:link commands: npm run test - versions: "7.3.0 || 7.12.1 || 7.18.2" peerDependencies: pg-pool@^2 + pretest: npm run --prefix ../../../ lerna:link commands: npm run test diff --git a/plugins/node/opentelemetry-instrumentation-redis/.tav.yml b/plugins/node/opentelemetry-instrumentation-redis/.tav.yml index 24622537c6..d22ee83fdf 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/.tav.yml +++ b/plugins/node/opentelemetry-instrumentation-redis/.tav.yml @@ -3,4 +3,4 @@ redis: commands: npm run test # Fix missing `contrib-test-utils` package - pretest: npm run --prefix ../../../ lerna:link + pretest: npm run --prefix ../../../ lerna:link