Compare commits

..

8 Commits

Author SHA1 Message Date
Tom Hu
f32b3a3741 Merge pull request #515 from codecov/specify-version
Allow specifying version of Codecov uploader
2021-09-13 08:58:22 -04:00
Tom Hu
72dfd4782e Allow specifying version of Codecov uploader 2021-09-09 14:53:12 -04:00
Tom Hu
46edaeda0c Merge pull request #499 from codecov/dependabot/npm_and_yarn/vercel/ncc-0.30.0
build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.30.0
2021-09-09 13:21:21 -04:00
Tom Hu
b6fd8cc98b Merge pull request #508 from codecov/dependabot/npm_and_yarn/openpgp-5.0.0
build(deps): bump openpgp from 5.0.0-5 to 5.0.0
2021-09-09 13:20:49 -04:00
dependabot[bot]
07a4e975bb build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.30.0
Bumps [@vercel/ncc](https://github.com/vercel/ncc) from 0.29.0 to 0.30.0.
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](https://github.com/vercel/ncc/compare/0.29.0...0.30.0)

---
updated-dependencies:
- dependency-name: "@vercel/ncc"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-09 17:17:40 +00:00
dependabot[bot]
c071c7087f build(deps): bump openpgp from 5.0.0-5 to 5.0.0
Bumps [openpgp](https://github.com/openpgpjs/openpgpjs) from 5.0.0-5 to 5.0.0.
- [Release notes](https://github.com/openpgpjs/openpgpjs/releases)
- [Commits](https://github.com/openpgpjs/openpgpjs/compare/v5.0.0-5...v5.0.0)

---
updated-dependencies:
- dependency-name: openpgp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-09 17:17:14 +00:00
Tom Hu
f6d4366a4c Merge pull request #514 from codecov/dependabot/npm_and_yarn/types/node-16.9.0
build(deps-dev): bump @types/node from 16.6.0 to 16.9.0
2021-09-09 13:16:10 -04:00
dependabot[bot]
2bbefc9105 build(deps-dev): bump @types/node from 16.6.0 to 16.9.0
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 16.6.0 to 16.9.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-09 04:03:24 +00:00
14 changed files with 478 additions and 448 deletions

View File

@@ -22,6 +22,14 @@ jobs:
file: ./coverage/coverage-final.json
flags: demo,${{ matrix.os }}
name: codecov-demo
- name: Upload coverage to Codecov (version)
uses: ./
with:
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
file: ./coverage/coverage-final.json
flags: version,${{ matrix.os }}
name: codecov-version
version: v0.1.0_8880
run:
runs-on: ${{ matrix.os }}
strategy:
@@ -49,3 +57,11 @@ jobs:
file: ./coverage/coverage-final.json
flags: demo,${{ matrix.os }}
name: codecov-demo
- name: Upload coverage to Codecov (version)
uses: ./
with:
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
file: ./coverage/coverage-final.json
flags: version,${{ matrix.os }}
name: codecov-version
version: v0.1.0_8880

View File

@@ -1,3 +1,12 @@
## 2.1.0
### Features
- #515 Allow specifying version of Codecov uploader
### Dependencies
- #499 build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.30.0
- #508 build(deps): bump openpgp from 5.0.0-5 to 5.0.0
- #514 build(deps-dev): bump @types/node from 16.6.0 to 16.9.0
## 2.0.3
### Fixes
- #464 Fix wrong link in the readme

View File

@@ -73,6 +73,7 @@ Codecov's Action currently supports five inputs from the user: `token`, `file`,
| `slug` | Specify the slug manually (Enterprise use) | Optional
| `url` | Change the upload host (Enterprise use) | Optional
| `verbose` | Specify whether the Codecov output should be verbose | Optional
| `version` | Specify which version of the Codecov Uploader should be used. Defaults to `latest` | Optional
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
### Example `workflow.yml` with Codecov Action

View File

@@ -68,6 +68,9 @@ inputs:
verbose:
description: 'Specify whether the Codecov output should be verbose'
required: false
version:
description: 'Specify which version of the Codecov Uploader should be used. Defaults to `latest`'
required: false
working-directory:
description: 'Directory in which to execute codecov.sh'
required: false

106
dist/index.js vendored
View File

@@ -134,7 +134,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
const command_1 = __nccwpck_require__(5241);
const file_command_1 = __nccwpck_require__(717);
const utils_1 = __nccwpck_require__(5278);
@@ -312,19 +312,30 @@ exports.debug = debug;
/**
* Adds an error issue
* @param message error issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function error(message) {
command_1.issue('error', message instanceof Error ? message.toString() : message);
function error(message, properties = {}) {
command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.error = error;
/**
* Adds an warning issue
* Adds a warning issue
* @param message warning issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function warning(message) {
command_1.issue('warning', message instanceof Error ? message.toString() : message);
function warning(message, properties = {}) {
command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.warning = warning;
/**
* Adds a notice issue
* @param message notice issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function notice(message, properties = {}) {
command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.notice = notice;
/**
* Writes info to log with console.log.
* @param message info message
@@ -458,7 +469,7 @@ exports.issueCommand = issueCommand;
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.toCommandValue = void 0;
exports.toCommandProperties = exports.toCommandValue = void 0;
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
@@ -473,6 +484,25 @@ function toCommandValue(input) {
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
/**
*
* @param annotationProperties
* @returns The command properties to send with the actual annotation command
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
*/
function toCommandProperties(annotationProperties) {
if (!Object.keys(annotationProperties).length) {
return {};
}
return {
title: annotationProperties.title,
line: annotationProperties.startLine,
endLine: annotationProperties.endLine,
col: annotationProperties.startColumn,
endColumn: annotationProperties.endColumn
};
}
exports.toCommandProperties = toCommandProperties;
//# sourceMappingURL=utils.js.map
/***/ }),
@@ -12829,7 +12859,7 @@ function wrappy (fn, cb) {
/***/ }),
/***/ 3997:
/***/ 5765:
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
"use strict";
@@ -12849,7 +12879,7 @@ var core = __nccwpck_require__(2186);
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
var github = __nccwpck_require__(5438);
;// CONCATENATED MODULE: ./package.json
const package_namespaceObject = {"i8":"2.0.3"};
const package_namespaceObject = {"i8":"2.1.0"};
;// CONCATENATED MODULE: ./src/buildExec.ts
@@ -12884,8 +12914,9 @@ const buildExec = () => {
const searchDir = core.getInput('directory');
const slug = core.getInput('slug');
const token = core.getInput('token');
const verbose = isTrue(core.getInput('verbose'));
let uploaderVersion = core.getInput('version');
const url = core.getInput('url');
const verbose = isTrue(core.getInput('verbose'));
const workingDir = core.getInput('working-directory');
const execArgs = [];
execArgs.push('-n', `${name}`, '-Q', `github-action-${package_namespaceObject.i8}`);
@@ -12982,7 +13013,10 @@ const buildExec = () => {
if (workingDir) {
options.cwd = workingDir;
}
return { execArgs, options, failCi, os };
if (uploaderVersion == '') {
uploaderVersion = 'latest';
}
return { execArgs, options, failCi, os, uploaderVersion };
};
/* harmony default export */ const src_buildExec = (buildExec);
@@ -13023,8 +13057,8 @@ const getPlatform = (os) => {
core.info('==> Could not detect OS or provided OS is invalid. Defaulting to linux');
return 'linux';
};
const getBaseUrl = (platform) => {
return `https://uploader.codecov.io/latest/${platform}/${getUploaderName(platform)}`;
const getBaseUrl = (platform, version) => {
return `https://uploader.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
};
@@ -13051,15 +13085,16 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
const verify = (filename, platform) => __awaiter(void 0, void 0, void 0, function* () {
const verify = (filename, platform, version) => __awaiter(void 0, void 0, void 0, function* () {
try {
const uploaderName = getUploaderName(platform);
// Read in public key
const publicKeyArmored = yield external_fs_.readFileSync(__nccwpck_require__.ab + "pgp_keys.asc", 'utf-8');
// Get SHASUM and SHASUM signature files
const shasumRes = yield lib(`${getBaseUrl(platform)}.SHA256SUM`);
console.log(`${getBaseUrl(platform, version)}.SHA256SUM`);
const shasumRes = yield lib(`${getBaseUrl(platform, version)}.SHA256SUM`);
const shasum = yield shasumRes.text();
const shaSigRes = yield lib(`${getBaseUrl(platform)}.SHA256SUM.sig`);
const shaSigRes = yield lib(`${getBaseUrl(platform, version)}.SHA256SUM.sig`);
const shaSig = yield shaSigRes.text();
// Verify shasum
const verified = yield openpgp_min/* verify */.T({
@@ -13099,6 +13134,35 @@ const verify = (filename, platform) => __awaiter(void 0, void 0, void 0, functio
});
/* harmony default export */ const validate = (verify);
;// CONCATENATED MODULE: ./src/version.ts
var version_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
const versionInfo = (platform, version) => version_awaiter(void 0, void 0, void 0, function* () {
if (version) {
core.info(`==> Running version ${version}`);
}
try {
const metadataRes = yield lib(`https://uploader.codecov.io/${platform}/latest`, {
headers: { 'Accept': 'application/json' },
});
const metadata = yield metadataRes.json();
core.info(`==> Running version ${metadata['version']}`);
}
catch (err) {
core.info(`Could not pull latest version information: ${err}`);
}
});
/* harmony default export */ const version = (versionInfo);
;// CONCATENATED MODULE: ./src/index.ts
var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -13116,12 +13180,13 @@ var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argu
let failCi;
try {
const { execArgs, options, failCi, os } = src_buildExec();
const { execArgs, options, failCi, os, uploaderVersion } = src_buildExec();
const platform = getPlatform(os);
const filename = external_path_.join(__dirname, getUploaderName(platform));
external_https_.get(getBaseUrl(platform), (res) => {
external_https_.get(getBaseUrl(platform, uploaderVersion), (res) => {
// Image will be stored at this path
const filePath = external_fs_.createWriteStream(filename);
res.pipe(filePath);
@@ -13130,7 +13195,8 @@ try {
setFailure(`Codecov: Failed to write uploader binary: ${err.message}`, true);
}).on('finish', () => src_awaiter(void 0, void 0, void 0, function* () {
filePath.close();
yield validate(filename, platform);
yield validate(filename, platform, uploaderVersion);
yield version(platform, uploaderVersion);
yield external_fs_.chmodSync(filename, '777');
const unlink = () => {
external_fs_.unlink(filename, (err) => {
@@ -13372,7 +13438,7 @@ module.exports = require("zlib");
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined
/******/ var __webpack_exports__ = __nccwpck_require__(3997);
/******/ var __webpack_exports__ = __nccwpck_require__(5765);
/******/ module.exports = __webpack_exports__;
/******/
/******/ })()

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

719
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "codecov-action",
"version": "2.0.3",
"version": "2.1.0",
"description": "Upload coverage reports to Codecov from GitHub Actions",
"main": "index.js",
"scripts": {
@@ -27,14 +27,14 @@
"@actions/exec": "^1.1.0",
"@actions/github": "^5.0.0",
"node-fetch": "^2.6.1",
"openpgp": "^5.0.0-5"
"openpgp": "^5.0.0"
},
"devDependencies": {
"@types/jest": "^27.0.1",
"@types/node": "^16.6.2",
"@types/node": "^16.9.0",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"@vercel/ncc": "^0.29.2",
"@vercel/ncc": "^0.30.0",
"eslint": "^7.32.0",
"eslint-config-google": "^0.14.0",
"jest": "^26.6.3",

View File

@@ -37,8 +37,9 @@ const buildExec = () => {
const searchDir = core.getInput('directory');
const slug = core.getInput('slug');
const token = core.getInput('token');
const verbose = isTrue(core.getInput('verbose'));
let uploaderVersion = core.getInput('version');
const url = core.getInput('url');
const verbose = isTrue(core.getInput('verbose'));
const workingDir = core.getInput('working-directory');
const execArgs = [];
@@ -147,7 +148,11 @@ const buildExec = () => {
options.cwd = workingDir;
}
return {execArgs, options, failCi, os};
if (uploaderVersion == '') {
uploaderVersion = 'latest';
}
return {execArgs, options, failCi, os, uploaderVersion};
};
export default buildExec;

View File

@@ -37,13 +37,22 @@ test('getPlatform', () => {
test('getBaseUrl', () => {
expect(PLATFORMS.map((platform) => {
return getBaseUrl(platform);
return getBaseUrl(platform, 'latest');
})).toEqual([
'https://uploader.codecov.io/latest/alpine/codecov',
'https://uploader.codecov.io/latest/linux/codecov',
'https://uploader.codecov.io/latest/macos/codecov',
'https://uploader.codecov.io/latest/windows/codecov.exe',
]);
expect(PLATFORMS.map((platform) => {
return getBaseUrl(platform, 'v0.1.0_8880');
})).toEqual([
'https://uploader.codecov.io/v0.1.0_8880/alpine/codecov',
'https://uploader.codecov.io/v0.1.0_8880/linux/codecov',
'https://uploader.codecov.io/v0.1.0_8880/macos/codecov',
'https://uploader.codecov.io/v0.1.0_8880/windows/codecov.exe',
]);
});
test('isWindows', () => {

View File

@@ -43,8 +43,8 @@ const getPlatform = (os?: string): string => {
return 'linux';
};
const getBaseUrl = (platform: string): string => {
return `https://uploader.codecov.io/latest/${platform}/${getUploaderName(platform)}`;
const getBaseUrl = (platform: string, version: string): string => {
return `https://uploader.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
};
export {

View File

@@ -13,15 +13,16 @@ import {
} from './helpers';
import verify from './validate';
import versionInfo from './version';
let failCi;
try {
const {execArgs, options, failCi, os} = buildExec();
const {execArgs, options, failCi, os, uploaderVersion} = buildExec();
const platform = getPlatform(os);
const filename = path.join( __dirname, getUploaderName(platform));
https.get(getBaseUrl(platform), (res) => {
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
// Image will be stored at this path
const filePath = fs.createWriteStream(filename);
res.pipe(filePath);
@@ -34,7 +35,8 @@ try {
}).on('finish', async () => {
filePath.close();
await verify(filename, platform);
await verify(filename, platform, uploaderVersion);
await versionInfo(platform, uploaderVersion);
await fs.chmodSync(filename, '777');
const unlink = () => {

View File

@@ -12,7 +12,7 @@ import {
setFailure,
} from './helpers';
const verify = async (filename: string, platform: string) => {
const verify = async (filename: string, platform: string, version: string) => {
try {
const uploaderName = getUploaderName(platform);
@@ -23,10 +23,15 @@ const verify = async (filename: string, platform: string) => {
);
// Get SHASUM and SHASUM signature files
const shasumRes = await fetch( `${getBaseUrl(platform)}.SHA256SUM`);
console.log(`${getBaseUrl(platform, version)}.SHA256SUM`);
const shasumRes = await fetch(
`${getBaseUrl(platform, version)}.SHA256SUM`,
);
const shasum = await shasumRes.text();
const shaSigRes = await fetch( `${getBaseUrl(platform)}.SHA256SUM.sig`);
const shaSigRes = await fetch(
`${getBaseUrl(platform, version)}.SHA256SUM.sig`,
);
const shaSig = await shaSigRes.text();
// Verify shasum

19
src/version.ts Normal file
View File

@@ -0,0 +1,19 @@
import * as core from '@actions/core';
import * as fetch from 'node-fetch';
const versionInfo = async (platform: string, version?: string) => {
if (version) {
core.info(`==> Running version ${version}`);
}
try {
const metadataRes = await fetch( `https://uploader.codecov.io/${platform}/latest`, {
headers: {'Accept': 'application/json'},
});
const metadata = await metadataRes.json();
core.info(`==> Running version ${metadata['version']}`);
} catch (err) {
core.info(`Could not pull latest version information: ${err}`);
}
};
export default versionInfo;