Skip to content

Commit f32b3a3

Browse files
Merge pull request #515 from codecov/specify-version
Allow specifying version of Codecov uploader
2 parents 46edaed + 72dfd47 commit f32b3a3

14 files changed

+170
-35
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ jobs:
2222
file: ./coverage/coverage-final.json
2323
flags: demo,${{ matrix.os }}
2424
name: codecov-demo
25+
- name: Upload coverage to Codecov (version)
26+
uses: ./
27+
with:
28+
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
29+
file: ./coverage/coverage-final.json
30+
flags: version,${{ matrix.os }}
31+
name: codecov-version
32+
version: v0.1.0_8880
2533
run:
2634
runs-on: ${{ matrix.os }}
2735
strategy:
@@ -49,3 +57,11 @@ jobs:
4957
file: ./coverage/coverage-final.json
5058
flags: demo,${{ matrix.os }}
5159
name: codecov-demo
60+
- name: Upload coverage to Codecov (version)
61+
uses: ./
62+
with:
63+
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
64+
file: ./coverage/coverage-final.json
65+
flags: version,${{ matrix.os }}
66+
name: codecov-version
67+
version: v0.1.0_8880

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 2.1.0
2+
### Features
3+
- #515 Allow specifying version of Codecov uploader
4+
5+
### Dependencies
6+
- #499 build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.30.0
7+
- #508 build(deps): bump openpgp from 5.0.0-5 to 5.0.0
8+
- #514 build(deps-dev): bump @types/node from 16.6.0 to 16.9.0
9+
110
## 2.0.3
211
### Fixes
312
- #464 Fix wrong link in the readme

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Codecov's Action currently supports five inputs from the user: `token`, `file`,
7373
| `slug` | Specify the slug manually (Enterprise use) | Optional
7474
| `url` | Change the upload host (Enterprise use) | Optional
7575
| `verbose` | Specify whether the Codecov output should be verbose | Optional
76+
| `version` | Specify which version of the Codecov Uploader should be used. Defaults to `latest` | Optional
7677
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
7778

7879
### Example `workflow.yml` with Codecov Action

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ inputs:
6868
verbose:
6969
description: 'Specify whether the Codecov output should be verbose'
7070
required: false
71+
version:
72+
description: 'Specify which version of the Codecov Uploader should be used. Defaults to `latest`'
73+
required: false
7174
working-directory:
7275
description: 'Directory in which to execute codecov.sh'
7376
required: false

dist/index.js

