Compare commits

..

1 Commits

Author SHA1 Message Date
Tom Hu
07b62770b8 Create README.md 2021-07-23 09:51:05 -07:00
12 changed files with 151 additions and 7936 deletions

View File

@@ -1,23 +1,3 @@
## 2.0.3
### Fixes
- #464 Fix wrong link in the readme
- #485 fix: Add override OS and linux default to platform
### Dependencies
- #447 build(deps): bump openpgp from 5.0.0-4 to 5.0.0-5
- #458 build(deps-dev): bump eslint from 7.31.0 to 7.32.0
- #465 build(deps-dev): bump @typescript-eslint/eslint-plugin from 4.28.4 to 4.29.1
- #466 build(deps-dev): bump @typescript-eslint/parser from 4.28.4 to 4.29.1
- #468 build(deps-dev): bump @types/jest from 26.0.24 to 27.0.0
- #470 build(deps-dev): bump @types/node from 16.4.0 to 16.6.0
- #472 build(deps): bump path-parse from 1.0.6 to 1.0.7
- #473 build(deps-dev): bump @types/jest from 27.0.0 to 27.0.1
- #478 build(deps-dev): bump @typescript-eslint/parser from 4.29.1 to 4.29.2
- #479 build(deps-dev): bump @typescript-eslint/eslint-plugin from 4.29.1 to 4.29.2
- #481 build(deps-dev): bump @types/node from 16.6.0 to 16.6.2
- #483 build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.29.2
- #484 build(deps): bump @actions/core from 1.4.0 to 1.5.0
## 2.0.2 ## 2.0.2
### Fixes ### Fixes
- Underlying uploader fixes issues with tokens not being sent properly for users seeing - Underlying uploader fixes issues with tokens not being sent properly for users seeing

View File

