From 75ecad110538dc42198809a6c8467fadfd345098 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Tue, 21 May 2024 14:11:49 -0400 Subject: [PATCH 1/4] chore: Added updating of docs site with compat table --- .github/workflows/ci-workflow.yml | 50 ++++++---------------- .github/workflows/compatibility-report.yml | 48 +++++++++++++++++++-- 2 files changed, 58 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 9141f3e6c2..f6807298d4 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -12,7 +12,7 @@ jobs: permissions: pull-requests: read outputs: - javascript_changed: ${{ steps.filter.output.javascript }} + javascript_changed: ${{ steps.filter.outputs.javascript }} steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v3 @@ -20,31 +20,17 @@ jobs: with: filters: | javascript: - - '**/*.js' - - '**/*.json' - - '**/*.mjs' - - '**/*.cjs' - - skip_if_release: - runs-on: ubuntu-latest - - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@v5 - with: - paths_ignore: '["NEWS.md", "changelog.json", "package.json", "package-lock.json"]' - skip_after_successful_duplicate: false - do_not_skip: '["workflow_dispatch", "pull_request"]' + - 'api.js' + - 'esm-loader.mjs' + - 'index.js' + - 'stub_api.js' + - 'lib/**/*.{js,json,mjs,cjs}' + - 'test/**/*.{js,json,mjs,cjs}' lint: needs: - - skip_if_release - should_run - if: needs.skip_if_release.outputs.should_skip != 'true' - || needs.should_run.outputs.javascript_changed == 'true' + if: needs.should_run.outputs.javascript_changed == 'true' runs-on: ubuntu-latest strategy: @@ -66,10 +52,8 @@ jobs: ci: needs: - - skip_if_release - should_run - if: needs.skip_if_release.outputs.should_skip != 'true' - || needs.should_run.outputs.javascript_changed == 'true' + if: needs.should_run.outputs.javascript_changed == 'true' runs-on: ubuntu-latest strategy: @@ -90,10 +74,8 @@ jobs: unit: needs: - - skip_if_release - should_run - if: needs.skip_if_release.outputs.should_skip != 'true' - || needs.should_run.outputs.javascript_changed == 'true' + if: needs.should_run.outputs.javascript_changed == 'true' runs-on: ubuntu-latest strategy: @@ -119,10 +101,8 @@ jobs: integration: needs: - - skip_if_release - should_run - if: needs.skip_if_release.outputs.should_skip != 'true' - || needs.should_run.outputs.javascript_changed == 'true' + if: needs.should_run.outputs.javascript_changed == 'true' runs-on: ubuntu-latest env: @@ -160,10 +140,8 @@ jobs: versioned-internal: needs: - - skip_if_release - should_run - if: needs.skip_if_release.outputs.should_skip != 'true' - || needs.should_run.outputs.javascript_changed == 'true' + if: needs.should_run.outputs.javascript_changed == 'true' runs-on: ${{ github.ref == 'refs/heads/main' && vars.NR_RUNNER || 'ubuntu-latest' }} strategy: @@ -211,10 +189,8 @@ jobs: # There is no coverage for external as that's tracked in their respective repos versioned-external: needs: - - skip_if_release - should_run - if: needs.skip_if_release.outputs.should_skip != 'true' - || needs.should_run.outputs.javascript_changed == 'true' + if: needs.should_run.outputs.javascript_changed == 'true' runs-on: ${{ github.ref == 'refs/heads/main' && vars.NR_RUNNER || 'ubuntu-latest' }} strategy: diff --git a/.github/workflows/compatibility-report.yml b/.github/workflows/compatibility-report.yml index 94cfde5db0..a1bd9e8b97 100644 --- a/.github/workflows/compatibility-report.yml +++ b/.github/workflows/compatibility-report.yml @@ -54,13 +54,11 @@ jobs: path: compatibility.md # Generate the new PR to update the doc in the repo. - - run: | - git config user.name $GITHUB_ACTOR - git config user.email gh-actions-${GITHUB_ACTOR}@github.com - run: | rm -f status.log - uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e with: + token: ${{ secrets.NODE_AGENT_GH_TOKEN || secrets.GITHUB_TOKEN }} title: "docs: Updated compatibility report" commit-message: "docs: Updated compatibility report" branch: "compatibility-report/auto-update" @@ -68,3 +66,47 @@ jobs: base: main labels: "documentation" + docs: + runs-on: ubuntu-latest + if: + github.event_name == 'push' || + (github.event.workflow_run && github.event.workflow_run.conclusion == 'success') || + (github.event_name == 'workflow_dispatch' && + (inputs.repo_target == 'docs' || inputs.repo_target == 'both')) + env: + DOCS_TARGET: src/content/docs/apm/agents/nodejs-agent/getting-started/compatibility-requirements-nodejs-agent.mdx + steps: + - uses: actions/checkout@v4 + with: + path: agent + - uses: actions/checkout@v4 + with: + repository: newrelic/docs-website + path: docs + - uses: jaxxstorm/action-install-gh-release@71d17cb091aa850acb2a1a4cf87258d183eb941b + with: + repo: newrelic/newrelic-node-versions + platform: linux + arch: amd64 + cache: enable + - run: | + nrversions -v -r agent -R ${DOCS_TARGET} 2>docs-status.log + + # Upload generated artifacts for potential debugging purposes. + - uses: actions/upload-artifact@v4 + with: + name: docs-status.log + path: docs-status.log + + # Generate the new PR to update the doc in the repo. + - run: | + rm -f docs-status.log + - uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e + with: + token: ${{ secrets.NODE_AGENT_GH_TOKEN || secrets.GITHUB_TOKEN }} + title: "docs: Updated Node.js agent compatibility report" + commit-message: "docs: Updated Node.js agent compatibility report" + branch: "nodejs-compatibility-report/auto-update" + delete-branch: true + base: develop + labels: "documentation" From c8120ea656be3cb3363c06d093957c7bf1738e99 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Wed, 22 May 2024 12:41:12 -0400 Subject: [PATCH 2/4] run when package lock changes --- .github/workflows/ci-workflow.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index f6807298d4..eb73537f75 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -18,12 +18,17 @@ jobs: - uses: dorny/paths-filter@v3 id: filter with: + # We only want the test suites to run when code has changed, or when + # a dependency update has occurred. We detect a dependency update + # by noticing changes in the package lock (as it only gets changes + # when dependencies have changed). filters: | javascript: - 'api.js' - 'esm-loader.mjs' - 'index.js' - 'stub_api.js' + - 'package-lock.json' - 'lib/**/*.{js,json,mjs,cjs}' - 'test/**/*.{js,json,mjs,cjs}' From 6a0d0c592678b3832326a42c4027c9a88b5787b3 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Thu, 23 May 2024 12:21:53 -0400 Subject: [PATCH 3/4] utilize action to detect dependency changes --- .github/workflows/ci-workflow.yml | 33 ++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index eb73537f75..642014504a 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -8,34 +8,40 @@ env: 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@v4 + with: + fetch-depth: 2 - uses: dorny/paths-filter@v3 id: filter with: - # We only want the test suites to run when code has changed, or when - # a dependency update has occurred. We detect a dependency update - # by noticing changes in the package lock (as it only gets changes - # when dependencies have changed). filters: | javascript: - 'api.js' - 'esm-loader.mjs' - 'index.js' - 'stub_api.js' - - 'package-lock.json' - 'lib/**/*.{js,json,mjs,cjs}' - 'test/**/*.{js,json,mjs,cjs}' + - uses: jsumners-nr/gha-node-deps-divergent@643628fe0da51ec025e984c4644f17fd9f9e93f6 + id: deps + with: + base-sha: ${{ github.base_ref }} + current-sha: ${{ github.sha }} lint: needs: - should_run - if: needs.should_run.outputs.javascript_changed == 'true' + if: needs.should_run.outputs.javascript_changed == 'true' || + needs.should_run.outputs.deps_changed == 'true' runs-on: ubuntu-latest strategy: @@ -58,7 +64,8 @@ jobs: ci: needs: - should_run - if: needs.should_run.outputs.javascript_changed == 'true' + if: needs.should_run.outputs.javascript_changed == 'true' || + needs.should_run.outputs.deps_changed == 'true' runs-on: ubuntu-latest strategy: @@ -80,7 +87,8 @@ jobs: unit: needs: - should_run - if: needs.should_run.outputs.javascript_changed == 'true' + if: needs.should_run.outputs.javascript_changed == 'true' || + needs.should_run.outputs.deps_changed == 'true' runs-on: ubuntu-latest strategy: @@ -107,7 +115,8 @@ jobs: integration: needs: - should_run - if: needs.should_run.outputs.javascript_changed == 'true' + if: needs.should_run.outputs.javascript_changed == 'true' || + needs.should_run.outputs.deps_changed == 'true' runs-on: ubuntu-latest env: @@ -146,7 +155,8 @@ jobs: versioned-internal: needs: - should_run - if: needs.should_run.outputs.javascript_changed == 'true' + if: 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: @@ -195,7 +205,8 @@ jobs: versioned-external: needs: - should_run - if: needs.should_run.outputs.javascript_changed == 'true' + if: 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: From ff9df16ab89b6976a2b05d855a17fbae37be882e Mon Sep 17 00:00:00 2001 From: James Sumners Date: Thu, 23 May 2024 15:56:25 -0400 Subject: [PATCH 4/4] no need to lint a non-existent lockfile --- .github/workflows/ci-workflow.yml | 2 -- package.json | 1 - 2 files changed, 3 deletions(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 642014504a..26c476cad0 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -58,8 +58,6 @@ jobs: run: npm install - name: Run Linting run: npm run lint - - name: Inspect Lockfile - run: npm run lint:lockfile ci: needs: diff --git a/package.json b/package.json index d6d0c46b20..0923d8e5fc 100644 --- a/package.json +++ b/package.json @@ -161,7 +161,6 @@ "prepare-test": "npm run ssl && npm run docker-env", "lint": "eslint ./*.{js,mjs} lib test bin examples", "lint:fix": "eslint --fix, ./*.{js,mjs} lib test bin examples", - "lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity", "public-docs": "jsdoc -c ./jsdoc-conf.jsonc && cp examples/shim/*.png out/", "publish-docs": "./bin/publish-docs.sh", "services": "docker compose up -d --wait",