refactor: Refactored dns instrumentation to subscribe to events emitted
#11072
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Node Agent CI | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| pull_request: | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| workflow_dispatch: | |
| env: | |
| # Enable versioned runner quiet mode to make CI output easier to read: | |
| OUTPUT_MODE: quiet | |
| jobs: | |
| should_run: | |
| # We only want the test suites to run when code has changed, or when | |
| # a dependency update has occurred. | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: read | |
| outputs: | |
| javascript_changed: ${{ steps.filter.outputs.javascript }} | |
| deps_changed: ${{ steps.deps.outputs.divergent }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 2 | |
| - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d | |
| id: filter | |
| with: | |
| filters: | | |
| javascript: | |
| - 'api.js' | |
| - 'esm-loader.mjs' | |
| - 'index.js' | |
| - 'stub_api.js' | |
| - 'lib/**/*.{js,json,mjs,cjs}' | |
| - 'test/**/*.{js,json,mjs,cjs}' | |
| - uses: jsumners-nr/gha-node-deps-divergent@8a3756574008854718621aee6de408fc2e79d70c | |
| id: deps | |
| with: | |
| base-sha: ${{ github.base_ref || 'main' }} | |
| current-sha: ${{ github.sha }} | |
| lint: | |
| needs: | |
| - should_run | |
| if: github.event_name == 'workflow_dispatch' || | |
| (needs.should_run.outputs.javascript_changed == 'true' || | |
| needs.should_run.outputs.deps_changed == 'true') | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [lts/*] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| check-latest: true | |
| - name: Install Dependencies | |
| run: npm install | |
| - name: Run Linting | |
| run: npm run lint | |
| ci: | |
| needs: | |
| - should_run | |
| if: github.event_name == 'workflow_dispatch' || | |
| (needs.should_run.outputs.javascript_changed == 'true' || | |
| needs.should_run.outputs.deps_changed == 'true') | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: [lts/*] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| check-latest: true | |
| - name: Install Dependencies | |
| run: npm install | |
| - name: Run CI Script Unit Tests | |
| run: npm run unit:scripts | |
| unit: | |
| needs: | |
| - should_run | |
| if: github.event_name == 'workflow_dispatch' || | |
| (needs.should_run.outputs.javascript_changed == 'true' || | |
| needs.should_run.outputs.deps_changed == 'true') | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: [22.x, 24.x, 26.x] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| check-latest: true | |
| # This step can be removed when we drop support for Node 22 | |
| - name: Upgrade npm | |
| if: matrix.node-version == '22.x' | |
| run: npm install -g npm@11 | |
| - name: Install Dependencies | |
| run: npm install | |
| - name: Run Unit Tests | |
| run: npm run unit | |
| - name: Archive Unit Test Coverage | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: unit-tests-${{ matrix.node-version }} | |
| path: ./coverage/unit/lcov.info | |
| integration: | |
| needs: | |
| - should_run | |
| if: github.event_name == 'workflow_dispatch' || | |
| (needs.should_run.outputs.javascript_changed == 'true' || | |
| needs.should_run.outputs.deps_changed == 'true') | |
| runs-on: ubuntu-latest | |
| env: | |
| NODE_NO_WARNINGS: 1 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: [22.x, 24.x, 26.x] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| check-latest: true | |
| # This step can be removed when we drop support for Node 22 | |
| - name: Upgrade npm | |
| if: matrix.node-version == '22.x' | |
| run: npm install -g npm@11 | |
| - name: Install Dependencies | |
| run: npm install | |
| - name: Run Integration Tests | |
| run: npm run integration | |
| - name: Run ESM Integration Tests | |
| run: npm run integration:esm | |
| - name: Archive Integration Test Coverage | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: integration-tests-cjs-${{ matrix.node-version }} | |
| path: ./coverage/integration/lcov.info | |
| - name: Archive Integration (ESM) Test Coverage | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: integration-tests-esm-${{ matrix.node-version }} | |
| path: ./coverage/integration-esm/lcov.info | |
| # Partition the versioned test suites across shards so the matrix below can | |
| # run them on separate runners in parallel. Emits a shard list, a | |
| # shard-index -> suite-dirs map, and a shard-index -> docker-services map, | |
| # all consumed by the `versioned` job matrix. | |
| versioned-setup: | |
| needs: | |
| - should_run | |
| if: github.event_name == 'workflow_dispatch' || | |
| (needs.should_run.outputs.javascript_changed == 'true' || | |
| needs.should_run.outputs.deps_changed == 'true') | |
| runs-on: ubuntu-latest | |
| outputs: | |
| shards: ${{ steps.plan.outputs.shards }} | |
| dirmap: ${{ steps.plan.outputs.dirmap }} | |
| servicemap: ${{ steps.plan.outputs.servicemap }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Plan versioned shards | |
| id: plan | |
| run: node ./bin/versioned-runner/shard-plan.js | |
| env: | |
| # At most 5 suites per shard; the shard count derives from suite count. | |
| SHARD_SIZE: 5 | |
| versioned: | |
| needs: | |
| - should_run | |
| - versioned-setup | |
| if: github.event_name == 'workflow_dispatch' || | |
| (needs.should_run.outputs.javascript_changed == 'true' || | |
| needs.should_run.outputs.deps_changed == 'true') | |
| runs-on: ${{ github.ref == 'refs/heads/main' && vars.NR_RUNNER || 'ubuntu-latest' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: [22.x, 24.x, 26.x] | |
| shard: ${{ fromJSON(needs.versioned-setup.outputs.shards) }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| check-latest: true | |
| # This step can be removed when we drop support for Node 22 | |
| - name: Upgrade npm | |
| if: matrix.node-version == '22.x' | |
| run: npm install -g npm@11 | |
| - name: Install Dependencies | |
| run: npm install | |
| # Start only the docker services this shard's suites need. Shards whose | |
| # suites need no services skip this step entirely (zero containers). | |
| - name: Run Docker Services | |
| if: ${{ fromJSON(needs.versioned-setup.outputs.servicemap)[matrix.shard] != '' }} | |
| run: ./bin/start-services.sh $SERVICES | |
| env: | |
| SERVICES: ${{ fromJSON(needs.versioned-setup.outputs.servicemap)[matrix.shard] }} | |
| # The suite names for this shard are passed as positional arguments so the | |
| # runner only executes this shard's subset of the versioned suites. | |
| - name: Run Versioned Tests | |
| run: | | |
| TEST_CHILD_TIMEOUT=600000 \ | |
| npm run versioned \ | |
| ${{ fromJSON(needs.versioned-setup.outputs.dirmap)[matrix.shard] }} | |
| env: | |
| VERSIONED_MODE: ${{ github.ref == 'refs/heads/main' && '--minor' || '--major' }} | |
| # Run more jobs when using larger runner, otherwise 2 per CPU seems to be the sweet spot in GHA default runners(July 2022) | |
| JOBS: ${{ github.ref == 'refs/heads/main' && vars.NR_RUNNER && 16 || 4 }} | |
| C8_REPORTER: lcovonly | |
| - name: Archive Versioned Test Coverage | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: versioned-tests-${{ matrix.node-version }}-shard-${{ matrix.shard }} | |
| path: ./coverage/versioned/lcov.info | |
| - name: Collect docker logs on failure | |
| if: failure() | |
| uses: jwalton/gh-docker-logs@2741064ab9d7af54b0b1ffb6076cf64c16f0220e | |
| with: | |
| dest: ./logs-${{ matrix.node-version }}-shard-${{ matrix.shard }} | |
| - name: Tar logs | |
| if: failure() | |
| run: tar cvzf ./logs-${{ matrix.node-version }}-shard-${{ matrix.shard }}.tgz ./logs-${{ matrix.node-version }}-shard-${{ matrix.shard }} | |
| - name: Upload logs to GitHub | |
| if: failure() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: logs-${{ matrix.node-version }}-shard-${{ matrix.shard }}.tgz | |
| path: ./logs-${{ matrix.node-version }}-shard-${{ matrix.shard }}.tgz | |
| codecov: | |
| needs: [unit, integration, versioned, versioned-setup] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [22.x, 24.x, 26.x] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 'lts/*' | |
| check-latest: true | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v8 | |
| # Versioned coverage is split across one artifact per shard. Build the | |
| # comma separated lcov file list for this node-version from the shard list | |
| # so codecov can merge them under a single flag. | |
| - name: Build versioned coverage file list | |
| id: versioned-coverage | |
| env: | |
| SHARDS: ${{ needs.versioned-setup.outputs.shards }} | |
| NODE_VERSION: ${{ matrix.node-version }} | |
| run: | | |
| files=$(echo "$SHARDS" | node -e ' | |
| const shards = JSON.parse(require("fs").readFileSync(0, "utf8")) | |
| const node = process.env.NODE_VERSION | |
| console.log(shards.map((s) => `./versioned-tests-${node}-shard-${s}/lcov.info`).join(",")) | |
| ') | |
| echo "files=${files}" >> "$GITHUB_OUTPUT" | |
| - name: Post Unit Test Coverage | |
| # v7.0.0 | |
| uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f | |
| with: | |
| fail_ci_if_error: true | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| directory: unit-tests-${{ matrix.node-version }} | |
| flags: unit-tests-${{ matrix.node-version }} | |
| - name: Post Integration CJS Test Coverage | |
| # v7.0.0 | |
| uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f | |
| with: | |
| fail_ci_if_error: true | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| directory: integration-tests-cjs-${{ matrix.node-version }} | |
| flags: integration-tests-cjs-${{ matrix.node-version }} | |
| - name: Post Integration ESM Test Coverage | |
| # v7.0.0 | |
| uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f | |
| with: | |
| fail_ci_if_error: true | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| directory: integration-tests-esm-${{ matrix.node-version }} | |
| flags: integration-tests-esm-${{ matrix.node-version }} | |
| - name: Post Versioned Test Coverage | |
| # v7.0.0 | |
| uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f | |
| with: | |
| fail_ci_if_error: true | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ${{ steps.versioned-coverage.outputs.files }} | |
| flags: versioned-tests-${{ matrix.node-version }} | |
| all-clear: | |
| if: always() | |
| runs-on: ubuntu-latest | |
| needs: | |
| - lint | |
| - ci | |
| - unit | |
| - integration | |
| - versioned-setup | |
| - versioned | |
| steps: | |
| - name: All checks passed | |
| if: ${{ !(contains(needs.*.result, 'failure')) }} | |
| run: exit 0 | |
| - name: Some checks failed | |
| if: ${{ contains(needs.*.result, 'failure') }} | |
| run: exit 1 |