@@ -10,7 +10,7 @@
## ⚠️ Deprecration of v1 ## ⚠️ Deprecration of v1
**On February 1, 2022, this version will be fully sunset and no longer function** **On February 1, 2022, this version will be fully sunset and no longer function**
Due to the [deprecation](https://about.codecov.io/blog/introducing-codecovs-new-uploader/) of the underlying bash uploader, Due to the [deprecation](https://about.codecov.io/blog/introducting-codecovs-new-uploader/) of the underlying bash uploader,
the Codecov GitHub Action has released `v2` which will use the new [uploader](https://github.com/codecov/uploader). You can learn the Codecov GitHub Action has released `v2` which will use the new [uploader](https://github.com/codecov/uploader). You can learn
more about our deprecation plan and the new uploader on our [blog](https://about.codecov.io/blog/introducing-codecovs-new-uploader/). more about our deprecation plan and the new uploader on our [blog](https://about.codecov.io/blog/introducing-codecovs-new-uploader/).

View File

@@ -53,9 +53,6 @@ inputs:
override_tag: override_tag:
description: 'Specify the git tag' description: 'Specify the git tag'
required: false required: false
os:
description: 'Override the assumed OS. Options are alpine | linux | macos | windows.'
required: false
root_dir: root_dir:
description: 'Used when not in git/hg project to identify project root directory' description: 'Used when not in git/hg project to identify project root directory'
required: false required: false

63
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

7848
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "codecov-action", "name": "codecov-action",
"version": "2.0.3", "version": "2.0.2",
"description": "Upload coverage reports to Codecov from GitHub Actions", "description": "Upload coverage reports to Codecov from GitHub Actions",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@@ -23,19 +23,19 @@
}, },
"homepage": "https://github.com/codecov/codecov-action#readme", "homepage": "https://github.com/codecov/codecov-action#readme",
"dependencies": { "dependencies": {
"@actions/core": "^1.5.0", "@actions/core": "^1.4.0",
"@actions/exec": "^1.1.0", "@actions/exec": "^1.1.0",
"@actions/github": "^5.0.0", "@actions/github": "^5.0.0",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
"openpgp": "^5.0.0-5" "openpgp": "^5.0.0-4"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^27.0.1", "@types/jest": "^26.0.24",
"@types/node": "^16.6.2", "@types/node": "^16.4.0",
"@typescript-eslint/eslint-plugin": "^4.29.2", "@typescript-eslint/eslint-plugin": "^4.28.4",
"@typescript-eslint/parser": "^4.29.2", "@typescript-eslint/parser": "^4.28.4",
"@vercel/ncc": "^0.29.2", "@vercel/ncc": "^0.29.0",
"eslint": "^7.32.0", "eslint": "^7.31.0",
"eslint-config-google": "^0.14.0", "eslint-config-google": "^0.14.0",
"jest": "^26.6.3", "jest": "^26.6.3",
"jest-junit": "^12.2.0", "jest-junit": "^12.2.0",

View File

@@ -27,7 +27,6 @@ const buildExec = () => {
const flags = core.getInput('flags'); const flags = core.getInput('flags');
const functionalities = core.getInput('functionalities'); const functionalities = core.getInput('functionalities');
const name = core.getInput('name'); const name = core.getInput('name');
const os = core.getInput('os');
const overrideBranch = core.getInput('override_branch'); const overrideBranch = core.getInput('override_branch');
const overrideBuild = core.getInput('override_build'); const overrideBuild = core.getInput('override_build');
const overrideCommit = core.getInput('override_commit'); const overrideCommit = core.getInput('override_commit');
@@ -147,7 +146,7 @@ const buildExec = () => {
options.cwd = workingDir; options.cwd = workingDir;
} }
return {execArgs, options, failCi, os}; return {execArgs, options, failCi};
}; };
export default buildExec; export default buildExec;

View File

@@ -1,61 +0,0 @@
import {
getBaseUrl,
getPlatform,
isValidPlatform,
isWindows,
PLATFORMS,
} from './helpers';
let OLDOS = process.env.RUNNER_OS;
beforeEach(() => {
jest.resetModules();
OLDOS = process.env.RUNNER_OS;
});
afterAll(() => {
process.env.RUNNER_OS = OLDOS;
});
test('getPlatform', () => {
expect(getPlatform('linux')).toBe('linux');
expect(getPlatform('windows')).toBe('windows');
const defaultPlatform =
process.env.RUNNER_OS ? process.env.RUNNER_OS.toLowerCase() : 'linux';
expect(getPlatform('fakeos')).toBe(defaultPlatform);
expect(getPlatform()).toBe(defaultPlatform);
process.env.RUNNER_OS = 'macos';
expect(getPlatform('fakeos')).toBe('macos');
expect(getPlatform()).toBe('macos');
process.env.RUNNER_OS = 'alsofakeos';
expect(getPlatform()).toBe('linux');
expect(getPlatform('fakeos')).toBe('linux');
});
test('getBaseUrl', () => {
expect(PLATFORMS.map((platform) => {
return getBaseUrl(platform);
})).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',
]);
});
test('isWindows', () => {
expect(PLATFORMS.map((platform) => {
return isWindows(platform);
})).toEqual([false, false, false, true]);
});
test('isValidPlatform', () => {
expect(PLATFORMS.map((platform) => {
return isValidPlatform(platform);
})).toEqual([true, true, true, true]);
expect(isValidPlatform('fakeos')).toBeFalsy();
});

View File

