diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 24943e1..39a62ca 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest - digest: sha256:609822e3c09b7a1bd90b99655904609f162cc15acb4704f1edf778284c36f429 -# created: 2024-10-01T19:34:30.797530443Z + digest: sha256:0d39e59663287ae929c1d4ccf8ebf7cef9946826c9b86eda7e85d8d752dbb584 +# created: 2024-11-21T22:39:44.342569463Z diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 3ee284b..94bd03a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -54,7 +54,6 @@ body: description: > Screenshots can be provided in the issue body below. placeholder: | - 1. Start the application in development (run `npm run start`) 2. Click X 3. Y will happen validations: diff --git a/.github/release-trigger.yml b/.github/release-trigger.yml index d4ca941..f4851e2 100644 --- a/.github/release-trigger.yml +++ b/.github/release-trigger.yml @@ -1 +1,2 @@ enabled: true +multiScmName: gcp-metadata \ No newline at end of file diff --git a/.github/scripts/close-invalid-link.cjs b/.github/scripts/close-invalid-link.cjs new file mode 100644 index 0000000..d7a3688 --- /dev/null +++ b/.github/scripts/close-invalid-link.cjs @@ -0,0 +1,56 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +async function closeIssue(github, owner, repo, number) { + await github.rest.issues.createComment({ + owner: owner, + repo: repo, + issue_number: number, + body: 'Issue was opened with an invalid reproduction link. Please make sure the repository is a valid, publicly-accessible github repository, and make sure the url is complete (example: https://github.com/googleapis/google-cloud-node)' + }); + await github.rest.issues.update({ + owner: owner, + repo: repo, + issue_number: number, + state: 'closed' + }); +} +module.exports = async ({github, context}) => { + const owner = context.repo.owner; + const repo = context.repo.repo; + const number = context.issue.number; + + const issue = await github.rest.issues.get({ + owner: owner, + repo: repo, + issue_number: number, + }); + + const isBugTemplate = issue.data.body.includes('Link to the code that reproduces this issue'); + + if (isBugTemplate) { + console.log(`Issue ${number} is a bug template`) + try { + const link = issue.data.body.split('\n')[18].match(/(https?:\/\/(gist\.)?github.com\/.*)/)[0]; + console.log(`Issue ${number} contains this link: ${link}`) + const isValidLink = (await fetch(link)).ok; + console.log(`Issue ${number} has a ${isValidLink ? 'valid' : 'invalid'} link`) + if (!isValidLink) { + await closeIssue(github, owner, repo, number); + } + } catch (err) { + await closeIssue(github, owner, repo, number); + } + } +}; diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index b46e4c4..a013376 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -8,9 +8,9 @@ branchProtectionRules: - "ci/kokoro: Samples test" - "ci/kokoro: System test" - lint - - test (14) - - test (16) - test (18) + - test (20) + - test (22) - cla/google - windows - OwlBot Post Processor diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4892eb2..791891a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [14, 16, 18, 20] + node: [18, 20, 22] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - run: node --version @@ -29,10 +29,10 @@ jobs: windows: runs-on: windows-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 18 - run: npm install --engine-strict - run: npm test env: @@ -40,19 +40,19 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 18 - run: npm install - run: npm run lint docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 18 - run: npm install - run: npm run docs - uses: JustinBeckwith/linkinator-action@v1 diff --git a/.github/workflows/issues-no-repro.yaml b/.github/workflows/issues-no-repro.yaml new file mode 100644 index 0000000..442a46b --- /dev/null +++ b/.github/workflows/issues-no-repro.yaml @@ -0,0 +1,18 @@ +name: invalid_link +on: + issues: + types: [opened, reopened] + +jobs: + close: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/github-script@v7 + with: + script: | + const script = require('./.github/scripts/close-invalid-link.cjs') + await script({github, context}) diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg index 4207c90..6ac7f05 100644 --- a/.kokoro/common.cfg +++ b/.kokoro/common.cfg @@ -16,7 +16,7 @@ build_file: "gcp-metadata/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" diff --git a/.kokoro/continuous/node14/common.cfg b/.kokoro/continuous/node18/common.cfg similarity index 89% rename from .kokoro/continuous/node14/common.cfg rename to .kokoro/continuous/node18/common.cfg index 4207c90..6ac7f05 100644 --- a/.kokoro/continuous/node14/common.cfg +++ b/.kokoro/continuous/node18/common.cfg @@ -16,7 +16,7 @@ build_file: "gcp-metadata/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" diff --git a/.kokoro/continuous/node14/lint.cfg b/.kokoro/continuous/node18/lint.cfg similarity index 100% rename from .kokoro/continuous/node14/lint.cfg rename to .kokoro/continuous/node18/lint.cfg diff --git a/.kokoro/continuous/node14/samples-test.cfg b/.kokoro/continuous/node18/samples-test.cfg similarity index 100% rename from .kokoro/continuous/node14/samples-test.cfg rename to .kokoro/continuous/node18/samples-test.cfg diff --git a/.kokoro/continuous/node14/system-test.cfg b/.kokoro/continuous/node18/system-test.cfg similarity index 100% rename from .kokoro/continuous/node14/system-test.cfg rename to .kokoro/continuous/node18/system-test.cfg diff --git a/.kokoro/continuous/node14/test.cfg b/.kokoro/continuous/node18/test.cfg similarity index 100% rename from .kokoro/continuous/node14/test.cfg rename to .kokoro/continuous/node18/test.cfg diff --git a/.kokoro/presubmit/node14/common.cfg b/.kokoro/presubmit/node18/common.cfg similarity index 89% rename from .kokoro/presubmit/node14/common.cfg rename to .kokoro/presubmit/node18/common.cfg index 4207c90..6ac7f05 100644 --- a/.kokoro/presubmit/node14/common.cfg +++ b/.kokoro/presubmit/node18/common.cfg @@ -16,7 +16,7 @@ build_file: "gcp-metadata/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" diff --git a/.kokoro/presubmit/node14/samples-test.cfg b/.kokoro/presubmit/node18/samples-test.cfg similarity index 100% rename from .kokoro/presubmit/node14/samples-test.cfg rename to .kokoro/presubmit/node18/samples-test.cfg diff --git a/.kokoro/presubmit/node14/system-test.cfg b/.kokoro/presubmit/node18/system-test.cfg similarity index 100% rename from .kokoro/presubmit/node14/system-test.cfg rename to .kokoro/presubmit/node18/system-test.cfg diff --git a/.kokoro/presubmit/node14/test.cfg b/.kokoro/presubmit/node18/test.cfg similarity index 100% rename from .kokoro/presubmit/node14/test.cfg rename to .kokoro/presubmit/node18/test.cfg diff --git a/.kokoro/release/docs-devsite.cfg b/.kokoro/release/docs-devsite.cfg index 3ce6bbc..2bee988 100644 --- a/.kokoro/release/docs-devsite.cfg +++ b/.kokoro/release/docs-devsite.cfg @@ -11,7 +11,7 @@ before_action { # doc publications use a Python image. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } # Download trampoline resources. diff --git a/.kokoro/release/docs.cfg b/.kokoro/release/docs.cfg index c72d89c..2e6da58 100644 --- a/.kokoro/release/docs.cfg +++ b/.kokoro/release/docs.cfg @@ -11,7 +11,7 @@ before_action { # doc publications use a Python image. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } # Download trampoline resources. diff --git a/.kokoro/release/docs.sh b/.kokoro/release/docs.sh index 1d8f3f4..e9079a6 100755 --- a/.kokoro/release/docs.sh +++ b/.kokoro/release/docs.sh @@ -16,7 +16,7 @@ set -eo pipefail -# build jsdocs (Python is installed on the Node 10 docker image). +# build jsdocs (Python is installed on the Node 18 docker image). if [[ -z "$CREDENTIALS" ]]; then # if CREDENTIALS are explicitly set, assume we're testing locally # and don't set NPM_CONFIG_PREFIX. diff --git a/.kokoro/release/publish.cfg b/.kokoro/release/publish.cfg index 1c0dc3a..de86e8c 100644 --- a/.kokoro/release/publish.cfg +++ b/.kokoro/release/publish.cfg @@ -30,7 +30,7 @@ build_file: "gcp-metadata/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } env_vars: { diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh index 8c5d108..5e5d15d 100755 --- a/.kokoro/samples-test.sh +++ b/.kokoro/samples-test.sh @@ -16,7 +16,13 @@ set -eo pipefail -export NPM_CONFIG_PREFIX=${HOME}/.npm-global +# Ensure the npm global directory is writable, otherwise rebuild `npm` +mkdir -p $NPM_CONFIG_PREFIX +npm config -g ls || npm i -g npm@`npm --version` + +echo $(npm -v) +echo $(which npm) +echo $(npm prefix -g) # Setup service account credentials. export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/long-door-651-kokoro-system-test-service-account @@ -56,7 +62,7 @@ fi # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=14 +COVERAGE_NODE=18 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh index 0b3043d..a90d5cf 100755 --- a/.kokoro/system-test.sh +++ b/.kokoro/system-test.sh @@ -49,7 +49,7 @@ npm run system-test # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=14 +COVERAGE_NODE=18 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/test.bat b/.kokoro/test.bat index 0bb1240..caf8256 100644 --- a/.kokoro/test.bat +++ b/.kokoro/test.bat @@ -21,7 +21,7 @@ cd .. @rem we upgrade Node.js in the image: SET PATH=%PATH%;/cygdrive/c/Program Files/nodejs/npm -call nvm use v14.17.3 +call nvm use 18 call which node call npm install || goto :error diff --git a/.kokoro/test.sh b/.kokoro/test.sh index 862d478..0d9f639 100755 --- a/.kokoro/test.sh +++ b/.kokoro/test.sh @@ -39,7 +39,7 @@ npm test # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=14 +COVERAGE_NODE=18 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/trampoline_v2.sh b/.kokoro/trampoline_v2.sh index 4d03112..5d6cfcc 100755 --- a/.kokoro/trampoline_v2.sh +++ b/.kokoro/trampoline_v2.sh @@ -44,7 +44,7 @@ # the project root. # # Here is an example for running this script. -# TRAMPOLINE_IMAGE=gcr.io/cloud-devrel-kokoro-resources/node:10-user \ +# TRAMPOLINE_IMAGE=gcr.io/cloud-devrel-kokoro-resources/node:18-user \ # TRAMPOLINE_BUILD_FILE=.kokoro/system-test.sh \ # .kokoro/trampoline_v2.sh diff --git a/owlbot.py b/owlbot.py index d3bfc21..408fc81 100644 --- a/owlbot.py +++ b/owlbot.py @@ -6,4 +6,4 @@ common_templates = gcp.CommonTemplates() templates = common_templates.node_library() -s.copy(sources=templates, excludes=[".github/ISSUE_TEMPLATE", ".github/scripts", ".github/workflows/issues-no-repro.yaml"]) +s.copy(sources=templates, excludes=[".github/ISSUE_TEMPLATE", ".github/scripts", ".github/workflows/issues-no-repro.yaml", ".kokoro/samples-test.sh"]) diff --git a/package.json b/package.json index 854bfff..e2a7eb0 100644 --- a/package.json +++ b/package.json @@ -37,36 +37,36 @@ "author": "Google LLC", "license": "Apache-2.0", "dependencies": { - "gaxios": "^6.1.1", - "json-bigint": "^1.0.0" + "json-bigint": "^1.0.0", + "gaxios": "^6.7.1" }, "devDependencies": { - "@google-cloud/functions": "^3.0.0", - "@types/json-bigint": "^1.0.0", - "@types/mocha": "^9.0.0", - "@types/ncp": "^2.0.1", - "@types/node": "^20.0.0", - "@types/sinon": "^17.0.0", - "@types/tmp": "0.2.6", - "@types/uuid": "^9.0.0", - "c8": "^9.0.0", + "@google-cloud/functions": "^3.6.0", + "@types/json-bigint": "^1.0.4", + "@types/mocha": "^10.0.9", + "@types/ncp": "^2.0.8", + "@types/node": "^22.9.0", + "@types/sinon": "^17.0.3", + "@types/tmp": "^0.2.6", + "@types/uuid": "^10.0.0", + "c8": "^10.1.2", "cross-env": "^7.0.3", - "gcbuild": "^1.3.4", + "gcbuild": "^1.3.39", "gcx": "^1.0.0", - "gts": "^5.0.0", - "linkinator": "^3.0.0", - "jsdoc": "^4.0.0", + "gts": "^6.0.2", + "jsdoc": "^4.0.4", "jsdoc-fresh": "^3.0.0", "jsdoc-region-tag": "^3.0.0", - "mocha": "^8.0.0", + "linkinator": "^6.1.2", + "mocha": "^10.8.2", "ncp": "^2.0.0", - "nock": "^13.0.0", - "sinon": "^17.0.0", - "tmp": "^0.2.0", - "typescript": "^5.1.6", - "uuid": "^9.0.0" + "nock": "^13.5.5", + "sinon": "^19.0.2", + "tmp": "^0.2.3", + "typescript": "^5.6.3", + "uuid": "^11.0.2" }, "engines": { - "node": ">=14" + "node": ">=18" } } diff --git a/samples/package.json b/samples/package.json index ea9a819..68da64d 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,7 +3,7 @@ "license": "Apache-2.0", "author": "Google LLC", "engines": { - "node": ">=14" + "node": ">=18" }, "files": [ "*.js" @@ -20,4 +20,4 @@ "chai": "^4.2.0", "mocha": "^8.0.0" } -} +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 82e13a0..cf81421 100644 --- a/src/index.ts +++ b/src/index.ts @@ -100,7 +100,7 @@ function validate(options: Options) { break; case 'qs': throw new Error( - "'qs' is not a valid configuration option. Please use 'params' instead." + "'qs' is not a valid configuration option. Please use 'params' instead.", ); default: throw new Error(`'${key}' is not a valid configuration option.`); @@ -112,14 +112,14 @@ async function metadataAccessor( type: string, options?: string | Options, noResponseRetries?: number, - fastFail?: boolean + fastFail?: boolean, ): Promise; async function metadataAccessor(metadata: MetadataAccessor): Promise; async function metadataAccessor( type: MetadataAccessor | string, options: string | Options = {}, noResponseRetries = 3, - fastFail = false + fastFail = false, ): Promise { let metadataKey = ''; let params: {} = {}; @@ -162,7 +162,7 @@ async function metadataAccessor( // NOTE: node.js converts all incoming headers to lower case. if (res.headers[HEADER_NAME.toLowerCase()] !== HEADER_VALUE) { throw new Error( - `Invalid response from metadata service: incorrect ${HEADER_NAME} header.` + `Invalid response from metadata service: incorrect ${HEADER_NAME} header.`, ); } @@ -178,7 +178,7 @@ async function metadataAccessor( } async function fastFailMetadataRequest( - options: GaxiosOptions + options: GaxiosOptions, ): Promise { const secondaryOptions = { ...options, @@ -314,7 +314,7 @@ export async function bulk< r[key] = res; })(); - }) + }), ); return r as R; @@ -342,8 +342,8 @@ export async function isAvailable() { if (!(value in METADATA_SERVER_DETECTION)) { throw new RangeError( `Unknown \`METADATA_SERVER_DETECTION\` env variable. Got \`${value}\`, but it should be \`${Object.keys( - METADATA_SERVER_DETECTION - ).join('`, `')}\`, or unset` + METADATA_SERVER_DETECTION, + ).join('`, `')}\`, or unset`, ); } @@ -372,7 +372,7 @@ export async function isAvailable() { // If the default HOST_ADDRESS has been overridden, we should not // make an effort to try SECONDARY_HOST_ADDRESS (as we are likely in // a non-GCP environment): - !(process.env.GCE_METADATA_IP || process.env.GCE_METADATA_HOST) + !(process.env.GCE_METADATA_IP || process.env.GCE_METADATA_HOST), ); } await cachedIsAvailableResponse; @@ -409,7 +409,7 @@ export async function isAvailable() { if (err.code) code = err.code; process.emitWarning( `received unexpected error = ${err.message} code = ${code}`, - 'MetadataLookupWarning' + 'MetadataLookupWarning', ); } diff --git a/system-test/any.d.ts b/system-test/any.d.ts new file mode 100644 index 0000000..c610914 --- /dev/null +++ b/system-test/any.d.ts @@ -0,0 +1 @@ +declare module '*'; diff --git a/system-test/system.ts b/system-test/system.ts index 94c9abb..8144ea0 100644 --- a/system-test/system.ts +++ b/system-test/system.ts @@ -84,13 +84,13 @@ describe('gcp metadata', () => { const result = await gcbuild.build({ sourcePath: path.join( __dirname, - '../../system-test/fixtures/cloudbuild' + '../../system-test/fixtures/cloudbuild', ), }); console.log(result.log); assert.ok(/isAvailable: true/.test(result.log)); assert.ok( - result.log.includes('"default":{"aliases":["default"],"email"') + result.log.includes('"default":{"aliases":["default"],"email"'), ); } catch (e) { console.error((e as gcbuild.BuildError).log); @@ -127,7 +127,7 @@ async function pruneFunctions(sessionOnly: boolean) { console.error(`There was a problem deleting function ${fn.name}.`); console.error(e); }); - }) + }), ); } @@ -158,6 +158,6 @@ async function packModule() { targets.map(target => { const to = `system-test/fixtures/${target}/${pkg.name}.tgz`; return copy(from, to); - }) + }), ); } diff --git a/test/index.test.ts b/test/index.test.ts index d23eeb5..abf43b6 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -179,7 +179,7 @@ describe('unit test', () => { .reply(200, {}, {[gcp.HEADER_NAME.toLowerCase()]: 'Hazelnut'}); await assert.rejects( gcp.instance(), - /Invalid response from metadata service: incorrect Metadata-Flavor header./ + /Invalid response from metadata service: incorrect Metadata-Flavor header./, ); scope.done(); }); @@ -226,7 +226,7 @@ describe('unit test', () => { await assert.rejects( // eslint-disable-next-line @typescript-eslint/no-explicit-any gcp.instance({qs: {one: 'two'}} as any), - /'qs' is not a valid configuration option. Please use 'params' instead\./ + /'qs' is not a valid configuration option. Please use 'params' instead\./, ); }); @@ -234,7 +234,7 @@ describe('unit test', () => { await assert.rejects( // eslint-disable-next-line @typescript-eslint/no-explicit-any gcp.instance({fake: 'news'} as any), - /'fake' is not a valid/ + /'fake' is not a valid/, ); }); @@ -251,7 +251,7 @@ describe('unit test', () => { async function secondaryHostRequest( delay: number, - responseType = 'success' + responseType = 'success', ): Promise { let secondary: nock.Scope; if (responseType === 'success') { @@ -467,7 +467,7 @@ describe('unit test', () => { }); it('should fail on isAvailable if request times out', async () => { - secondaryHostRequest(5000); + void secondaryHostRequest(5000); const primary = nock(HOST) .get(`${PATH}/${TYPE}`) .delayConnection(3500) @@ -482,7 +482,7 @@ describe('unit test', () => { it('should fail on isAvailable if GCE_METADATA_HOST times out', async () => { process.env.GCE_METADATA_HOST = '127.0.0.1:8080'; - secondaryHostRequest(5000); + void secondaryHostRequest(5000); const primary = nock(`http://${process.env.GCE_METADATA_HOST}`) .get(`${PATH}/${TYPE}`) .delayConnection(3500) @@ -540,7 +540,7 @@ describe('unit test', () => { process.on('warning', warning => { assert.strictEqual( warning.toString().includes('unexpected error'), - true + true, ); return resolve(); }); @@ -596,7 +596,7 @@ describe('unit test', () => { it('should only make one outbound request, if isAvailable() called in rapid succession', async () => { const secondary = secondaryHostRequest(500); const primary = nock(HOST).get(`${PATH}/${TYPE}`).reply(200, {}, HEADERS); - gcp.isAvailable(); + void gcp.isAvailable(); // because we haven't created additional mocks, we expect this to fail // if we were not caching the first isAvailable() call: const isGCE = await gcp.isAvailable(); diff --git a/test/utils/gcp-residency.ts b/test/utils/gcp-residency.ts index 144fa78..51640f3 100644 --- a/test/utils/gcp-residency.ts +++ b/test/utils/gcp-residency.ts @@ -47,7 +47,7 @@ export class GCPResidencyUtil { this.stubs.osNetworkInterfaces ??= this.sandbox.stub( os, - 'networkInterfaces' + 'networkInterfaces', ); this.stubs.osNetworkInterfaces.returns({ 'test-interface': [{mac} as os.NetworkInterfaceInfo], diff --git a/tsconfig.json b/tsconfig.json index b7492c4..cc54f42 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,8 @@ "include": [ "src/*.ts", "test/*.ts", - "system-test/*.ts" + "system-test/*.ts", + "test/**/*.ts" ], "exclude": [ "test/fixtures"