From 517f62fc0c0a1de1ed7aac4e9f8d304c38945a1b Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 6 May 2020 18:00:13 +0200 Subject: [PATCH] Codecov --- .github/workflows/test.yml | 8 ++++++++ .prettierrc.json | 2 +- README.md | 1 + dist/index.js | 16 +++++++--------- src/gpg.ts | 26 ++++++++++++-------------- src/main.ts | 6 ++---- src/openpgp.ts | 7 +------ tsconfig.json | 3 ++- 8 files changed, 34 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4aa0cb2..2f05e70 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,3 +32,11 @@ jobs: - name: Test run: npm run test + - + # https://github.com/codecov/codecov-action + name: Upload coverage + uses: codecov/codecov-action@v1 + if: success() + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage/clover.xml diff --git a/.prettierrc.json b/.prettierrc.json index 1339e9b..d8339f6 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,5 +1,5 @@ { - "printWidth": 120, + "printWidth": 240, "tabWidth": 2, "useTabs": false, "semi": true, diff --git a/README.md b/README.md index 545d8c4..c738b77 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ [![GitHub release](https://img.shields.io/github/release/crazy-max/ghaction-import-gpg.svg?style=flat-square)](https://github.com/crazy-max/ghaction-import-gpg/releases/latest) [![GitHub marketplace](https://img.shields.io/badge/marketplace-import--gpg-blue?logo=github&style=flat-square)](https://github.com/marketplace/actions/import-gpg) [![Test workflow](https://github.com/crazy-max/ghaction-import-gpg/workflows/test/badge.svg)](https://github.com/crazy-max/ghaction-import-gpg/actions?workflow=test) +[![Codecov](https://codecov.io/gh/crazy-max/ghaction-import-gpg/workflows/test/badge.svg)](https://codecov.io/gh/crazy-max/ghaction-import-gpg) [![Become a sponsor](https://img.shields.io/badge/sponsor-crazy--max-181717.svg?logo=github&style=flat-square)](https://github.com/sponsors/crazy-max) [![Paypal Donate](https://img.shields.io/badge/donate-paypal-00457c.svg?logo=paypal&style=flat-square)](https://www.paypal.me/crazyws) diff --git a/dist/index.js b/dist/index.js index 6d3ab3e..8301192 100644 --- a/dist/index.js +++ b/dist/index.js @@ -985,7 +985,7 @@ exports.IsPost = !!process.env['STATE_isPost']; if (!exports.IsPost) { coreCommand.issueCommand('save-state', { name: 'isPost' }, 'true'); } - +//# sourceMappingURL=state-helper.js.map /***/ }), @@ -1114,7 +1114,7 @@ if (!stateHelper.IsPost) { else { cleanup(); } - +//# sourceMappingURL=main.js.map /***/ }), @@ -1245,9 +1245,7 @@ exports.importKey = (armoredText) => __awaiter(void 0, void 0, void 0, function* }); }); exports.getKeygrip = (fingerprint) => __awaiter(void 0, void 0, void 0, function* () { - return yield exec - .exec('gpg', ['--batch', '--with-colons', '--with-keygrip', '--list-secret-keys', fingerprint], true) - .then(res => { + return yield exec.exec('gpg', ['--batch', '--with-colons', '--with-keygrip', '--list-secret-keys', fingerprint], true).then(res => { if (res.stderr != '' && !res.success) { throw new Error(res.stderr); } @@ -1289,7 +1287,7 @@ exports.deleteKey = (fingerprint) => __awaiter(void 0, void 0, void 0, function* exports.killAgent = () => __awaiter(void 0, void 0, void 0, function* () { yield gpgConnectAgent('KILLAGENT'); }); - +//# sourceMappingURL=gpg.js.map /***/ }), @@ -1442,7 +1440,7 @@ function setConfig(key, value) { }); } exports.setConfig = setConfig; - +//# sourceMappingURL=git.js.map /***/ }), @@ -45691,7 +45689,7 @@ exports.generateKeyPair = (name, email, passphrase, numBits = 4096) => __awaiter privateKey: keyPair.privateKeyArmored.replace(/\r\n/g, '\n').trim() }; }); - +//# sourceMappingURL=openpgp.js.map /***/ }), @@ -45740,7 +45738,7 @@ exports.exec = (command, args = [], silent) => __awaiter(void 0, void 0, void 0, stderr: stderr.trim() }; }); - +//# sourceMappingURL=exec.js.map /***/ }), diff --git a/src/gpg.ts b/src/gpg.ts index 77d2fe0..68a4f62 100644 --- a/src/gpg.ts +++ b/src/gpg.ts @@ -124,21 +124,19 @@ export const importKey = async (armoredText: string): Promise => { }; export const getKeygrip = async (fingerprint: string): Promise => { - return await exec - .exec('gpg', ['--batch', '--with-colons', '--with-keygrip', '--list-secret-keys', fingerprint], true) - .then(res => { - if (res.stderr != '' && !res.success) { - throw new Error(res.stderr); + return await exec.exec('gpg', ['--batch', '--with-colons', '--with-keygrip', '--list-secret-keys', fingerprint], true).then(res => { + if (res.stderr != '' && !res.success) { + throw new Error(res.stderr); + } + let keygrip: string = ''; + for (let line of res.stdout.replace(/\r/g, '').trim().split(/\n/g)) { + if (line.startsWith('grp')) { + keygrip = line.replace(/(grp|:)/g, '').trim(); + break; } - let keygrip: string = ''; - for (let line of res.stdout.replace(/\r/g, '').trim().split(/\n/g)) { - if (line.startsWith('grp')) { - keygrip = line.replace(/(grp|:)/g, '').trim(); - break; - } - } - return keygrip; - }); + } + return keygrip; + }); }; export const configureAgent = async (config: string): Promise => { diff --git a/src/main.ts b/src/main.ts index e7700a4..d0e7445 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,10 +15,8 @@ async function run(): Promise { const git_commit_gpgsign = /true/i.test(core.getInput('git_commit_gpgsign')); const git_tag_gpgsign = /true/i.test(core.getInput('git_tag_gpgsign')); const git_push_gpgsign = /true/i.test(core.getInput('git_push_gpgsign')); - const git_committer_name: string = - core.getInput('git_committer_name') || process.env['GITHUB_ACTOR'] || 'github-actions'; - const git_committer_email: string = - core.getInput('git_committer_email') || `${git_committer_name}@users.noreply.github.com`; + const git_committer_name: string = core.getInput('git_committer_name') || process.env['GITHUB_ACTOR'] || 'github-actions'; + const git_committer_email: string = core.getInput('git_committer_email') || `${git_committer_name}@users.noreply.github.com`; core.info('📣 GnuPG info'); const version = await gpg.getVersion(); diff --git a/src/openpgp.ts b/src/openpgp.ts index 2ab3bda..bb6aa45 100644 --- a/src/openpgp.ts +++ b/src/openpgp.ts @@ -39,12 +39,7 @@ export const readPrivateKey = async (armoredText: string): Promise = }; }; -export const generateKeyPair = async ( - name: string, - email: string, - passphrase: string, - numBits: number = 4096 -): Promise => { +export const generateKeyPair = async (name: string, email: string, passphrase: string, numBits: number = 4096): Promise => { const keyPair = await openpgp.generateKey({ userIds: [{name: name, email: email}], numBits, diff --git a/tsconfig.json b/tsconfig.json index a8685de..81f09f6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,8 @@ "rootDir": "./src", "strict": true, "noImplicitAny": false, - "esModuleInterop": true + "esModuleInterop": true, + "sourceMap": true }, "exclude": ["node_modules", "**/*.test.ts"] }