Skip to content

Commit

Permalink
Allow specifying version of Codecov uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrockhu-codecov committed Sep 9, 2021
1 parent 5a8bb47 commit 2df245e
Show file tree
Hide file tree
Showing 11 changed files with 425 additions and 424 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/main.yml
Expand Up @@ -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: 0.1.0_8880
run:
runs-on: ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -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-versio
version: 0.1.0_8880
2 changes: 2 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,5 @@
## 2.1.0

## 2.0.3
### Fixes
- #464 Fix wrong link in the readme
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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
Expand Down
94 changes: 79 additions & 15 deletions dist/index.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

/***/ }),
Expand Down Expand Up @@ -12829,7 +12859,7 @@ function wrappy (fn, cb) {

/***/ }),

/***/ 3997:
/***/ 5765:
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {

"use strict";
Expand All @@ -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


Expand Down Expand Up @@ -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'));
const 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}`);
Expand Down Expand Up @@ -12982,7 +13013,7 @@ const buildExec = () => {
if (workingDir) {
options.cwd = workingDir;
}
return { execArgs, options, failCi, os };
return { execArgs, options, failCi, os, uploaderVersion };
};
/* harmony default export */ const src_buildExec = (buildExec);

Expand Down Expand Up @@ -13023,7 +13054,10 @@ const getPlatform = (os) => {
core.info('==> Could not detect OS or provided OS is invalid. Defaulting to linux');
return 'linux';
};
const getBaseUrl = (platform) => {
const getBaseUrl = (platform, version) => {
if (version) {
return `https://uploader.codecov.io/${platform}/${version}/${getUploaderName(platform)}`;
}
return `https://uploader.codecov.io/latest/${platform}/${getUploaderName(platform)}`;
};

Expand Down Expand Up @@ -13099,6 +13133,32 @@ 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_awaiter(void 0, void 0, void 0, function* () {
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); }); }
Expand All @@ -13116,12 +13176,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);
Expand All @@ -13131,6 +13192,9 @@ try {
}).on('finish', () => src_awaiter(void 0, void 0, void 0, function* () {
filePath.close();
yield validate(filename, platform);
if (!uploaderVersion) {
yield version(platform);
}
yield external_fs_.chmodSync(filename, '777');
const unlink = () => {
external_fs_.unlink(filename, (err) => {
Expand Down Expand Up @@ -13372,7 +13436,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__;
/******/
/******/ })()
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit 2df245e

Please sign in to comment.