From 22cc2b5fa3c1368d70adb87ca722892468ab3bfe Mon Sep 17 00:00:00 2001 From: William Armiros Date: Thu, 28 Jan 2021 14:17:11 -0800 Subject: [PATCH 1/7] added github workflow for unit tests --- .github/workflows/unit-test.yml | 132 ++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 .github/workflows/unit-test.yml diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000000..c0da4bf6c7 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,132 @@ +name: Unit Tests +on: + push: + branches: [main] + pull_request: + +jobs: + unit-test: + strategy: + fail-fast: false + matrix: + container: ["node:8", "node:10", "node:12", "node:14"] + runs-on: ubuntu-latest + container: + image: ${{ matrix.container }} + services: + mongo: + image: mongo + ports: + - 27017:27017 + postgres: + image: circleci/postgres:9.6-alpine + env: + POSTGRES_USER: postgres + POSTGRES_DB: circle_database + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + redis: + image: redis + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + mysql: + image: circleci/mysql:5.7 + env: + MYSQL_USER: otel + MYSQL_PASSWORD: secret + MYSQL_DATABASE: circle_database + MYSQL_ROOT_PASSWORD: rootpw + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + RUN_POSTGRES_TESTS: 1 + RUN_MYSQL_TESTS: 1 + RUN_MONGODB_TESTS: 1 + RUN_REDIS_TESTS: 1 + POSTGRES_USER: postgres + POSTGRES_DB: circle_database + POSTGRES_HOST: postgres + POSTGRES_PORT: 5432 + OPENTELEMETRY_REDIS_HOST: redis + OPENTELEMETRY_REDIS_PORT: 6379 + MONGODB_DB: opentelemetry-tests + MONGODB_HOST: mongo + MONGODB_PORT: 27017 + MYSQL_USER: otel + MYSQL_PASSWORD: secret + MYSQL_DATABASE: circle_database + MYSQL_HOST: mysql + MYSQL_PORT: 3306 + NPM_CONFIG_UNSAFE_PERM: true + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Cache Dependencies + uses: actions/cache@v2 + with: + path: | + node_modules + package-lock.json + detectors/node/*/node_modules + metapackages/*/node_modules + packages/*/node_modules + plugins/node/*/node_modules + plugins/web/*/node_modules + propagators/*/node_modules + key: ${{ runner.os }}-${{ matrix.container }}-${{ hashFiles('**/package.json') }} + - name: Install Root Dependencies + run: npm install --ignore-scripts + - name: Boostrap Dependencies + run: npx lerna bootstrap --no-ci + - name: Unit tests + run: npm run test + - name: Report Coverage + run: npm run codecov + if: ${{ matrix.container }} == 'node:12' + browser-tests: + runs-on: ubuntu-latest + container: + image: circleci/node:12-browsers + env: + NPM_CONFIG_UNSAFE_PERM: true + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Permission Setup + run: sudo chmod -R 777 /github /__w + - name: Cache Dependencies + uses: actions/cache@v2 + with: + path: | + node_modules + package-lock.json + detectors/node/*/node_modules + metapackages/*/node_modules + packages/*/node_modules + plugins/node/*/node_modules + plugins/web/*/node_modules + propagators/*/node_modules + key: ${{ runner.os }}-node:12-${{ hashFiles('**/package.json') }} + - name: Install Root Dependencies + run: npm install --ignore-scripts + - name: Boostrap Dependencies + run: npx lerna bootstrap --no-ci + - name: Unit tests + run: npm run test:browser + - name: Report Coverage + run: npm run codecov:browser From 3af73b72f9cd30437336fb99baef5edd5ec37ce1 Mon Sep 17 00:00:00 2001 From: William Armiros Date: Thu, 28 Jan 2021 14:48:40 -0800 Subject: [PATCH 2/7] test coverage only on node12 --- .github/workflows/unit-test.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index c0da4bf6c7..d715f3010b 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -89,12 +89,15 @@ jobs: plugins/web/*/node_modules propagators/*/node_modules key: ${{ runner.os }}-${{ matrix.container }}-${{ hashFiles('**/package.json') }} - - name: Install Root Dependencies - run: npm install --ignore-scripts - - name: Boostrap Dependencies - run: npx lerna bootstrap --no-ci + # - name: Install Root Dependencies + # run: npm install --ignore-scripts + # - name: Boostrap Dependencies + # run: npx lerna bootstrap --no-ci - name: Unit tests - run: npm run test + # run: npm run test + env: + MATRIX_CONTEXT: ${{ toJSON(matrix) }} + run: echo "$MATRIX_CONTEXT" - name: Report Coverage run: npm run codecov if: ${{ matrix.container }} == 'node:12' From 15795bbdedff36de4c5f038977dc1e3074069994 Mon Sep 17 00:00:00 2001 From: William Armiros Date: Thu, 28 Jan 2021 15:34:30 -0800 Subject: [PATCH 3/7] fix for coverage --- .github/workflows/unit-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index d715f3010b..9544ca68fe 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -99,8 +99,8 @@ jobs: MATRIX_CONTEXT: ${{ toJSON(matrix) }} run: echo "$MATRIX_CONTEXT" - name: Report Coverage + if: matrix.container == 'node:12' run: npm run codecov - if: ${{ matrix.container }} == 'node:12' browser-tests: runs-on: ubuntu-latest container: From a754b6c9b6c27994f1c297487b185dd1a027a627 Mon Sep 17 00:00:00 2001 From: William Armiros Date: Thu, 28 Jan 2021 15:44:19 -0800 Subject: [PATCH 4/7] uncommented real tests --- .github/workflows/unit-test.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 9544ca68fe..0a003e9925 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -89,15 +89,12 @@ jobs: plugins/web/*/node_modules propagators/*/node_modules key: ${{ runner.os }}-${{ matrix.container }}-${{ hashFiles('**/package.json') }} - # - name: Install Root Dependencies - # run: npm install --ignore-scripts - # - name: Boostrap Dependencies - # run: npx lerna bootstrap --no-ci + - name: Install Root Dependencies + run: npm install --ignore-scripts + - name: Boostrap Dependencies + run: npx lerna bootstrap --no-ci - name: Unit tests - # run: npm run test - env: - MATRIX_CONTEXT: ${{ toJSON(matrix) }} - run: echo "$MATRIX_CONTEXT" + run: npm run test - name: Report Coverage if: matrix.container == 'node:12' run: npm run codecov From e0a474bd4137d50e5b52069044ea985074ec3ee8 Mon Sep 17 00:00:00 2001 From: William Armiros Date: Thu, 28 Jan 2021 16:27:40 -0800 Subject: [PATCH 5/7] removed circleci --- .circleci/checksum.sh | 31 ------- .circleci/config.yml | 189 ------------------------------------------ 2 files changed, 220 deletions(-) delete mode 100644 .circleci/checksum.sh delete mode 100644 .circleci/config.yml diff --git a/.circleci/checksum.sh b/.circleci/checksum.sh deleted file mode 100644 index 9c9f3288c1..0000000000 --- a/.circleci/checksum.sh +++ /dev/null @@ -1,31 +0,0 @@ -#! /bin/sh -# -# Usage: checksum.sh filename -# -# checksum.sh computes the checksum of the repo's top level `package.json` -# and `package.json` files in package/, putting the hashes into a file in -# alphabetical order. Must be run at the top level of the repository. - - -if [ -z $1 ]; then - echo "Usage: checksum.sh filename" - exit 1 -fi - -FILE=$1 - -# remove existing file -if [ -f $FILE ]; then - rm $FILE -fi - -openssl md5 package.json >> $FILE - -find detectors/node/*/package.json | xargs -I{} openssl md5 {} >> $FILE -find metapackages/*/package.json | xargs -I{} openssl md5 {} >> $FILE -find packages/*/package.json | xargs -I{} openssl md5 {} >> $FILE -find plugins/node/*/package.json | xargs -I{} openssl md5 {} >> $FILE -find plugins/web/*/package.json | xargs -I{} openssl md5 {} >> $FILE -find propagators/*/package.json | xargs -I{} openssl md5 {} >> $FILE - -sort -o $FILE $FILE diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 0ccf82e727..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,189 +0,0 @@ -version: 2 - -node_test_env: &node_test_env - RUN_POSTGRES_TESTS: 1 - RUN_MYSQL_TESTS: 1 - RUN_MONGODB_TESTS: 1 - RUN_REDIS_TESTS: 1 - POSTGRES_USER: postgres - POSTGRES_DB: circle_database - POSTGRES_HOST: localhost - POSTGRES_PORT: 5432 - OPENTELEMETRY_REDIS_HOST: 'localhost' - OPENTELEMETRY_REDIS_PORT: 6379 - MONGODB_HOST: localhost - MONGODB_DB: opentelemetry-tests - MONGODB_PORT: 27017 - MYSQL_USER: otel - MYSQL_PASSWORD: secret - MYSQL_DATABASE: circle_database - MYSQL_PORT: 3306 - NPM_CONFIG_UNSAFE_PERM: true - -postgres_service: &postgres_service - image: circleci/postgres:9.6-alpine - environment: # env to pass to CircleCI, specified values must match node_test_env - POSTGRES_USER: postgres - POSTGRES_DB: circle_database -redis_service: &redis_service - image: redis - -mongo_service: &mongo_service - image: mongo - -mysql_service: &mysql_service - image: circleci/mysql:5.7 - environment: - MYSQL_USER: otel - MYSQL_PASSWORD: secret - MYSQL_DATABASE: circle_database - MYSQL_ROOT_PASSWORD: rootpw - -cache_1: &cache_1 - key: npm-cache-01-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/checksums.txt" }} - paths: - - ./node_modules - - ./package-lock.json - - detectors/node/opentelemetry-resource-detector-github/node_modules - - metapackages/plugins-node-core-and-contrib/node_modules - - packages/opentelemetry-host-metrics/node_modules - - packages/opentelemetry-test-utils/node_modules - - plugins/node/opentelemetry-hapi-instrumentation/node_modules - - plugins/node/opentelemetry-instrumentation-graphql/node_modules - - plugins/node/opentelemetry-koa-instrumentation/node_modules - - plugins/node/opentelemetry-plugin-dns/node_modules - - plugins/node/opentelemetry-plugin-express/node_modules - - plugins/node/opentelemetry-plugin-ioredis/node_modules - - plugins/node/opentelemetry-plugin-mongodb/node_modules - - plugins/node/opentelemetry-plugin-mysql/node_modules - - plugins/node/opentelemetry-plugin-pg/node_modules - - plugins/node/opentelemetry-plugin-pg-pool/node_modules - - plugins/node/opentelemetry-plugin-redis/node_modules - - plugins/web/opentelemetry-plugin-document-load/node_modules - - plugins/web/opentelemetry-plugin-react-load/node_modules - - plugins/web/opentelemetry-plugin-user-interaction/node_modules - - propagators/opentelemetry-propagator-jaeger/node_modules - - propagators/opentelemetry-propagator-grpc-census-binary/node_modules - -node_unit_tests: &node_unit_tests - resource_class: large - steps: - - checkout - - run: - name: Create Checksum - command: sh .circleci/checksum.sh /tmp/checksums.txt - - run: - name: Setup environment variables - command: | - echo "export CIRCLE_NODE_VERSION=\$(node --version | grep -oE 'v[0-9]+')" >> $BASH_ENV - source $BASH_ENV - - run: - name: Log out node.js version - command: | - node --version - echo "CIRCLE_NODE_VERSION=${CIRCLE_NODE_VERSION}" - - restore_cache: - keys: - - npm-cache-01-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/checksums.txt" }}-F267A71D - - run: - name: Install Root Dependencies - command: npm install --ignore-scripts - - run: - name: Boostrap dependencies - command: npx lerna bootstrap --no-ci - - save_cache: - <<: *cache_1 - - run: - name: Unit tests - command: npm run test - - run: - name: report coverage - command: if [ "${CIRCLE_NODE_VERSION}" = "v12" ]; then npm run codecov; fi - -browsers_unit_tests: &browsers_unit_tests - resource_class: large - steps: - - checkout - - run: - name: Create Checksum - command: sh .circleci/checksum.sh /tmp/checksums.txt - - run: - name: Setup environment variables - command: | - echo "export CIRCLE_NODE_VERSION=\$(node --version | grep -oE 'v[0-9]+')" >> $BASH_ENV - source $BASH_ENV - - run: - name: Log out node.js version - command: | - node --version - echo "CIRCLE_NODE_VERSION=${CIRCLE_NODE_VERSION}" - - restore_cache: - keys: - - npm-cache-01-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/checksums.txt" }}-F267A71D - - run: - name: Install Root Dependencies - command: npm install --ignore-scripts - - run: - name: Boostrap dependencies - command: npx lerna bootstrap --no-ci - - save_cache: - <<: *cache_1 - - run: - name: Unit tests - command: npm run test:browser - - run: - name: report coverage - command: if [ "$CIRCLE_NODE_VERSION" = "v12" ]; then npm run codecov:browser; fi - -jobs: - node8: - docker: - - image: node:8 - environment: *node_test_env - - *postgres_service - - *mysql_service - - *redis_service - - *mongo_service - <<: *node_unit_tests - node10: - docker: - - image: node:10 - environment: *node_test_env - - *postgres_service - - *mysql_service - - *redis_service - - *mongo_service - <<: *node_unit_tests - node12: - docker: - - image: node:12 - environment: *node_test_env - - *postgres_service - - *mysql_service - - *redis_service - - *mongo_service - <<: *node_unit_tests - node14: - docker: - - image: node:14 - environment: *node_test_env - - *postgres_service - - *mysql_service - - *redis_service - - *mongo_service - <<: *node_unit_tests - node12-browsers: - docker: - - image: circleci/node:12-browsers - <<: *browsers_unit_tests - -workflows: - version: 2 - build: - jobs: - - node8 - - node10 - - node12 - - node14 - - node12-browsers - From 83e010f75307d0bc2c75aa3bfd5eec60439a9de6 Mon Sep 17 00:00:00 2001 From: William Armiros Date: Fri, 29 Jan 2021 11:27:02 -0800 Subject: [PATCH 6/7] run codecov on all versions --- .github/workflows/unit-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 0a003e9925..d3fa00f668 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -96,7 +96,6 @@ jobs: - name: Unit tests run: npm run test - name: Report Coverage - if: matrix.container == 'node:12' run: npm run codecov browser-tests: runs-on: ubuntu-latest From 541a5904a33766ac2ad048a40e74f724fc9a2f9a Mon Sep 17 00:00:00 2001 From: William Armiros Date: Tue, 9 Feb 2021 09:48:45 -0600 Subject: [PATCH 7/7] only run coverage on node14 --- .github/workflows/unit-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index d3fa00f668..3eeac25e0e 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -96,6 +96,7 @@ jobs: - name: Unit tests run: npm run test - name: Report Coverage + if: matrix.container == 'node:14' run: npm run codecov browser-tests: runs-on: ubuntu-latest