From 26b35031a2a035ccb0b457a706ba12203ea27401 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 15 Mar 2022 19:05:05 -0700 Subject: [PATCH] Add basic support for --verifytypes; closes #4 --- README.md | 3 +++ action.yml | 3 +++ dist/index.js | 7 ++++++- src/main.ts | 15 +++++++++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9544d34..7638a49 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,9 @@ inputs: description: 'Use library code to infer types when stubs are missing.' required: false default: 'false' +verify-types: + description: 'Package name to run the type verifier on; must be an *installed* library. Any score under 100% will fail the build.' + required: false extra-args: description: 'Extra arguments; can be used to specify specific files to check.' required: false diff --git a/action.yml b/action.yml index 2353b34..28d9ce2 100644 --- a/action.yml +++ b/action.yml @@ -35,6 +35,9 @@ inputs: description: 'Use exit code of 1 if warnings are reported.' required: false default: 'false' + verify-types: + description: description: 'Package name to run the type verifier on; must be an *installed* library. Any score under 100% will fail the build.' + required: false extra-args: description: 'Extra arguments; can be used to specify specific files to check.' required: false diff --git a/dist/index.js b/dist/index.js index 737b31b..e24fa15 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6198,7 +6198,7 @@ async function main() { console.log(`pyright ${version}, node ${process.version}`); const { args, noComments } = await getArgs(version); console.log(`${process.execPath} ${args.join(" ")}`); - if (noComments) { + if (noComments || args.indexOf("--verifytypes") >= 0) { const { status: status2 } = cp.spawnSync(process.execPath, args, { stdio: ["ignore", "inherit", "inherit"] }); @@ -6291,6 +6291,11 @@ async function getArgs(version) { if (warnings) { args.push("--warnings"); } + const verifyTypes = core.getInput("verify-types"); + if (project) { + args.push("--verifytypes"); + args.push(verifyTypes); + } const extraArgs = core.getInput("extra-args"); if (extraArgs) { args.push(...(0, import_string_argv.default)(extraArgs)); diff --git a/src/main.ts b/src/main.ts index da678ad..e6ced0b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -22,8 +22,13 @@ export async function main() { const { args, noComments } = await getArgs(version); console.log(`${process.execPath} ${args.join(' ')}`); - if (noComments) { - // Comments are disabled, just run as a subprocess passing things through. + if (noComments || args.indexOf('--verifytypes') >= 0) { + // If comments are disabled, there's no point in directly processing the output, + // as it's only used for comments. + // If we're running the type verifier, there's no guarantee that we can even act + // on the output besides the exit code. + // + // So, in either case, just directly run pyright and exit with its status. const { status } = cp.spawnSync(process.execPath, args, { stdio: ['ignore', 'inherit', 'inherit'], }); @@ -150,6 +155,12 @@ async function getArgs(version: SemVer) { args.push('--warnings'); } + const verifyTypes = core.getInput('verify-types'); + if (project) { + args.push('--verifytypes'); + args.push(verifyTypes); + } + const extraArgs = core.getInput('extra-args'); if (extraArgs) { args.push(...stringArgv(extraArgs));