Lines changed: 86 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
134134
});
135135
};
136136
Object.defineProperty(exports, "__esModule", ({ value: true }));
137-
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;
137+
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;
138138
const command_1 = __nccwpck_require__(5241);
139139
const file_command_1 = __nccwpck_require__(717);
140140
const utils_1 = __nccwpck_require__(5278);
@@ -312,19 +312,30 @@ exports.debug = debug;
312312
/**
313313
* Adds an error issue
314314
* @param message error issue message. Errors will be converted to string via toString()
315+
* @param properties optional properties to add to the annotation.
315316
*/
316-
function error(message) {
317-
command_1.issue('error', message instanceof Error ? message.toString() : message);
317+
function error(message, properties = {}) {
318+
command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
318319
}
319320
exports.error = error;
320321
/**
321-
* Adds an warning issue
322+
* Adds a warning issue
322323
* @param message warning issue message. Errors will be converted to string via toString()
324+
* @param properties optional properties to add to the annotation.
323325
*/
324-
function warning(message) {
325-
command_1.issue('warning', message instanceof Error ? message.toString() : message);
326+
function warning(message, properties = {}) {
327+
command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
326328
}
327329
exports.warning = warning;
330+
/**
331+
* Adds a notice issue
332+
* @param message notice issue message. Errors will be converted to string via toString()
333+
* @param properties optional properties to add to the annotation.
334+
*/
335+
function notice(message, properties = {}) {
336+
command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
337+
}
338+
exports.notice = notice;
328339
/**
329340
* Writes info to log with console.log.
330341
* @param message info message
@@ -458,7 +469,7 @@ exports.issueCommand = issueCommand;
458469
// We use any as a valid input type
459470
/* eslint-disable @typescript-eslint/no-explicit-any */
460471
Object.defineProperty(exports, "__esModule", ({ value: true }));
461-
exports.toCommandValue = void 0;
472+
exports.toCommandProperties = exports.toCommandValue = void 0;
462473
/**
463474
* Sanitizes an input into a string so it can be passed into issueCommand safely
464475
* @param input input to sanitize into a string
@@ -473,6 +484,25 @@ function toCommandValue(input) {
473484
return JSON.stringify(input);
474485
}
475486
exports.toCommandValue = toCommandValue;
487+
/**
488+
*
489+
* @param annotationProperties
490+
* @returns The command properties to send with the actual annotation command
491+
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
492+
*/
493+
function toCommandProperties(annotationProperties) {
494+
if (!Object.keys(annotationProperties).length) {
495+
return {};
496+
}
497+
return {
498+
title: annotationProperties.title,
499+
line: annotationProperties.startLine,
500+
endLine: annotationProperties.endLine,
501+
col: annotationProperties.startColumn,
502+
endColumn: annotationProperties.endColumn
503+
};
504+
}
505+
exports.toCommandProperties = toCommandProperties;
476506
//# sourceMappingURL=utils.js.map
477507

478508
/***/ }),
@@ -12829,7 +12859,7 @@ function wrappy (fn, cb) {
1282912859

1283012860
/***/ }),
1283112861

12832-
/***/ 3997:
12862+
/***/ 5765:
1283312863
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
1283412864

1283512865
"use strict";
@@ -12849,7 +12879,7 @@ var core = __nccwpck_require__(2186);
1284912879
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
1285012880
var github = __nccwpck_require__(5438);
1285112881
;// CONCATENATED MODULE: ./package.json
12852-
const package_namespaceObject = {"i8":"2.0.3"};
12882+
const package_namespaceObject = {"i8":"2.1.0"};
1285312883
;// CONCATENATED MODULE: ./src/buildExec.ts
1285412884

1285512885