@@ -9,47 +9,30 @@ const setFailure = (message: string, failCi: boolean): void => {
} }
}; };
const getUploaderName = (platform: string): string => { const getUploaderName = (): string => {
if (isWindows(platform)) { if (isWindows()) {
return 'codecov.exe'; return 'codecov.exe';
} else { } else {
return 'codecov'; return 'codecov';
} }
}; };
const isValidPlatform = (platform: string): boolean => { const isValidPlatform = (): boolean => {
return PLATFORMS.includes(platform); return PLATFORMS.includes(getPlatform());
}; };
const isWindows = (platform: string): boolean => { const isWindows = (): boolean => {
return platform === 'windows'; return getPlatform() === 'windows';
}; };
const getPlatform = (os?: string): string => { const getPlatform = (): string => {
if (isValidPlatform(os)) { return process.env.RUNNER_OS.toLowerCase();
core.info(`==> ${os} OS provided`);
return os;
}
const platform = process.env.RUNNER_OS?.toLowerCase();
if (isValidPlatform(platform)) {
core.info(`==> ${platform} OS detected`);
return platform;
}
core.info(
'==> Could not detect OS or provided OS is invalid. Defaulting to linux',
);
return 'linux';
}; };
const getBaseUrl = (platform: string): string => { const BASEURL = `https://uploader.codecov.io/latest/${getPlatform()}/${getUploaderName()}`;
return `https://uploader.codecov.io/latest/${platform}/${getUploaderName(platform)}`;
};
export { export {
PLATFORMS, BASEURL,
getBaseUrl,
getPlatform, getPlatform,
getUploaderName, getUploaderName,
isValidPlatform, isValidPlatform,

View File

@@ -6,9 +6,10 @@ import * as exec from '@actions/exec';
import buildExec from './buildExec'; import buildExec from './buildExec';
import { import {
getBaseUrl, BASEURL,
getPlatform, getPlatform,
getUploaderName, getUploaderName,
isValidPlatform,
setFailure, setFailure,
} from './helpers'; } from './helpers';
@@ -17,11 +18,16 @@ import verify from './validate';
let failCi; let failCi;
try { try {
const {execArgs, options, failCi, os} = buildExec(); const {execArgs, options, failCi} = buildExec();
const platform = getPlatform(os); const platform = getPlatform();
if (!isValidPlatform()) {
const filename = path.join( __dirname, getUploaderName(platform)); setFailure(
https.get(getBaseUrl(platform), (res) => { `Codecov: Encountered an unexpected platform: ${platform}`,
failCi,
);
}
const filename = path.join( __dirname, getUploaderName());
https.get(BASEURL, (res) => {
// Image will be stored at this path // Image will be stored at this path
const filePath = fs.createWriteStream(filename); const filePath = fs.createWriteStream(filename);
res.pipe(filePath); res.pipe(filePath);
@@ -34,7 +40,7 @@ try {
}).on('finish', async () => { }).on('finish', async () => {
filePath.close(); filePath.close();
await verify(filename, platform); await verify(filename);
await fs.chmodSync(filename, '777'); await fs.chmodSync(filename, '777');
const unlink = () => { const unlink = () => {

View File

@@ -7,14 +7,14 @@ import * as openpgp from 'openpgp';
import * as fetch from 'node-fetch'; import * as fetch from 'node-fetch';
import { import {
getBaseUrl, BASEURL,
getUploaderName, getUploaderName,
setFailure, setFailure,
} from './helpers'; } from './helpers';
const verify = async (filename: string, platform: string) => { const verify = async (filename: string) => {
try { try {
const uploaderName = getUploaderName(platform); const uploaderName = getUploaderName();
// Read in public key // Read in public key
const publicKeyArmored = await fs.readFileSync( const publicKeyArmored = await fs.readFileSync(
@@ -23,10 +23,10 @@ const verify = async (filename: string, platform: string) => {
); );
// Get SHASUM and SHASUM signature files // Get SHASUM and SHASUM signature files
const shasumRes = await fetch( `${getBaseUrl(platform)}.SHA256SUM`); const shasumRes = await fetch( `${BASEURL}.SHA256SUM`);
const shasum = await shasumRes.text(); const shasum = await shasumRes.text();
const shaSigRes = await fetch( `${getBaseUrl(platform)}.SHA256SUM.sig`); const shaSigRes = await fetch( `${BASEURL}.SHA256SUM.sig`);
const shaSig = await shaSigRes.text(); const shaSig = await shaSigRes.text();
// Verify shasum // Verify shasum