From 489f45b5cc6d7397d98f04a4503ff449ca728215 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Tue, 8 Nov 2022 12:50:41 -0600 Subject: [PATCH 1/4] fix: swap out `@npmcli/ci-detect` for `ci-info` --- __tests__/lib/fetch.test.ts | 6 ++++++ package-lock.json | 34 +++------------------------------- package.json | 3 +-- src/lib/isCI.ts | 6 +++--- 4 files changed, 13 insertions(+), 36 deletions(-) diff --git a/__tests__/lib/fetch.test.ts b/__tests__/lib/fetch.test.ts index d4abe9454..85b61a99d 100644 --- a/__tests__/lib/fetch.test.ts +++ b/__tests__/lib/fetch.test.ts @@ -4,10 +4,13 @@ import { Headers } from 'node-fetch'; import pkg from '../../package.json'; import fetch, { cleanHeaders, handleRes } from '../../src/lib/fetch'; +import * as isCI from '../../src/lib/isCI'; import getAPIMock from '../helpers/get-api-mock'; describe('#fetch()', () => { describe('GitHub Actions environment', () => { + let spy: jest.SpyInstance; + // List of all GitHub Actions env variables: // https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables beforeEach(() => { @@ -18,6 +21,8 @@ describe('#fetch()', () => { process.env.GITHUB_RUN_ID = '1658821493'; process.env.GITHUB_RUN_NUMBER = '3'; process.env.GITHUB_SHA = 'ffac537e6cbbf934b08745a378932722df287a53'; + spy = jest.spyOn(isCI, 'isGHA'); + spy.mockReturnValue(true); }); afterEach(() => { @@ -28,6 +33,7 @@ describe('#fetch()', () => { delete process.env.GITHUB_RUN_ID; delete process.env.GITHUB_RUN_NUMBER; delete process.env.GITHUB_SHA; + spy.mockReset(); }); it('should have correct headers for requests in GitHub Action env', async () => { diff --git a/package-lock.json b/package-lock.json index 2ec3af427..ae708e3c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,8 @@ "license": "MIT", "dependencies": { "@actions/core": "^1.6.0", - "@npmcli/ci-detect": "^3.0.0", "chalk": "^4.1.2", + "ci-info": "^3.5.0", "command-line-args": "^5.2.0", "command-line-usage": "^6.0.2", "config": "^3.1.0", @@ -53,7 +53,6 @@ "@types/jsonpath": "^0.2.0", "@types/mime-types": "^2.1.1", "@types/node-fetch": "^2.6.2", - "@types/npmcli__ci-detect": "^2.0.0", "@types/parse-link-header": "^2.0.0", "@types/prompts": "^2.0.14", "@types/semver": "^7.3.12", @@ -1383,14 +1382,6 @@ "node": ">= 8" } }, - "node_modules/@npmcli/ci-detect": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@npmcli/ci-detect/-/ci-detect-3.0.1.tgz", - "integrity": "sha512-zQ/qTg2eWnGDToPZH5n7FggNlGC2OYWl6TZv/kDZrTttpm3y2bBcybXSIjlr1ne/ecVp4/vmRNxZP7qTMZo90g==", - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, "node_modules/@pkgr/utils": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.3.0.tgz", @@ -1837,12 +1828,6 @@ "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", "dev": true }, - "node_modules/@types/npmcli__ci-detect": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@types/npmcli__ci-detect/-/npmcli__ci-detect-2.0.0.tgz", - "integrity": "sha512-Nzom9KQvlBNk3gLWKThXZ+DhX/uZ6sDOltOgPFNONo30wi9fePwuwd6V+4+ES9vY+/SVMP4S7Z3QQHXhidAYyg==", - "dev": true - }, "node_modules/@types/parse-link-header": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@types/parse-link-header/-/parse-link-header-2.0.0.tgz", @@ -2735,8 +2720,7 @@ "node_modules/ci-info": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.5.0.tgz", - "integrity": "sha512-yH4RezKOGlOhxkmhbeNuC4eYZKAUsEaGtBuBzDDP1eFUKiccDWzBABxBfOx31IDwDIXMTxWuwAxUGModvkbuVw==", - "dev": true + "integrity": "sha512-yH4RezKOGlOhxkmhbeNuC4eYZKAUsEaGtBuBzDDP1eFUKiccDWzBABxBfOx31IDwDIXMTxWuwAxUGModvkbuVw==" }, "node_modules/cjs-module-lexer": { "version": "1.2.2", @@ -10351,11 +10335,6 @@ "fastq": "^1.6.0" } }, - "@npmcli/ci-detect": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@npmcli/ci-detect/-/ci-detect-3.0.1.tgz", - "integrity": "sha512-zQ/qTg2eWnGDToPZH5n7FggNlGC2OYWl6TZv/kDZrTttpm3y2bBcybXSIjlr1ne/ecVp4/vmRNxZP7qTMZo90g==" - }, "@pkgr/utils": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.3.0.tgz", @@ -10761,12 +10740,6 @@ "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", "dev": true }, - "@types/npmcli__ci-detect": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@types/npmcli__ci-detect/-/npmcli__ci-detect-2.0.0.tgz", - "integrity": "sha512-Nzom9KQvlBNk3gLWKThXZ+DhX/uZ6sDOltOgPFNONo30wi9fePwuwd6V+4+ES9vY+/SVMP4S7Z3QQHXhidAYyg==", - "dev": true - }, "@types/parse-link-header": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@types/parse-link-header/-/parse-link-header-2.0.0.tgz", @@ -11360,8 +11333,7 @@ "ci-info": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.5.0.tgz", - "integrity": "sha512-yH4RezKOGlOhxkmhbeNuC4eYZKAUsEaGtBuBzDDP1eFUKiccDWzBABxBfOx31IDwDIXMTxWuwAxUGModvkbuVw==", - "dev": true + "integrity": "sha512-yH4RezKOGlOhxkmhbeNuC4eYZKAUsEaGtBuBzDDP1eFUKiccDWzBABxBfOx31IDwDIXMTxWuwAxUGModvkbuVw==" }, "cjs-module-lexer": { "version": "1.2.2", diff --git a/package.json b/package.json index 01bbc36a8..162bef8b9 100644 --- a/package.json +++ b/package.json @@ -35,8 +35,8 @@ }, "dependencies": { "@actions/core": "^1.6.0", - "@npmcli/ci-detect": "^3.0.0", "chalk": "^4.1.2", + "ci-info": "^3.5.0", "command-line-args": "^5.2.0", "command-line-usage": "^6.0.2", "config": "^3.1.0", @@ -75,7 +75,6 @@ "@types/jsonpath": "^0.2.0", "@types/mime-types": "^2.1.1", "@types/node-fetch": "^2.6.2", - "@types/npmcli__ci-detect": "^2.0.0", "@types/parse-link-header": "^2.0.0", "@types/prompts": "^2.0.14", "@types/semver": "^7.3.12", diff --git a/src/lib/isCI.ts b/src/lib/isCI.ts index 0c1e06776..bc1afd969 100644 --- a/src/lib/isCI.ts +++ b/src/lib/isCI.ts @@ -1,4 +1,4 @@ -import ciDetect from '@npmcli/ci-detect'; +import ci from 'ci-info'; /** * Small env check to determine if we're in a GitHub Actions environment. @@ -6,7 +6,7 @@ import ciDetect from '@npmcli/ci-detect'; * @see {@link https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables} */ export function isGHA() { - return ciDetect() === 'github-actions'; + return ci.GITHUB_ACTIONS; } /** @@ -40,5 +40,5 @@ export function isNpmScript() { */ export default function isCI() { /* istanbul ignore next */ - return (ciDetect() && !isTest()) || !!process.env.TEST_RDME_CI; + return (ci.isCI && !isTest()) || !!process.env.TEST_RDME_CI; } From 0b1f8636caaf9e55244132343e6df5c7ae19bf2a Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Mon, 14 Nov 2022 09:08:54 -0600 Subject: [PATCH 2/4] chore(deps): bump ci-info --- package-lock.json | 17 ++++++++++------- package.json | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index edbf94304..1ba2b131a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@actions/core": "^1.6.0", "chalk": "^4.1.2", - "ci-info": "^3.5.0", + "ci-info": "^3.6.1", "command-line-args": "^5.2.0", "command-line-usage": "^6.0.2", "config": "^3.1.0", @@ -2718,9 +2718,12 @@ } }, "node_modules/ci-info": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.5.0.tgz", - "integrity": "sha512-yH4RezKOGlOhxkmhbeNuC4eYZKAUsEaGtBuBzDDP1eFUKiccDWzBABxBfOx31IDwDIXMTxWuwAxUGModvkbuVw==" + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.6.1.tgz", + "integrity": "sha512-up5ggbaDqOqJ4UqLKZ2naVkyqSJQgJi5lwD6b6mM748ysrghDBX0bx/qJTUHzw7zu6Mq4gycviSF5hJnwceD8w==", + "engines": { + "node": ">=8" + } }, "node_modules/cjs-module-lexer": { "version": "1.2.2", @@ -11398,9 +11401,9 @@ "dev": true }, "ci-info": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.5.0.tgz", - "integrity": "sha512-yH4RezKOGlOhxkmhbeNuC4eYZKAUsEaGtBuBzDDP1eFUKiccDWzBABxBfOx31IDwDIXMTxWuwAxUGModvkbuVw==" + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.6.1.tgz", + "integrity": "sha512-up5ggbaDqOqJ4UqLKZ2naVkyqSJQgJi5lwD6b6mM748ysrghDBX0bx/qJTUHzw7zu6Mq4gycviSF5hJnwceD8w==" }, "cjs-module-lexer": { "version": "1.2.2", diff --git a/package.json b/package.json index 2b6c4cf08..ac50e0dc3 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "dependencies": { "@actions/core": "^1.6.0", "chalk": "^4.1.2", - "ci-info": "^3.5.0", + "ci-info": "^3.6.1", "command-line-args": "^5.2.0", "command-line-usage": "^6.0.2", "config": "^3.1.0", From 90385009cd663521d3aa315f9121da81fbe8afc8 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Mon, 14 Nov 2022 09:31:48 -0600 Subject: [PATCH 3/4] chore: temporarily disable CI in node 19 weird nock behavior, not sure what's going on --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5cfc74d37..569a38dd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - 14 - 16 - 18 - - 19 + # - 19 steps: - uses: actions/checkout@v3 From bfb67591883612a69e476b1d82612d0f4f53d805 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Mon, 14 Nov 2022 09:39:39 -0600 Subject: [PATCH 4/4] revert: try getting 19 going again? --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 569a38dd2..5cfc74d37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - 14 - 16 - 18 - # - 19 + - 19 steps: - uses: actions/checkout@v3