@@ -12884,8 +12914,9 @@ const buildExec = () => {
1288412914
const searchDir = core.getInput('directory');
1288512915
const slug = core.getInput('slug');
1288612916
const token = core.getInput('token');
12887-
const verbose = isTrue(core.getInput('verbose'));
12917+
let uploaderVersion = core.getInput('version');
1288812918
const url = core.getInput('url');
12919+
const verbose = isTrue(core.getInput('verbose'));
1288912920
const workingDir = core.getInput('working-directory');
1289012921
const execArgs = [];
1289112922
execArgs.push('-n', `${name}`, '-Q', `github-action-${package_namespaceObject.i8}`);
@@ -12982,7 +13013,10 @@ const buildExec = () => {
1298213013
if (workingDir) {
1298313014
options.cwd = workingDir;
1298413015
}
12985-
return { execArgs, options, failCi, os };
13016+
if (uploaderVersion == '') {
13017+
uploaderVersion = 'latest';
13018+
}
13019+
return { execArgs, options, failCi, os, uploaderVersion };
1298613020
};
1298713021
/* harmony default export */ const src_buildExec = (buildExec);
1298813022

@@ -13023,8 +13057,8 @@ const getPlatform = (os) => {
1302313057
core.info('==> Could not detect OS or provided OS is invalid. Defaulting to linux');
1302413058
return 'linux';
1302513059
};
13026-
const getBaseUrl = (platform) => {
13027-
return `https://uploader.codecov.io/latest/${platform}/${getUploaderName(platform)}`;
13060+
const getBaseUrl = (platform, version) => {
13061+
return `https://uploader.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
1302813062
};
1302913063

1303013064

@@ -13051,15 +13085,16 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
1305113085

1305213086

1305313087

13054-
const verify = (filename, platform) => __awaiter(void 0, void 0, void 0, function* () {
13088+
const verify = (filename, platform, version) => __awaiter(void 0, void 0, void 0, function* () {
1305513089
try {
1305613090
const uploaderName = getUploaderName(platform);
1305713091
// Read in public key
1305813092
const publicKeyArmored = yield external_fs_.readFileSync(__nccwpck_require__.ab + "pgp_keys.asc", 'utf-8');
1305913093
// Get SHASUM and SHASUM signature files
13060-
const shasumRes = yield lib(`${getBaseUrl(platform)}.SHA256SUM`);
13094+
console.log(`${getBaseUrl(platform, version)}.SHA256SUM`);
13095+
const shasumRes = yield lib(`${getBaseUrl(platform, version)}.SHA256SUM`);
1306113096
const shasum = yield shasumRes.text();
13062-
const shaSigRes = yield lib(`${getBaseUrl(platform)}.SHA256SUM.sig`);
13097+
const shaSigRes = yield lib(`${getBaseUrl(platform, version)}.SHA256SUM.sig`);
1306313098
const shaSig = yield shaSigRes.text();
1306413099
// Verify shasum
1306513100
const verified = yield openpgp_min/* verify */.T({
@@ -13099,6 +13134,35 @@ const verify = (filename, platform) => __awaiter(void 0, void 0, void 0, functio
1309913134
});
1310013135
/* harmony default export */ const validate = (verify);
1310113136

13137+
;// CONCATENATED MODULE: ./src/version.ts
13138+
var version_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
13139+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13140+
return new (P || (P = Promise))(function (resolve, reject) {
13141+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13142+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13143+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13144+
step((generator = generator.apply(thisArg, _arguments || [])).next());
13145+
});
13146+
};
13147+
13148+
13149+
const versionInfo = (platform, version) => version_awaiter(void 0, void 0, void 0, function* () {
13150+
if (version) {
13151+
core.info(`==> Running version ${version}`);
13152+
}
13153+
try {
13154+
const metadataRes = yield lib(`https://uploader.codecov.io/${platform}/latest`, {
13155+
headers: { 'Accept': 'application/json' },
13156+
});
13157+
const metadata = yield metadataRes.json();
13158+
core.info(`==> Running version ${metadata['version']}`);
13159+
}
13160+
catch (err) {
13161+
core.info(`Could not pull latest version information: ${err}`);
13162+
}
13163+
});
13164+
/* harmony default export */ const version = (versionInfo);
13165+
1310213166
;// CONCATENATED MODULE: ./src/index.ts
1310313167
var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
1310413168
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
1311613180

1311713181

1311813182

