diff --git a/.github/workflows/e2e-cache.yml b/.github/workflows/e2e-cache.yml index ddedf39b..73e48d8d 100644 --- a/.github/workflows/e2e-cache.yml +++ b/.github/workflows/e2e-cache.yml @@ -21,7 +21,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [20, 22, 24] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Clean global cache run: npm cache clean --force - name: Setup Node @@ -44,7 +44,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [20, 22, 24] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Install pnpm uses: pnpm/action-setup@v4 with: @@ -77,7 +77,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [20, 22, 24] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Yarn version run: yarn --version - name: Generate yarn file @@ -109,7 +109,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [20, 22, 24] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Update yarn run: yarn set version 3.6.4 - name: Yarn version @@ -143,7 +143,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: prepare sub-projects run: __tests__/prepare-yarn-subprojects.sh yarn1 @@ -170,7 +170,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: prepare sub-projects run: __tests__/prepare-yarn-subprojects.sh keepcache keepcache @@ -197,7 +197,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: prepare sub-projects run: __tests__/prepare-yarn-subprojects.sh global @@ -224,7 +224,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: prepare sub-projects run: /bin/bash __tests__/prepare-yarn-subprojects.sh keepcache @@ -253,7 +253,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [20, 22, 24] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Create package.json with packageManager field run: | echo '{ "name": "test-project", "version": "1.0.0", "packageManager": "npm@8.0.0" }' > package.json @@ -278,7 +278,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [20, 22, 24] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Create package.json with devEngines field run: | echo '{ diff --git a/.github/workflows/proxy.yml b/.github/workflows/proxy.yml index c5493b59..e1112314 100644 --- a/.github/workflows/proxy.yml +++ b/.github/workflows/proxy.yml @@ -25,7 +25,7 @@ jobs: env: https_proxy: http://squid-proxy:3128 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Clear tool cache run: rm -rf $RUNNER_TOOL_CACHE/* - name: Setup node 24 @@ -41,7 +41,7 @@ jobs: https_proxy: http://no-such-proxy:3128 no_proxy: api.github.com,github.com,nodejs.org,registry.npmjs.org,*.s3.amazonaws.com,s3.amazonaws.com steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Clear tool cache run: rm -rf $RUNNER_TOOL_CACHE/* - name: Setup node 24 diff --git a/.github/workflows/publish-immutable-actions.yml b/.github/workflows/publish-immutable-actions.yml index 52c7bc00..7f49c641 100644 --- a/.github/workflows/publish-immutable-actions.yml +++ b/.github/workflows/publish-immutable-actions.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Checking out - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Publish id: publish uses: actions/publish-immutable-action@v0.0.4 diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 4c393337..d5fe2504 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -12,7 +12,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [20, 22, 24] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Node uses: ./ with: @@ -29,7 +29,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest-large] node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Node uses: ./ with: @@ -56,7 +56,7 @@ jobs: '20.0.0-v8-canary20221101e50e45c9f8' ] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Node uses: ./ with: @@ -76,7 +76,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [20-nightly, 25-nightly, 24.0.0-nightly] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Node uses: ./ with: @@ -96,7 +96,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [20.0.0-rc.1, 22.14.0-rc.1, 24.0.0-rc.4] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Node uses: ./ with: @@ -116,7 +116,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [20.10.0, 22.0.0, 24.9.0] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Node uses: ./ with: @@ -133,7 +133,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [20, 22, 24] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Node and check latest uses: ./ with: @@ -152,7 +152,7 @@ jobs: node-version-file: [.nvmrc, .tool-versions, .tool-versions-node, package.json] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup node from node version file uses: ./ with: @@ -167,7 +167,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup node from node version file uses: ./ with: @@ -182,7 +182,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup node from node version file uses: ./ with: @@ -198,7 +198,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] node-version: [17, 19] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Node from dist uses: ./ with: @@ -214,7 +214,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest-large] steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 # test old versions which didn't have npm and layout different - name: Setup node 0.12.18 from dist uses: ./ @@ -227,7 +227,7 @@ jobs: arch: runs-on: windows-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup node 20 x86 from dist uses: ./ with: @@ -251,7 +251,7 @@ jobs: echo "LATEST_NODE_VERSION=$latestNodeVersion" >> $GITHUB_OUTPUT id: version shell: bash - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup Node uses: ./ with: diff --git a/.licenses/npm/@actions/cache.dep.yml b/.licenses/npm/@actions/cache.dep.yml index f70b140d..2cc92352 100644 Binary files a/.licenses/npm/@actions/cache.dep.yml and b/.licenses/npm/@actions/cache.dep.yml differ diff --git a/.licenses/npm/@protobuf-ts/plugin-framework.dep.yml b/.licenses/npm/@protobuf-ts/plugin-framework.dep.yml deleted file mode 100644 index cbb1501e..00000000 Binary files a/.licenses/npm/@protobuf-ts/plugin-framework.dep.yml and /dev/null differ diff --git a/.licenses/npm/@protobuf-ts/plugin.dep.yml b/.licenses/npm/@protobuf-ts/plugin.dep.yml deleted file mode 100644 index 09e4667e..00000000 Binary files a/.licenses/npm/@protobuf-ts/plugin.dep.yml and /dev/null differ diff --git a/.licenses/npm/@protobuf-ts/protoc.dep.yml b/.licenses/npm/@protobuf-ts/protoc.dep.yml deleted file mode 100644 index dddaf18a..00000000 Binary files a/.licenses/npm/@protobuf-ts/protoc.dep.yml and /dev/null differ diff --git a/.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml b/.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml index 3e52954e..79644b5d 100644 Binary files a/.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml and b/.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml differ diff --git a/.licenses/npm/@protobuf-ts/runtime.dep.yml b/.licenses/npm/@protobuf-ts/runtime.dep.yml index 66dbe2b1..7a210232 100644 Binary files a/.licenses/npm/@protobuf-ts/runtime.dep.yml and b/.licenses/npm/@protobuf-ts/runtime.dep.yml differ diff --git a/.licenses/npm/typescript.dep.yml b/.licenses/npm/typescript.dep.yml deleted file mode 100644 index 01cccafd..00000000 Binary files a/.licenses/npm/typescript.dep.yml and /dev/null differ diff --git a/README.md b/README.md index 24aa81d1..b9c2fa3c 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ This action provides the following functionality for GitHub Actions users: - Caching is now automatically enabled for npm projects when either the `devEngines.packageManager` field or the top-level `packageManager` field in `package.json` is set to `npm`. For other package managers, such as Yarn and pnpm, caching is disabled by default and must be configured manually using the `cache` input. +- The `always-auth` input has been removed, as it is deprecated and will no longer be supported in future npm releases. To ensure your workflows continue to run without warnings or errors, please remove any references to `always-auth` from your configuration. + ## Breaking changes in V5 - Enabled caching by default with package manager detection if no cache input is provided. @@ -92,10 +94,6 @@ See [action.yml](action.yml) # Default: '' scope: '' - # Set always-auth option in npmrc file. - # Default: '' - always-auth: '' - # Optional mirror to download binaries from. # Artifacts need to match the official Node.js # Example: @@ -150,7 +148,7 @@ Since it will not be cached always, there is possibility of hitting rate limit w ### Checking in lockfiles -It's **always** recommended to commit the lockfile of your package manager for security and performance reasons. For more information consult the "Working with lockfiles" section of the [Advanced usage](docs/advanced-usage.md#working-with-lockfiles) guide. +It's **strongly recommended** to commit the lockfile of your package manager for security and performance reasons. For more information consult the "Working with lockfiles" section of the [Advanced usage](docs/advanced-usage.md#working-with-lockfiles) guide. ## Caching global packages data @@ -251,6 +249,7 @@ If the runner is not able to access github.com, any Nodejs versions requested du - [Publishing to npmjs and GPR with npm](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-npm) - [Publishing to npmjs and GPR with yarn](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-yarn) - [Using private packages](docs/advanced-usage.md#use-private-packages) + - [Using private mirror](docs/advanced-usage.md#use-private-mirror) ## Recommended permissions @@ -271,4 +270,4 @@ Contributions are welcome! See [Contributor's Guide](docs/contributors.md) ## Code of Conduct -:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md) \ No newline at end of file +:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md) diff --git a/__tests__/authutil.test.ts b/__tests__/authutil.test.ts index 0676a850..d5f6c195 100644 --- a/__tests__/authutil.test.ts +++ b/__tests__/authutil.test.ts @@ -76,115 +76,102 @@ describe('authutil tests', () => { } it('Sets up npmrc for npmjs', async () => { - await auth.configAuthentication('https://registry.npmjs.org/', 'false'); + await auth.configAuthentication('https://registry.npmjs.org/'); expect(fs.statSync(rcFile)).toBeDefined(); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); const rc = readRcFile(rcFile); expect(rc['registry']).toBe('https://registry.npmjs.org/'); - expect(rc['always-auth']).toBe('false'); }); it('Appends trailing slash to registry', async () => { - await auth.configAuthentication('https://registry.npmjs.org', 'false'); + await auth.configAuthentication('https://registry.npmjs.org'); expect(fs.statSync(rcFile)).toBeDefined(); const rc = readRcFile(rcFile); expect(rc['registry']).toBe('https://registry.npmjs.org/'); - expect(rc['always-auth']).toBe('false'); }); it('Configures scoped npm registries', async () => { process.env['INPUT_SCOPE'] = 'myScope'; - await auth.configAuthentication('https://registry.npmjs.org', 'false'); + await auth.configAuthentication('https://registry.npmjs.org'); expect(fs.statSync(rcFile)).toBeDefined(); const rc = readRcFile(rcFile); expect(rc['@myscope:registry']).toBe('https://registry.npmjs.org/'); - expect(rc['always-auth']).toBe('false'); }); it('Automatically configures GPR scope', async () => { - await auth.configAuthentication('npm.pkg.github.com', 'false'); + await auth.configAuthentication('npm.pkg.github.com'); expect(fs.statSync(rcFile)).toBeDefined(); const rc = readRcFile(rcFile); expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/'); - expect(rc['always-auth']).toBe('false'); - }); - - it('Sets up npmrc for always-auth true', async () => { - await auth.configAuthentication('https://registry.npmjs.org/', 'true'); - expect(fs.statSync(rcFile)).toBeDefined(); - const rc = readRcFile(rcFile); - expect(rc['registry']).toBe('https://registry.npmjs.org/'); - expect(rc['always-auth']).toBe('true'); }); it('is already set the NODE_AUTH_TOKEN export it', async () => { process.env.NODE_AUTH_TOKEN = 'foobar'; - await auth.configAuthentication('npm.pkg.github.com', 'false'); + await auth.configAuthentication('npm.pkg.github.com'); expect(fs.statSync(rcFile)).toBeDefined(); const rc = readRcFile(rcFile); expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/'); - expect(rc['always-auth']).toBe('false'); expect(process.env.NODE_AUTH_TOKEN).toEqual('foobar'); }); it('configAuthentication should overwrite non-scoped with non-scoped', async () => { fs.writeFileSync(rcFile, 'registry=NNN'); - await auth.configAuthentication('https://registry.npmjs.org/', 'true'); + await auth.configAuthentication('https://registry.npmjs.org/'); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); expect(contents).toBe( - `//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true` + `//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/` ); }); it('configAuthentication should overwrite only non-scoped', async () => { fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`); - await auth.configAuthentication('https://registry.npmjs.org/', 'true'); + await auth.configAuthentication('https://registry.npmjs.org/'); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); expect(contents).toBe( - `@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true` + `@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/` ); }); it('configAuthentication should add non-scoped to scoped', async () => { fs.writeFileSync(rcFile, '@myscope:registry=NNN'); - await auth.configAuthentication('https://registry.npmjs.org/', 'true'); + await auth.configAuthentication('https://registry.npmjs.org/'); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); expect(contents).toBe( - `@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true` + `@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/` ); }); it('configAuthentication should overwrite scoped with scoped', async () => { process.env['INPUT_SCOPE'] = 'myscope'; fs.writeFileSync(rcFile, `@myscope:registry=NNN`); - await auth.configAuthentication('https://registry.npmjs.org/', 'true'); + await auth.configAuthentication('https://registry.npmjs.org/'); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); expect(contents).toBe( - `//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` + `//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/` ); }); it('configAuthentication should overwrite only scoped', async () => { process.env['INPUT_SCOPE'] = 'myscope'; fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`); - await auth.configAuthentication('https://registry.npmjs.org/', 'true'); + await auth.configAuthentication('https://registry.npmjs.org/'); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); expect(contents).toBe( - `registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` + `registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/` ); }); it('configAuthentication should add scoped to non-scoped', async () => { process.env['INPUT_SCOPE'] = 'myscope'; fs.writeFileSync(rcFile, `registry=MMM`); - await auth.configAuthentication('https://registry.npmjs.org/', 'true'); + await auth.configAuthentication('https://registry.npmjs.org/'); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); expect(contents).toBe( - `registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` + `registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/` ); }); @@ -194,20 +181,20 @@ describe('authutil tests', () => { rcFile, `@otherscope:registry=NNN${os.EOL}@myscope:registry=MMM` ); - await auth.configAuthentication('https://registry.npmjs.org/', 'true'); + await auth.configAuthentication('https://registry.npmjs.org/'); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); expect(contents).toBe( - `@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` + `@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/` ); }); it('configAuthentication should add scoped to another scoped', async () => { process.env['INPUT_SCOPE'] = 'myscope'; fs.writeFileSync(rcFile, `@otherscope:registry=MMM`); - await auth.configAuthentication('https://registry.npmjs.org/', 'true'); + await auth.configAuthentication('https://registry.npmjs.org/'); const contents = fs.readFileSync(rcFile, {encoding: 'utf8'}); expect(contents).toBe( - `@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true` + `@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/` ); }); }); diff --git a/__tests__/canary-installer.test.ts b/__tests__/canary-installer.test.ts index 4393d7ef..93daf17c 100644 --- a/__tests__/canary-installer.test.ts +++ b/__tests__/canary-installer.test.ts @@ -227,7 +227,6 @@ describe('setup-node', () => { const versionSpec = '11.15.0'; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; // ... but not in the local cache @@ -283,7 +282,6 @@ describe('setup-node', () => { const versionSpec = '19.0.0-v8-canary'; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; findSpy.mockImplementation(() => ''); @@ -324,7 +322,6 @@ describe('setup-node', () => { inputs['node-version'] = version; inputs['architecture'] = arch; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; const expectedUrl = `https://nodejs.org/download/v8-canary/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`; @@ -569,7 +566,6 @@ describe('setup-node', () => { const versionSpec = 'v20-v8-canary'; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; os.platform = 'linux'; diff --git a/__tests__/nightly-installer.test.ts b/__tests__/nightly-installer.test.ts index eece2c34..b95a42d2 100644 --- a/__tests__/nightly-installer.test.ts +++ b/__tests__/nightly-installer.test.ts @@ -255,7 +255,6 @@ describe('setup-node', () => { const versionSpec = '13.13.1-nightly20200415947ddec091'; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; // ... but not in the local cache @@ -291,7 +290,6 @@ describe('setup-node', () => { ]; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; // ... but not in the local cache @@ -333,7 +331,6 @@ describe('setup-node', () => { ]; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; // ... but not in the local cache @@ -389,7 +386,6 @@ describe('setup-node', () => { const versionSpec = '18.0.0-nightly202204180699150267'; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; findSpy.mockImplementation(() => ''); @@ -427,7 +423,6 @@ describe('setup-node', () => { inputs['node-version'] = version; inputs['architecture'] = arch; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; const expectedUrl = `https://nodejs.org/download/nightly/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`; @@ -473,7 +468,6 @@ describe('setup-node', () => { inputs['node-version'] = version; inputs['architecture'] = arch; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; inputs['mirror'] = 'https://my-mirror.org'; inputs['mirror-token'] = 'my-mirror-token'; diff --git a/__tests__/official-installer.test.ts b/__tests__/official-installer.test.ts index f23183d3..fa46c35e 100644 --- a/__tests__/official-installer.test.ts +++ b/__tests__/official-installer.test.ts @@ -235,7 +235,6 @@ describe('setup-node', () => { const resolvedVersion = versionSpec; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; const expectedUrl = @@ -290,7 +289,6 @@ describe('setup-node', () => { const versionSpec = '11.15.0'; const mirror = 'https://my_mirror_url'; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; inputs['mirror'] = mirror; inputs['mirror-token'] = 'faketoken'; @@ -327,7 +325,6 @@ describe('setup-node', () => { const versionSpec = '11.15.0'; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; // ... but not in the local cache @@ -385,7 +382,6 @@ describe('setup-node', () => { const resolvedVersion = versionSpec; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; findSpy.mockImplementation(() => ''); @@ -405,7 +401,6 @@ describe('setup-node', () => { const versionSpec = '11.15.0'; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; // ... but not in the local cache @@ -448,7 +443,6 @@ describe('setup-node', () => { inputs['node-version'] = version; inputs['architecture'] = arch; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; const expectedUrl = @@ -560,7 +554,6 @@ describe('setup-node', () => { inputs['node-version'] = versionSpec; inputs['check-latest'] = 'true'; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; // ... but not in the local cache @@ -602,7 +595,6 @@ describe('setup-node', () => { inputs['node-version'] = versionSpec; inputs['check-latest'] = 'true'; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; // ... but not in the local cache @@ -882,7 +874,6 @@ describe('setup-node', () => { inputs['node-version'] = version; inputs['architecture'] = arch; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; inputs['mirror'] = 'https://my_mirror_url'; inputs['mirror-token'] = 'faketoken'; diff --git a/__tests__/rc-installer.test.ts b/__tests__/rc-installer.test.ts index 736260a4..e159044b 100644 --- a/__tests__/rc-installer.test.ts +++ b/__tests__/rc-installer.test.ts @@ -194,7 +194,6 @@ describe('setup-node', () => { const versionSpec = '13.0.0-rc.0'; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; // ... but not in the local cache @@ -239,7 +238,6 @@ describe('setup-node', () => { const versionSpec = '14.7.0-rc.1'; inputs['node-version'] = versionSpec; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; findSpy.mockImplementation(() => ''); @@ -268,7 +266,6 @@ describe('setup-node', () => { inputs['node-version'] = version; inputs['architecture'] = arch; - inputs['always-auth'] = false; inputs['token'] = 'faketoken'; const expectedUrl = `https://nodejs.org/download/rc/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`; diff --git a/action.yml b/action.yml index 73c766bc..da747954 100644 --- a/action.yml +++ b/action.yml @@ -2,9 +2,6 @@ name: 'Setup Node.js environment' description: 'Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH.' author: 'GitHub' inputs: - always-auth: - description: 'Set always-auth in npmrc.' - default: 'false' node-version: description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0.' node-version-file: diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 00e47927..1105527b 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -39,7 +39,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.saveCache = exports.restoreCache = exports.isFeatureAvailable = exports.ReserveCacheError = exports.ValidationError = void 0; +exports.saveCache = exports.restoreCache = exports.isFeatureAvailable = exports.FinalizeCacheError = exports.ReserveCacheError = exports.ValidationError = void 0; const core = __importStar(__nccwpck_require__(7484)); const path = __importStar(__nccwpck_require__(6928)); const utils = __importStar(__nccwpck_require__(680)); @@ -47,7 +47,7 @@ const cacheHttpClient = __importStar(__nccwpck_require__(5552)); const cacheTwirpClient = __importStar(__nccwpck_require__(6819)); const config_1 = __nccwpck_require__(7606); const tar_1 = __nccwpck_require__(5321); -const constants_1 = __nccwpck_require__(8287); +const http_client_1 = __nccwpck_require__(4844); class ValidationError extends Error { constructor(message) { super(message); @@ -64,6 +64,14 @@ class ReserveCacheError extends Error { } } exports.ReserveCacheError = ReserveCacheError; +class FinalizeCacheError extends Error { + constructor(message) { + super(message); + this.name = 'FinalizeCacheError'; + Object.setPrototypeOf(this, FinalizeCacheError.prototype); + } +} +exports.FinalizeCacheError = FinalizeCacheError; function checkPaths(paths) { if (!paths || paths.length === 0) { throw new ValidationError(`Path Validation Error: At least one directory or file path is required`); @@ -84,7 +92,17 @@ function checkKey(key) { * @returns boolean return true if Actions cache service feature is available, otherwise false */ function isFeatureAvailable() { - return !!process.env['ACTIONS_CACHE_URL']; + const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); + // Check availability based on cache service version + switch (cacheServiceVersion) { + case 'v2': + // For v2, we need ACTIONS_RESULTS_URL + return !!process.env['ACTIONS_RESULTS_URL']; + case 'v1': + default: + // For v1, we only need ACTIONS_CACHE_URL + return !!process.env['ACTIONS_CACHE_URL']; + } } exports.isFeatureAvailable = isFeatureAvailable; /** @@ -169,8 +187,16 @@ function restoreCacheV1(paths, primaryKey, restoreKeys, options, enableCrossOsAr throw error; } else { - // Supress all non-validation cache related errors because caching should be optional - core.warning(`Failed to restore: ${error.message}`); + // warn on cache restore failure and continue build + // Log server errors (5xx) as errors, all other errors as warnings + if (typedError instanceof http_client_1.HttpClientError && + typeof typedError.statusCode === 'number' && + typedError.statusCode >= 500) { + core.error(`Failed to restore: ${error.message}`); + } + else { + core.warning(`Failed to restore: ${error.message}`); + } } } finally { @@ -223,7 +249,13 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr core.debug(`Cache not found for version ${request.version} of keys: ${keys.join(', ')}`); return undefined; } - core.info(`Cache hit for: ${request.key}`); + const isRestoreKeyMatch = request.key !== response.matchedKey; + if (isRestoreKeyMatch) { + core.info(`Cache hit for restore-key: ${response.matchedKey}`); + } + else { + core.info(`Cache hit for: ${response.matchedKey}`); + } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { core.info('Lookup only - skipping download'); return response.matchedKey; @@ -248,7 +280,15 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr } else { // Supress all non-validation cache related errors because caching should be optional - core.warning(`Failed to restore: ${error.message}`); + // Log server errors (5xx) as errors, all other errors as warnings + if (typedError instanceof http_client_1.HttpClientError && + typeof typedError.statusCode === 'number' && + typedError.statusCode >= 500) { + core.error(`Failed to restore: ${error.message}`); + } + else { + core.warning(`Failed to restore: ${error.message}`); + } } } finally { @@ -351,7 +391,15 @@ function saveCacheV1(paths, key, options, enableCrossOsArchive = false) { core.info(`Failed to save: ${typedError.message}`); } else { - core.warning(`Failed to save: ${typedError.message}`); + // Log server errors (5xx) as errors, all other errors as warnings + if (typedError instanceof http_client_1.HttpClientError && + typeof typedError.statusCode === 'number' && + typedError.statusCode >= 500) { + core.error(`Failed to save: ${typedError.message}`); + } + else { + core.warning(`Failed to save: ${typedError.message}`); + } } } finally { @@ -400,10 +448,6 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); core.debug(`File Size: ${archiveFileSize}`); - // For GHES, this check will take place in ReserveCache API with enterprise file size limit - if (archiveFileSize > constants_1.CacheFileSizeLimit && !(0, config_1.isGhes)()) { - throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); - } // Set the archive size in the options, will be used to display the upload progress options.archiveSizeBytes = archiveFileSize; core.debug('Reserving Cache'); @@ -416,7 +460,10 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { try { const response = yield twirpClient.CreateCacheEntry(request); if (!response.ok) { - throw new Error('Response was not ok'); + if (response.message) { + core.warning(`Cache reservation failed: ${response.message}`); + } + throw new Error(response.message || 'Response was not ok'); } signedUploadUrl = response.signedUploadUrl; } @@ -434,6 +481,9 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); core.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { + if (finalizeResponse.message) { + throw new FinalizeCacheError(finalizeResponse.message); + } throw new Error(`Unable to finalize cache with key ${key}, another job may be finalizing this cache.`); } cacheId = parseInt(finalizeResponse.entryId); @@ -446,8 +496,19 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { else if (typedError.name === ReserveCacheError.name) { core.info(`Failed to save: ${typedError.message}`); } + else if (typedError.name === FinalizeCacheError.name) { + core.warning(typedError.message); + } else { - core.warning(`Failed to save: ${typedError.message}`); + // Log server errors (5xx) as errors, all other errors as warnings + if (typedError instanceof http_client_1.HttpClientError && + typeof typedError.statusCode === 'number' && + typedError.statusCode >= 500) { + core.error(`Failed to save: ${typedError.message}`); + } + else { + core.warning(`Failed to save: ${typedError.message}`); + } } } finally { @@ -549,11 +610,12 @@ class CreateCacheEntryResponse$Type extends runtime_5.MessageType { constructor() { super("github.actions.results.api.v1.CreateCacheEntryResponse", [ { no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }, - { no: 2, name: "signed_upload_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ } + { no: 2, name: "signed_upload_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + { no: 3, name: "message", kind: "scalar", T: 9 /*ScalarType.STRING*/ } ]); } create(value) { - const message = { ok: false, signedUploadUrl: "" }; + const message = { ok: false, signedUploadUrl: "", message: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -570,6 +632,9 @@ class CreateCacheEntryResponse$Type extends runtime_5.MessageType { case /* string signed_upload_url */ 2: message.signedUploadUrl = reader.string(); break; + case /* string message */ 3: + message.message = reader.string(); + break; default: let u = options.readUnknownField; if (u === "throw") @@ -588,6 +653,9 @@ class CreateCacheEntryResponse$Type extends runtime_5.MessageType { /* string signed_upload_url = 2; */ if (message.signedUploadUrl !== "") writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.signedUploadUrl); + /* string message = 3; */ + if (message.message !== "") + writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.message); let u = options.writeUnknownFields; if (u !== false) (u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); @@ -671,11 +739,12 @@ class FinalizeCacheEntryUploadResponse$Type extends runtime_5.MessageType { constructor() { super("github.actions.results.api.v1.FinalizeCacheEntryUploadResponse", [ { no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }, - { no: 2, name: "entry_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ } + { no: 2, name: "entry_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ }, + { no: 3, name: "message", kind: "scalar", T: 9 /*ScalarType.STRING*/ } ]); } create(value) { - const message = { ok: false, entryId: "0" }; + const message = { ok: false, entryId: "0", message: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -692,6 +761,9 @@ class FinalizeCacheEntryUploadResponse$Type extends runtime_5.MessageType { case /* int64 entry_id */ 2: message.entryId = reader.int64().toString(); break; + case /* string message */ 3: + message.message = reader.string(); + break; default: let u = options.readUnknownField; if (u === "throw") @@ -710,6 +782,9 @@ class FinalizeCacheEntryUploadResponse$Type extends runtime_5.MessageType { /* int64 entry_id = 2; */ if (message.entryId !== "0") writer.tag(2, runtime_1.WireType.Varint).int64(message.entryId); + /* string message = 3; */ + if (message.message !== "") + writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.message); let u = options.writeUnknownFields; if (u !== false) (u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); @@ -47828,6 +47903,10 @@ class RpcOutputStreamController { cmp: [], }; this._closed = false; + // --- RpcOutputStream async iterator API + // iterator state. + // is undefined when no iterator has been acquired yet. + this._itState = { q: [] }; } // --- RpcOutputStream callback API onNext(callback) { @@ -47927,10 +48006,6 @@ class RpcOutputStreamController { * messages are queued. */ [Symbol.asyncIterator]() { - // init the iterator state, enabling pushIt() - if (!this._itState) { - this._itState = { q: [] }; - } // if we are closed, we are definitely not receiving any more messages. // but we can't let the iterator get stuck. we want to either: // a) finish the new iterator immediately, because we are completed @@ -47963,8 +48038,6 @@ class RpcOutputStreamController { // this either resolves a pending promise, or enqueues the result. pushIt(result) { let state = this._itState; - if (!state) - return; // is the consumer waiting for us? if (state.p) { // yes, consumer is waiting for this promise. @@ -49876,6 +49949,7 @@ const reflection_equals_1 = __nccwpck_require__(4827); const binary_writer_1 = __nccwpck_require__(3957); const binary_reader_1 = __nccwpck_require__(2889); const baseDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})); +const messageTypeDescriptor = baseDescriptors[message_type_contract_1.MESSAGE_TYPE] = {}; /** * This standard message type provides reflection-based * operations to work with a message. @@ -49886,7 +49960,8 @@ class MessageType { this.typeName = name; this.fields = fields.map(reflection_info_1.normalizeFieldInfo); this.options = options !== null && options !== void 0 ? options : {}; - this.messagePrototype = Object.create(null, Object.assign(Object.assign({}, baseDescriptors), { [message_type_contract_1.MESSAGE_TYPE]: { value: this } })); + messageTypeDescriptor.value = this; + this.messagePrototype = Object.create(null, baseDescriptors); this.refTypeCheck = new reflection_type_check_1.ReflectionTypeCheck(this); this.refJsonReader = new reflection_json_reader_1.ReflectionJsonReader(this); this.refJsonWriter = new reflection_json_writer_1.ReflectionJsonWriter(this); @@ -91387,7 +91462,7 @@ module.exports = parseParams /***/ ((module) => { "use strict"; -module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.3","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1"},"devDependencies":{"@types/node":"^22.13.9","@types/semver":"^6.0.0","typescript":"^5.2.2"}}'); +module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.1.0","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","semver":"^6.3.1"},"devDependencies":{"@types/node":"^22.13.9","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"}}'); /***/ }), diff --git a/dist/setup/index.js b/dist/setup/index.js index 4aa29b26..48d93766 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -39,7 +39,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.saveCache = exports.restoreCache = exports.isFeatureAvailable = exports.ReserveCacheError = exports.ValidationError = void 0; +exports.saveCache = exports.restoreCache = exports.isFeatureAvailable = exports.FinalizeCacheError = exports.ReserveCacheError = exports.ValidationError = void 0; const core = __importStar(__nccwpck_require__(37484)); const path = __importStar(__nccwpck_require__(16928)); const utils = __importStar(__nccwpck_require__(98299)); @@ -47,7 +47,7 @@ const cacheHttpClient = __importStar(__nccwpck_require__(73171)); const cacheTwirpClient = __importStar(__nccwpck_require__(96819)); const config_1 = __nccwpck_require__(17606); const tar_1 = __nccwpck_require__(95321); -const constants_1 = __nccwpck_require__(58287); +const http_client_1 = __nccwpck_require__(54844); class ValidationError extends Error { constructor(message) { super(message); @@ -64,6 +64,14 @@ class ReserveCacheError extends Error { } } exports.ReserveCacheError = ReserveCacheError; +class FinalizeCacheError extends Error { + constructor(message) { + super(message); + this.name = 'FinalizeCacheError'; + Object.setPrototypeOf(this, FinalizeCacheError.prototype); + } +} +exports.FinalizeCacheError = FinalizeCacheError; function checkPaths(paths) { if (!paths || paths.length === 0) { throw new ValidationError(`Path Validation Error: At least one directory or file path is required`); @@ -84,7 +92,17 @@ function checkKey(key) { * @returns boolean return true if Actions cache service feature is available, otherwise false */ function isFeatureAvailable() { - return !!process.env['ACTIONS_CACHE_URL']; + const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); + // Check availability based on cache service version + switch (cacheServiceVersion) { + case 'v2': + // For v2, we need ACTIONS_RESULTS_URL + return !!process.env['ACTIONS_RESULTS_URL']; + case 'v1': + default: + // For v1, we only need ACTIONS_CACHE_URL + return !!process.env['ACTIONS_CACHE_URL']; + } } exports.isFeatureAvailable = isFeatureAvailable; /** @@ -169,8 +187,16 @@ function restoreCacheV1(paths, primaryKey, restoreKeys, options, enableCrossOsAr throw error; } else { - // Supress all non-validation cache related errors because caching should be optional - core.warning(`Failed to restore: ${error.message}`); + // warn on cache restore failure and continue build + // Log server errors (5xx) as errors, all other errors as warnings + if (typedError instanceof http_client_1.HttpClientError && + typeof typedError.statusCode === 'number' && + typedError.statusCode >= 500) { + core.error(`Failed to restore: ${error.message}`); + } + else { + core.warning(`Failed to restore: ${error.message}`); + } } } finally { @@ -223,7 +249,13 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr core.debug(`Cache not found for version ${request.version} of keys: ${keys.join(', ')}`); return undefined; } - core.info(`Cache hit for: ${request.key}`); + const isRestoreKeyMatch = request.key !== response.matchedKey; + if (isRestoreKeyMatch) { + core.info(`Cache hit for restore-key: ${response.matchedKey}`); + } + else { + core.info(`Cache hit for: ${response.matchedKey}`); + } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { core.info('Lookup only - skipping download'); return response.matchedKey; @@ -248,7 +280,15 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr } else { // Supress all non-validation cache related errors because caching should be optional - core.warning(`Failed to restore: ${error.message}`); + // Log server errors (5xx) as errors, all other errors as warnings + if (typedError instanceof http_client_1.HttpClientError && + typeof typedError.statusCode === 'number' && + typedError.statusCode >= 500) { + core.error(`Failed to restore: ${error.message}`); + } + else { + core.warning(`Failed to restore: ${error.message}`); + } } } finally { @@ -351,7 +391,15 @@ function saveCacheV1(paths, key, options, enableCrossOsArchive = false) { core.info(`Failed to save: ${typedError.message}`); } else { - core.warning(`Failed to save: ${typedError.message}`); + // Log server errors (5xx) as errors, all other errors as warnings + if (typedError instanceof http_client_1.HttpClientError && + typeof typedError.statusCode === 'number' && + typedError.statusCode >= 500) { + core.error(`Failed to save: ${typedError.message}`); + } + else { + core.warning(`Failed to save: ${typedError.message}`); + } } } finally { @@ -400,10 +448,6 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); core.debug(`File Size: ${archiveFileSize}`); - // For GHES, this check will take place in ReserveCache API with enterprise file size limit - if (archiveFileSize > constants_1.CacheFileSizeLimit && !(0, config_1.isGhes)()) { - throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); - } // Set the archive size in the options, will be used to display the upload progress options.archiveSizeBytes = archiveFileSize; core.debug('Reserving Cache'); @@ -416,7 +460,10 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { try { const response = yield twirpClient.CreateCacheEntry(request); if (!response.ok) { - throw new Error('Response was not ok'); + if (response.message) { + core.warning(`Cache reservation failed: ${response.message}`); + } + throw new Error(response.message || 'Response was not ok'); } signedUploadUrl = response.signedUploadUrl; } @@ -434,6 +481,9 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); core.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { + if (finalizeResponse.message) { + throw new FinalizeCacheError(finalizeResponse.message); + } throw new Error(`Unable to finalize cache with key ${key}, another job may be finalizing this cache.`); } cacheId = parseInt(finalizeResponse.entryId); @@ -446,8 +496,19 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { else if (typedError.name === ReserveCacheError.name) { core.info(`Failed to save: ${typedError.message}`); } + else if (typedError.name === FinalizeCacheError.name) { + core.warning(typedError.message); + } else { - core.warning(`Failed to save: ${typedError.message}`); + // Log server errors (5xx) as errors, all other errors as warnings + if (typedError instanceof http_client_1.HttpClientError && + typeof typedError.statusCode === 'number' && + typedError.statusCode >= 500) { + core.error(`Failed to save: ${typedError.message}`); + } + else { + core.warning(`Failed to save: ${typedError.message}`); + } } } finally { @@ -549,11 +610,12 @@ class CreateCacheEntryResponse$Type extends runtime_5.MessageType { constructor() { super("github.actions.results.api.v1.CreateCacheEntryResponse", [ { no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }, - { no: 2, name: "signed_upload_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ } + { no: 2, name: "signed_upload_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, + { no: 3, name: "message", kind: "scalar", T: 9 /*ScalarType.STRING*/ } ]); } create(value) { - const message = { ok: false, signedUploadUrl: "" }; + const message = { ok: false, signedUploadUrl: "", message: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -570,6 +632,9 @@ class CreateCacheEntryResponse$Type extends runtime_5.MessageType { case /* string signed_upload_url */ 2: message.signedUploadUrl = reader.string(); break; + case /* string message */ 3: + message.message = reader.string(); + break; default: let u = options.readUnknownField; if (u === "throw") @@ -588,6 +653,9 @@ class CreateCacheEntryResponse$Type extends runtime_5.MessageType { /* string signed_upload_url = 2; */ if (message.signedUploadUrl !== "") writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.signedUploadUrl); + /* string message = 3; */ + if (message.message !== "") + writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.message); let u = options.writeUnknownFields; if (u !== false) (u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); @@ -671,11 +739,12 @@ class FinalizeCacheEntryUploadResponse$Type extends runtime_5.MessageType { constructor() { super("github.actions.results.api.v1.FinalizeCacheEntryUploadResponse", [ { no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }, - { no: 2, name: "entry_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ } + { no: 2, name: "entry_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ }, + { no: 3, name: "message", kind: "scalar", T: 9 /*ScalarType.STRING*/ } ]); } create(value) { - const message = { ok: false, entryId: "0" }; + const message = { ok: false, entryId: "0", message: "" }; globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) (0, runtime_3.reflectionMergePartial)(this, message, value); @@ -692,6 +761,9 @@ class FinalizeCacheEntryUploadResponse$Type extends runtime_5.MessageType { case /* int64 entry_id */ 2: message.entryId = reader.int64().toString(); break; + case /* string message */ 3: + message.message = reader.string(); + break; default: let u = options.readUnknownField; if (u === "throw") @@ -710,6 +782,9 @@ class FinalizeCacheEntryUploadResponse$Type extends runtime_5.MessageType { /* int64 entry_id = 2; */ if (message.entryId !== "0") writer.tag(2, runtime_1.WireType.Varint).int64(message.entryId); + /* string message = 3; */ + if (message.message !== "") + writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.message); let u = options.writeUnknownFields; if (u !== false) (u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); @@ -54329,6 +54404,10 @@ class RpcOutputStreamController { cmp: [], }; this._closed = false; + // --- RpcOutputStream async iterator API + // iterator state. + // is undefined when no iterator has been acquired yet. + this._itState = { q: [] }; } // --- RpcOutputStream callback API onNext(callback) { @@ -54428,10 +54507,6 @@ class RpcOutputStreamController { * messages are queued. */ [Symbol.asyncIterator]() { - // init the iterator state, enabling pushIt() - if (!this._itState) { - this._itState = { q: [] }; - } // if we are closed, we are definitely not receiving any more messages. // but we can't let the iterator get stuck. we want to either: // a) finish the new iterator immediately, because we are completed @@ -54464,8 +54539,6 @@ class RpcOutputStreamController { // this either resolves a pending promise, or enqueues the result. pushIt(result) { let state = this._itState; - if (!state) - return; // is the consumer waiting for us? if (state.p) { // yes, consumer is waiting for this promise. @@ -56377,6 +56450,7 @@ const reflection_equals_1 = __nccwpck_require__(4827); const binary_writer_1 = __nccwpck_require__(23957); const binary_reader_1 = __nccwpck_require__(92889); const baseDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})); +const messageTypeDescriptor = baseDescriptors[message_type_contract_1.MESSAGE_TYPE] = {}; /** * This standard message type provides reflection-based * operations to work with a message. @@ -56387,7 +56461,8 @@ class MessageType { this.typeName = name; this.fields = fields.map(reflection_info_1.normalizeFieldInfo); this.options = options !== null && options !== void 0 ? options : {}; - this.messagePrototype = Object.create(null, Object.assign(Object.assign({}, baseDescriptors), { [message_type_contract_1.MESSAGE_TYPE]: { value: this } })); + messageTypeDescriptor.value = this; + this.messagePrototype = Object.create(null, baseDescriptors); this.refTypeCheck = new reflection_type_check_1.ReflectionTypeCheck(this); this.refJsonReader = new reflection_json_reader_1.ReflectionJsonReader(this); this.refJsonWriter = new reflection_json_writer_1.ReflectionJsonWriter(this); @@ -98514,15 +98589,15 @@ const os = __importStar(__nccwpck_require__(70857)); const path = __importStar(__nccwpck_require__(16928)); const core = __importStar(__nccwpck_require__(37484)); const github = __importStar(__nccwpck_require__(93228)); -function configAuthentication(registryUrl, alwaysAuth) { +function configAuthentication(registryUrl) { const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc'); if (!registryUrl.endsWith('/')) { registryUrl += '/'; } - writeRegistryToFile(registryUrl, npmrc, alwaysAuth); + writeRegistryToFile(registryUrl, npmrc); } exports.configAuthentication = configAuthentication; -function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) { +function writeRegistryToFile(registryUrl, fileLocation) { let scope = core.getInput('scope'); if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) { scope = github.context.repo.owner; @@ -98547,8 +98622,7 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) { // Remove http: or https: from front of registry. const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}'; const registryString = `${scope}registry=${registryUrl}`; - const alwaysAuthString = `always-auth=${alwaysAuth}`; - newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`; + newContents += `${authString}${os.EOL}${registryString}`; fs.writeFileSync(fileLocation, newContents); core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); // Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it @@ -99782,9 +99856,8 @@ function run() { } yield (0, util_1.printEnvDetailsAndSetOutput)(); const registryUrl = core.getInput('registry-url'); - const alwaysAuth = core.getInput('always-auth'); if (registryUrl) { - auth.configAuthentication(registryUrl, alwaysAuth); + auth.configAuthentication(registryUrl); } const cacheDependencyPath = core.getInput('cache-dependency-path'); if ((0, cache_utils_1.isCacheFeatureAvailable)()) { @@ -102519,7 +102592,7 @@ exports["default"] = version; /***/ ((module) => { "use strict"; -module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.3","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1"},"devDependencies":{"@types/node":"^22.13.9","@types/semver":"^6.0.0","typescript":"^5.2.2"}}'); +module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.1.0","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","semver":"^6.3.1"},"devDependencies":{"@types/node":"^22.13.9","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"}}'); /***/ }), diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index f2a8a2f3..ee265a69 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -1,6 +1,6 @@ ## Working with lockfiles -All supported package managers recommend that you **always** commit the lockfile, although implementations vary doing so generally provides the following benefits: +Most supported package managers recommend that you **always** commit the lockfile, although implementations vary doing so generally provides the following benefits: - Enables faster installation for CI and production environments, due to being able to skip package resolution. - Describes a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies. @@ -35,6 +35,25 @@ Ensure that `pnpm-lock.yaml` is always committed, when on CI pass `--frozen-lock - [Working with Git - Lockfiles](https://pnpm.io/git#lockfiles) - [Documentation of `--frozen-lockfile` option](https://pnpm.io/cli/install#--frozen-lockfile) +### Running without a lockfile + +If you choose not to use a lockfile, you must ensure that **caching is disabled**. The `cache` feature relies on the lockfile to generate a unique key for the cache entry. + +To run without a lockfile: +1. Do not set the `cache` input. +2. If your `package.json` contains a `packageManager` field set to npm (or devEngines.packageManager), automatic caching is enabled by default. Override this by setting `package-manager-cache: false`. + +```yaml +steps: +- uses: actions/checkout@v6 +- uses: actions/setup-node@v6 + with: + node-version: '24' + package-manager-cache: false # Explicitly disable caching if you don't have a lockfile +- run: npm install +- run: npm test +``` + ## Check latest version The `check-latest` flag defaults to `false`. When set to `false`, the action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/). Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Node.js is always used. @@ -300,6 +319,35 @@ steps: - run: npm test ``` +**Restore-Only Cache** + +```yaml +## In some workflows, you may want to restore a cache without saving it. This can help reduce cache writes and storage usage in workflows that only need to read from cache +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + # Restore Node.js modules cache (restore-only) + - name: Restore Node modules cache + uses: actions/cache@v4 + id: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + # Setup Node.js + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: '24' + # Install dependencies + - run: npm install +``` + +> For more details related to cache scenarios, please refer [Node – npm](https://github.com/actions/cache/blob/main/examples.md#node---npm). + ## Multiple Operating Systems and Architectures ```yaml @@ -417,9 +465,6 @@ To access private GitHub Packages within the same organization, go to "Manage Ac Please refer to the [Ensuring workflow access to your package - Configuring a package's access control and visibility](https://docs.github.com/en/packages/learn-github-packages/configuring-a-packages-access-control-and-visibility#ensuring-workflow-access-to-your-package) for more details. -### always-auth input -The always-auth input sets `always-auth=true` in .npmrc file. With this option set [npm](https://docs.npmjs.com/cli/v6/using-npm/config#always-auth)/yarn sends the authentication credentials when making a request to the registries. - ## Use private mirror It is possible to use a private mirror hosting Node.js binaries. This mirror must be a full mirror of the official Node.js distribution. diff --git a/package-lock.json b/package-lock.json index 297a9fdc..143fcb71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "6.0.0", "license": "MIT", "dependencies": { - "@actions/cache": "^4.0.3", + "@actions/cache": "^4.1.0", "@actions/core": "^1.11.1", "@actions/exec": "^1.1.1", "@actions/github": "^6.0.1", @@ -52,9 +52,9 @@ } }, "node_modules/@actions/cache": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-4.0.3.tgz", - "integrity": "sha512-SvrqFtYJ7I48A/uXNkoJrnukx5weQv1fGquhs3+4nkByZThBH109KTIqj5x/cGV7JGNvb8dLPVywUOqX1fjiXg==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-4.1.0.tgz", + "integrity": "sha512-z3Opg+P4Y7baq+g1dODXgdtsvPLSewr3ZKpp3U0HQR1A/vWCoJFS52XSezjdngo4SIOdR5oHtyK3a3Arar+X9A==", "license": "MIT", "dependencies": { "@actions/core": "^1.11.1", @@ -65,7 +65,7 @@ "@azure/abort-controller": "^1.1.0", "@azure/ms-rest-js": "^2.6.0", "@azure/storage-blob": "^12.13.0", - "@protobuf-ts/plugin": "^2.9.4", + "@protobuf-ts/runtime-rpc": "^2.11.1", "semver": "^6.3.1" } }, @@ -994,10 +994,11 @@ } }, "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", + "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", "dev": true, + "license": "MIT", "dependencies": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -1590,81 +1591,19 @@ "node": ">=8.0.0" } }, - "node_modules/@protobuf-ts/plugin": { - "version": "2.9.5", - "resolved": "https://registry.npmjs.org/@protobuf-ts/plugin/-/plugin-2.9.5.tgz", - "integrity": "sha512-KCzNRTFye837XdfPjS85gGzxgPGVDR3W8Px2G3etXuouNog9W+Cr+U0IBTFADrRWXC2x+OSNjXxrdZEiw+H5Cw==", - "license": "Apache-2.0", - "dependencies": { - "@protobuf-ts/plugin-framework": "^2.9.5", - "@protobuf-ts/protoc": "^2.9.5", - "@protobuf-ts/runtime": "^2.9.5", - "@protobuf-ts/runtime-rpc": "^2.9.5", - "typescript": "^3.9" - }, - "bin": { - "protoc-gen-dump": "bin/protoc-gen-dump", - "protoc-gen-ts": "bin/protoc-gen-ts" - } - }, - "node_modules/@protobuf-ts/plugin-framework": { - "version": "2.9.5", - "resolved": "https://registry.npmjs.org/@protobuf-ts/plugin-framework/-/plugin-framework-2.9.5.tgz", - "integrity": "sha512-DYNQ8Ga3xwPZMfaZGRCnDOcEdQZK9MorTXngVoFLnHWEE8zLhUjFVtdkChZtTih6rl8Z6akyA7hRgj/GrJF58Q==", - "license": "(Apache-2.0 AND BSD-3-Clause)", - "dependencies": { - "@protobuf-ts/runtime": "^2.9.5", - "typescript": "^3.9" - } - }, - "node_modules/@protobuf-ts/plugin-framework/node_modules/typescript": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", - "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/@protobuf-ts/plugin/node_modules/typescript": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", - "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/@protobuf-ts/protoc": { - "version": "2.9.5", - "resolved": "https://registry.npmjs.org/@protobuf-ts/protoc/-/protoc-2.9.5.tgz", - "integrity": "sha512-n6a7OHfr/Ubw483L6kNJB0wBCe/Ops0A652zB6J6nR2x1o+pjVFrMCeeQQsqxkYpQwQ8FCIETSxrMpfOBKTIvQ==", - "license": "Apache-2.0", - "bin": { - "protoc": "protoc.js" - } - }, "node_modules/@protobuf-ts/runtime": { - "version": "2.9.5", - "resolved": "https://registry.npmjs.org/@protobuf-ts/runtime/-/runtime-2.9.5.tgz", - "integrity": "sha512-SsumigRe3IqNTCQvVZUqDQExsKF72eyAMiWlYb5Jwj3eU4z8UH7JLlSfb/Wjidz4b/chTN6zh5AXBSKl0Asm3A==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@protobuf-ts/runtime/-/runtime-2.11.1.tgz", + "integrity": "sha512-KuDaT1IfHkugM2pyz+FwiY80ejWrkH1pAtOBOZFuR6SXEFTsnb/jiQWQ1rCIrcKx2BtyxnxW6BWwsVSA/Ie+WQ==", "license": "(Apache-2.0 AND BSD-3-Clause)" }, "node_modules/@protobuf-ts/runtime-rpc": { - "version": "2.9.5", - "resolved": "https://registry.npmjs.org/@protobuf-ts/runtime-rpc/-/runtime-rpc-2.9.5.tgz", - "integrity": "sha512-NWAb1TaV4CR+BknZr1WRVT5Ws2AupVwGgRNes4oPAFrgLNXQotDFl2E6pmsjPwME8sAgJVzeSr7bUqQVyoAK2A==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@protobuf-ts/runtime-rpc/-/runtime-rpc-2.11.1.tgz", + "integrity": "sha512-4CqqUmNA+/uMz00+d3CYKgElXO9VrEbucjnBFEjqI4GuDrEQ32MaI3q+9qPBvIGOlL4PmHXrzM32vBPWRhQKWQ==", "license": "Apache-2.0", "dependencies": { - "@protobuf-ts/runtime": "^2.9.5" + "@protobuf-ts/runtime": "^2.11.1" } }, "node_modules/@sinclair/typebox": { @@ -4377,10 +4316,11 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", "dev": true, + "license": "MIT", "dependencies": { "argparse": "^2.0.1" }, diff --git a/package.json b/package.json index ef1cfc19..74857446 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "^4.0.3", + "@actions/cache": "^4.1.0", "@actions/core": "^1.11.1", "@actions/exec": "^1.1.1", "@actions/github": "^6.0.1", diff --git a/src/authutil.ts b/src/authutil.ts index 2ce94939..e4b823bd 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -4,7 +4,7 @@ import * as path from 'path'; import * as core from '@actions/core'; import * as github from '@actions/github'; -export function configAuthentication(registryUrl: string, alwaysAuth: string) { +export function configAuthentication(registryUrl: string) { const npmrc: string = path.resolve( process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc' @@ -13,14 +13,10 @@ export function configAuthentication(registryUrl: string, alwaysAuth: string) { registryUrl += '/'; } - writeRegistryToFile(registryUrl, npmrc, alwaysAuth); + writeRegistryToFile(registryUrl, npmrc); } -function writeRegistryToFile( - registryUrl: string, - fileLocation: string, - alwaysAuth: string -) { +function writeRegistryToFile(registryUrl: string, fileLocation: string) { let scope: string = core.getInput('scope'); if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) { scope = github.context.repo.owner; @@ -47,8 +43,7 @@ function writeRegistryToFile( const authString: string = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}'; const registryString = `${scope}registry=${registryUrl}`; - const alwaysAuthString = `always-auth=${alwaysAuth}`; - newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`; + newContents += `${authString}${os.EOL}${registryString}`; fs.writeFileSync(fileLocation, newContents); core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); // Export empty node_auth_token if didn't exist so npm doesn't complain about not being able to find it diff --git a/src/main.ts b/src/main.ts index 07871150..4afbd293 100644 --- a/src/main.ts +++ b/src/main.ts @@ -62,9 +62,8 @@ export async function run() { await printEnvDetailsAndSetOutput(); const registryUrl: string = core.getInput('registry-url'); - const alwaysAuth: string = core.getInput('always-auth'); if (registryUrl) { - auth.configAuthentication(registryUrl, alwaysAuth); + auth.configAuthentication(registryUrl); } const cacheDependencyPath = core.getInput('cache-dependency-path');