diff --git a/CODEOWNERS b/.github/CODEOWNERS similarity index 100% rename from CODEOWNERS rename to .github/CODEOWNERS diff --git a/.github/actions/generate-action-code/action.yml b/.github/actions/generate-action-code/action.yml index 00b10bd..7f44878 100644 --- a/.github/actions/generate-action-code/action.yml +++ b/.github/actions/generate-action-code/action.yml @@ -6,7 +6,7 @@ runs: steps: - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 20 check-latest: true cache: 'npm' - name: Generate action code diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e22ad66..554ee73 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -26,7 +26,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8ee4d14..9ae360e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,7 +10,7 @@ jobs: name: Deploy Action Code runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: token: ${{ secrets.BOT_TOKEN }} - uses: ./.github/actions/generate-action-code diff --git a/.github/workflows/tag-update.yml b/.github/workflows/tag-update.yml index 8d3db78..49d757a 100644 --- a/.github/workflows/tag-update.yml +++ b/.github/workflows/tag-update.yml @@ -8,10 +8,10 @@ jobs: update-tags: name: Update Running Releases runs-on: ubuntu-latest + if: ${{ github.event.release.prerelease == false }} steps: - - uses: actions/checkout@v3 - - uses: sersoft-gmbh/running-release-tags-action@v2 - if: ${{ github.event.release.prerelease == false }} + - uses: actions/checkout@v4 + - uses: sersoft-gmbh/running-release-tags-action@v3 with: update-full-release: true github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bc8dcb6..0e546b1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,7 +27,7 @@ jobs: with: release-version: 5.7 github-token: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Generate action code if: ${{ github.event_name == 'pull_request' }} uses: ./.github/actions/generate-action-code @@ -77,7 +77,7 @@ jobs: with: release-version: 5.7 github-token: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Generate action code if: ${{ github.event_name == 'pull_request' }} uses: ./.github/actions/generate-action-code diff --git a/README.md b/README.md index 7478d1b..2428933 100644 --- a/README.md +++ b/README.md @@ -51,16 +51,17 @@ The JSON encoded array of (absolute) file paths that were written. They are all Use the following snippet after running tests with Swift or Xcode to convert those coverage files: ```yaml -uses: sersoft-gmbh/swift-coverage-action@v3 +uses: sersoft-gmbh/swift-coverage-action@v4 ``` -### Codecov Action v2 +### Codecov Action (v2 or later) -To use this action together with [codecov/codecov-action@v2](https://github.com/codecov/codecov-action), you need to convert the output to a comma separated string: +To use this action together with [codecov/codecov-action](https://github.com/codecov/codecov-action), you need to convert the output to a comma separated string: ```yaml -- uses: sersoft-gmbh/swift-coverage-action@v3 +- uses: sersoft-gmbh/swift-coverage-action@v4 id: coverage-files -- uses: codecov/codecov-action@v2 +- uses: codecov/codecov-action@v3 with: - files: ${{join(fromJSON(steps.coverage-files.outputs.files), ',')}} + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }} ``` diff --git a/action.yml b/action.yml index 47106f9..45f0852 100644 --- a/action.yml +++ b/action.yml @@ -31,7 +31,7 @@ outputs: files: description: The JSON-encoded array of (absolute) file paths that were converted. runs: - using: node16 + using: node20 main: dist/index.js branding: color: gray-dark diff --git a/dist/index.js b/dist/index.js index cf49426..f131529 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31,13 +31,13 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); const core = __importStar(__nccwpck_require__(186)); -const exec = __importStar(__nccwpck_require__(514)); +const exec_1 = __nccwpck_require__(514); const io = __importStar(__nccwpck_require__(436)); const fs_1 = __nccwpck_require__(147); const path = __importStar(__nccwpck_require__(17)); const os = __importStar(__nccwpck_require__(37)); -async function runCmd(cmd, args) { - const output = await exec.getExecOutput(cmd, args, { silent: !core.isDebug() }); +async function runCmd(cmd, ...args) { + const output = await (0, exec_1.getExecOutput)(cmd, args.length <= 0 ? undefined : args, { silent: !core.isDebug() }); if (output.stderr.length > 0) core.warning(`Command execution wrote lines to stderr:\n${output.stderr}`); return output.stdout; @@ -199,22 +199,18 @@ async function main() { args.push('-instr-profile', profDataFile, dest); let converted; try { - converted = await runCmd(cmd, args); + converted = await runCmd(cmd, ...args); } catch (error) { const msg = `Failed to convert ${dest}: ${error}`; - if (error instanceof Error) { + if (error instanceof Error) conversionFailures.push(error); - } - else { + else conversionFailures.push(new Error(msg)); - } - if (ignoreConversionFailures) { + if (ignoreConversionFailures) core.info(msg); - } - else { + else core.error(msg); - } continue; } const projFileName = proj.replace(/\s/g, ''); @@ -226,12 +222,10 @@ async function main() { } } if (conversionFailures.length > 0) { - if (ignoreConversionFailures) { + if (ignoreConversionFailures) core.info(`Failed to convert ${conversionFailures.length} file(s)...`); - } - else { + else throw new Error('Conversion failures:\n' + conversionFailures.map(e => e.toString()).join('\n')); - } } core.info(`Processed ${outFiles.length} file(s):\n${outFiles.join('\n')}`); return outFiles; @@ -808,7 +802,7 @@ class OidcClient { .catch(error => { throw new Error(`Failed to get ID Token. \n Error Code : ${error.statusCode}\n - Error Message: ${error.result.message}`); + Error Message: ${error.message}`); }); const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; if (!id_token) { diff --git a/dist/license.txt b/dist/license.txt new file mode 100644 index 0000000..d771846 --- /dev/null +++ b/dist/license.txt @@ -0,0 +1,97 @@ +@actions/core +MIT +The MIT License (MIT) + +Copyright 2019 GitHub + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +@actions/exec +MIT +The MIT License (MIT) + +Copyright 2019 GitHub + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +@actions/http-client +MIT +Actions Http Client for Node.js + +Copyright (c) GitHub, Inc. + +All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +@actions/io +MIT +The MIT License (MIT) + +Copyright 2019 GitHub + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +tunnel +MIT +The MIT License (MIT) + +Copyright (c) 2012 Koichi Kobayashi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +uuid +MIT +The MIT License (MIT) + +Copyright (c) 2010-2020 Robert Kieffer and other contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/package-lock.json b/package-lock.json index 04d7ae1..7701980 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,28 +1,32 @@ { "name": "swift-coverage-action", - "version": "3.0.0", + "version": "4.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "swift-coverage-action", - "version": "3.0.0", + "version": "4.0.0", "license": "Apache-2.0", "dependencies": { - "@actions/core": "^1.10.0", + "@actions/core": "^1.10.1", "@actions/exec": "^1.1.1", "@actions/io": "^1.1.3" }, "devDependencies": { - "@types/node": "^16.18.36", - "@vercel/ncc": "^0.36.1", - "typescript": "^5.1.3" + "@tsconfig/node20": "^20.1.2", + "@types/node": "^20.6.2", + "@vercel/ncc": "^0.38.0", + "typescript": "^5.2.2" + }, + "engines": { + "node": ">=20" } }, "node_modules/@actions/core": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", - "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz", + "integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==", "dependencies": { "@actions/http-client": "^2.0.1", "uuid": "^8.3.2" @@ -49,16 +53,22 @@ "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz", "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==" }, + "node_modules/@tsconfig/node20": { + "version": "20.1.2", + "resolved": "https://registry.npmjs.org/@tsconfig/node20/-/node20-20.1.2.tgz", + "integrity": "sha512-madaWq2k+LYMEhmcp0fs+OGaLFk0OenpHa4gmI4VEmCKX4PJntQ6fnnGADVFrVkBj0wIdAlQnK/MrlYTHsa1gQ==", + "dev": true + }, "node_modules/@types/node": { - "version": "16.18.36", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.36.tgz", - "integrity": "sha512-8egDX8dE50XyXWH6C6PRCNkTP106DuUrvdrednFouDSmCi7IOvrqr0frznfZaHifHH/3aq/7a7v9N4wdXMqhBQ==", + "version": "20.6.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.2.tgz", + "integrity": "sha512-Y+/1vGBHV/cYk6OI1Na/LHzwnlNCAfU3ZNGrc1LdRe/LAIbdDPTTv/HU3M7yXN448aTVDq3eKRm2cg7iKLb8gw==", "dev": true }, "node_modules/@vercel/ncc": { - "version": "0.36.1", - "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.1.tgz", - "integrity": "sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==", + "version": "0.38.0", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.0.tgz", + "integrity": "sha512-B4YKZMm/EqMptKSFyAq4q2SlgJe+VCmEH6Y8gf/E1pTlWbsUJpuH1ymik2Ex3aYO5mCWwV1kaSYHSQOT8+4vHA==", "dev": true, "bin": { "ncc": "dist/ncc/cli.js" @@ -73,9 +83,9 @@ } }, "node_modules/typescript": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", - "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index f95f81d..c61c48a 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,17 @@ { "name": "swift-coverage-action", - "version": "3.0.0", + "version": "4.0.0", "description": "A GitHub action that converts Swift / Xcode code coverage files.", - "main": "dist/index.js", + "engines": { + "node": ">=20" + }, + "exports": { + ".": "./dist/index.js" + }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "tsc", - "pack": "rm -rf dist && ncc build lib/main.js -o dist" + "pack": "rm -rf dist && ncc build lib/main.js -o dist --license license.txt --target es2022" }, "repository": { "type": "git", @@ -26,13 +31,14 @@ }, "homepage": "https://github.com/sersoft-gmbh/swift-coverage-action#readme", "dependencies": { - "@actions/core": "^1.10.0", + "@actions/core": "^1.10.1", "@actions/exec": "^1.1.1", "@actions/io": "^1.1.3" }, "devDependencies": { - "@types/node": "^16.18.36", - "@vercel/ncc": "^0.36.1", - "typescript": "^5.1.3" + "@tsconfig/node20": "^20.1.2", + "@types/node": "^20.6.2", + "@vercel/ncc": "^0.38.0", + "typescript": "^5.2.2" } } diff --git a/src/main.ts b/src/main.ts index 42453c2..4dcfae3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,12 +1,12 @@ import * as core from '@actions/core'; -import * as exec from '@actions/exec'; +import { getExecOutput } from '@actions/exec'; import * as io from '@actions/io'; import { existsSync as exists, PathLike, promises as fs } from 'fs'; import * as path from 'path'; import * as os from 'os'; -async function runCmd(cmd: string, args?: string[]): Promise { - const output = await exec.getExecOutput(cmd, args, { silent: !core.isDebug() }); +async function runCmd(cmd: string, ...args: string[]): Promise { + const output = await getExecOutput(cmd, args.length <= 0 ? undefined : args, { silent: !core.isDebug() }); if (output.stderr.length > 0) core.warning(`Command execution wrote lines to stderr:\n${output.stderr}`); return output.stdout; @@ -14,7 +14,7 @@ async function runCmd(cmd: string, args?: string[]): Promise { enum CovFormat { txt = 'txt', - lcov = 'lcov' + lcov = 'lcov', } declare type WalkEntry = { @@ -67,8 +67,7 @@ async function main() { .replace(/(~|\$HOME|\${HOME})/g, os.homedir)); const _format = core.getInput('format', { required: true }) const format = CovFormat[_format as keyof typeof CovFormat]; - if (!format) - throw new Error(`Invalid format: ${_format}`); + if (!format) throw new Error(`Invalid format: ${_format}`); const _targetNameFilter = core.getInput('target-name-filter'); const targetNameFilter = _targetNameFilter ? new RegExp(_targetNameFilter) : null; const ignoreConversionFailures = core.getBooleanInput('ignore-conversion-failures'); @@ -175,22 +174,18 @@ async function main() { fileEnding = 'lcov'; break; } - args.push('-instr-profile', profDataFile, dest) + args.push('-instr-profile', profDataFile, dest); let converted: string; try { - converted = await runCmd(cmd, args); + converted = await runCmd(cmd, ...args); } catch (error: any) { const msg = `Failed to convert ${dest}: ${error}`; - if (error instanceof Error) { + if (error instanceof Error) conversionFailures.push(error); - } else { + else conversionFailures.push(new Error(msg)); - } - if (ignoreConversionFailures) { - core.info(msg); - } else { - core.error(msg); - } + if (ignoreConversionFailures) core.info(msg); + else core.error(msg); continue; } const projFileName = proj.replace(/\s/g, ''); @@ -202,11 +197,10 @@ async function main() { } } if (conversionFailures.length > 0) { - if (ignoreConversionFailures) { + if (ignoreConversionFailures) core.info(`Failed to convert ${conversionFailures.length} file(s)...`); - } else { + else throw new Error('Conversion failures:\n' + conversionFailures.map(e => e.toString()).join('\n')); - } } core.info(`Processed ${outFiles.length} file(s):\n${outFiles.join('\n')}`); return outFiles; diff --git a/tsconfig.json b/tsconfig.json index fb4b0bd..e01c40f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,8 @@ { + "extends": "@tsconfig/node20/tsconfig.json", "compilerOptions": { - "target": "ES2019", - "module": "commonjs", - "outDir": "./lib", - "rootDir": "./src", - "strict": true, - "esModuleInterop": true + "outDir": "lib", + "rootDir": "src", }, "include": ["src/**/*"] }