13183+
1311913184
let failCi;
1312013185
try {
13121-
const { execArgs, options, failCi, os } = src_buildExec();
13186+
const { execArgs, options, failCi, os, uploaderVersion } = src_buildExec();
1312213187
const platform = getPlatform(os);
1312313188
const filename = external_path_.join(__dirname, getUploaderName(platform));
13124-
external_https_.get(getBaseUrl(platform), (res) => {
13189+
external_https_.get(getBaseUrl(platform, uploaderVersion), (res) => {
1312513190
// Image will be stored at this path
1312613191
const filePath = external_fs_.createWriteStream(filename);
1312713192
res.pipe(filePath);
@@ -13130,7 +13195,8 @@ try {
1313013195
setFailure(`Codecov: Failed to write uploader binary: ${err.message}`, true);
1313113196
}).on('finish', () => src_awaiter(void 0, void 0, void 0, function* () {
1313213197
filePath.close();
13133-
yield validate(filename, platform);
13198+
yield validate(filename, platform, uploaderVersion);
13199+
yield version(platform, uploaderVersion);
1313413200
yield external_fs_.chmodSync(filename, '777');
1313513201
const unlink = () => {
1313613202
external_fs_.unlink(filename, (err) => {
@@ -13372,7 +13438,7 @@ module.exports = require("zlib");
1337213438
/******/ // startup
1337313439
/******/ // Load entry module and return exports
1337413440
/******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined
13375-
/******/ var __webpack_exports__ = __nccwpck_require__(3997);
13441+
/******/ var __webpack_exports__ = __nccwpck_require__(5765);
1337613442
/******/ module.exports = __webpack_exports__;
1337713443
/******/
1337813444
/******/ })()

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codecov-action",
3-
"version": "2.0.3",
3+
"version": "2.1.0",
44
"description": "Upload coverage reports to Codecov from GitHub Actions",
55
"main": "index.js",
66
"scripts": {

src/buildExec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ const buildExec = () => {
3737
const searchDir = core.getInput('directory');
3838
const slug = core.getInput('slug');
3939
const token = core.getInput('token');
40-
const verbose = isTrue(core.getInput('verbose'));
40+
let uploaderVersion = core.getInput('version');
4141
const url = core.getInput('url');
42+
const verbose = isTrue(core.getInput('verbose'));
4243
const workingDir = core.getInput('working-directory');
4344

4445
const execArgs = [];
@@ -147,7 +148,11 @@ const buildExec = () => {
147148
options.cwd = workingDir;
148149
}
149150

150-
return {execArgs, options, failCi, os};
151+
if (uploaderVersion == '') {
152+
uploaderVersion = 'latest';
153+
}
154+
155+
return {execArgs, options, failCi, os, uploaderVersion};
151156
};
152157

153158
export default buildExec;

src/helpers.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,22 @@ test('getPlatform', () => {
3737

3838
test('getBaseUrl', () => {
3939
expect(PLATFORMS.map((platform) => {
40-
return getBaseUrl(platform);
40+
return getBaseUrl(platform, 'latest');
4141
})).toEqual([
4242
'https://uploader.codecov.io/latest/alpine/codecov',
4343
'https://uploader.codecov.io/latest/linux/codecov',
4444
'https://uploader.codecov.io/latest/macos/codecov',
4545
'https://uploader.codecov.io/latest/windows/codecov.exe',
4646
]);
47+
48+
expect(PLATFORMS.map((platform) => {
49+
return getBaseUrl(platform, 'v0.1.0_8880');
50+
})).toEqual([
51+
'https://uploader.codecov.io/v0.1.0_8880/alpine/codecov',
52+
'https://uploader.codecov.io/v0.1.0_8880/linux/codecov',
53+
'https://uploader.codecov.io/v0.1.0_8880/macos/codecov',
54+
'https://uploader.codecov.io/v0.1.0_8880/windows/codecov.exe',
55+
]);
4756
});
4857

4958
test('isWindows', () => {

src/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const getPlatform = (os?: string): string => {
4343
return 'linux';
4444
};
4545

46-
const getBaseUrl = (platform: string): string => {
47-
return `https://uploader.codecov.io/latest/${platform}/${getUploaderName(platform)}`;
46+
const getBaseUrl = (platform: string, version: string): string => {
47+
return `https://uploader.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
4848
};
4949

5050
export {

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ import {
1313
} from './helpers';
1414

1515
import verify from './validate';
16+
import versionInfo from './version';
1617

1718
let failCi;
1819

1920
try {
20-
const {execArgs, options, failCi, os} = buildExec();
21+
const {execArgs, options, failCi, os, uploaderVersion} = buildExec();
2122
const platform = getPlatform(os);
2223

2324
const filename = path.join( __dirname, getUploaderName(platform));
24-
https.get(getBaseUrl(platform), (res) => {
25+
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
2526
// Image will be stored at this path
2627
const filePath = fs.createWriteStream(filename);
2728
res.pipe(filePath);
@@ -34,7 +35,8 @@ try {
3435
}).on('finish', async () => {
3536
filePath.close();
3637

37-
await verify(filename, platform);
38+
await verify(filename, platform, uploaderVersion);
39+
await versionInfo(platform, uploaderVersion);
3840
await fs.chmodSync(filename, '777');
3941

4042
const unlink = () => {

0 commit comments

Comments
 (0)