mirror of
https://github.com/codecov/codecov-action.git
synced 2026-02-13 14:37:24 +00:00
Merge pull request #485 from codecov/alternate-os
fix: Add override OS and linux default to platform
This commit is contained in:
commit
5a8bb4701e
11 changed files with 7782 additions and 63 deletions
20
CHANGELOG.md
20
CHANGELOG.md
|
|
@ -1,3 +1,23 @@
|
||||||
|
## 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
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,9 @@ 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
63
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
7624
package-lock.json
generated
7624
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "codecov-action",
|
"name": "codecov-action",
|
||||||
"version": "2.0.2",
|
"version": "2.0.3",
|
||||||
"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": {
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ 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');
|
||||||
|
|
@ -146,7 +147,7 @@ const buildExec = () => {
|
||||||
options.cwd = workingDir;
|
options.cwd = workingDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {execArgs, options, failCi};
|
return {execArgs, options, failCi, os};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default buildExec;
|
export default buildExec;
|
||||||
|
|
|
||||||
61
src/helpers.test.ts
Normal file
61
src/helpers.test.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
|
@ -9,30 +9,47 @@ const setFailure = (message: string, failCi: boolean): void => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUploaderName = (): string => {
|
const getUploaderName = (platform: string): string => {
|
||||||
if (isWindows()) {
|
if (isWindows(platform)) {
|
||||||
return 'codecov.exe';
|
return 'codecov.exe';
|
||||||
} else {
|
} else {
|
||||||
return 'codecov';
|
return 'codecov';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isValidPlatform = (): boolean => {
|
const isValidPlatform = (platform: string): boolean => {
|
||||||
return PLATFORMS.includes(getPlatform());
|
return PLATFORMS.includes(platform);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isWindows = (): boolean => {
|
const isWindows = (platform: string): boolean => {
|
||||||
return getPlatform() === 'windows';
|
return platform === 'windows';
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPlatform = (): string => {
|
const getPlatform = (os?: string): string => {
|
||||||
return process.env.RUNNER_OS.toLowerCase();
|
if (isValidPlatform(os)) {
|
||||||
|
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 BASEURL = `https://uploader.codecov.io/latest/${getPlatform()}/${getUploaderName()}`;
|
const getBaseUrl = (platform: string): string => {
|
||||||
|
return `https://uploader.codecov.io/latest/${platform}/${getUploaderName(platform)}`;
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
BASEURL,
|
PLATFORMS,
|
||||||
|
getBaseUrl,
|
||||||
getPlatform,
|
getPlatform,
|
||||||
getUploaderName,
|
getUploaderName,
|
||||||
isValidPlatform,
|
isValidPlatform,
|
||||||
|
|
|
||||||
20
src/index.ts
20
src/index.ts
|
|
@ -6,10 +6,9 @@ import * as exec from '@actions/exec';
|
||||||
|
|
||||||
import buildExec from './buildExec';
|
import buildExec from './buildExec';
|
||||||
import {
|
import {
|
||||||
BASEURL,
|
getBaseUrl,
|
||||||
getPlatform,
|
getPlatform,
|
||||||
getUploaderName,
|
getUploaderName,
|
||||||
isValidPlatform,
|
|
||||||
setFailure,
|
setFailure,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
|
|
@ -18,16 +17,11 @@ import verify from './validate';
|
||||||
let failCi;
|
let failCi;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {execArgs, options, failCi} = buildExec();
|
const {execArgs, options, failCi, os} = buildExec();
|
||||||
const platform = getPlatform();
|
const platform = getPlatform(os);
|
||||||
if (!isValidPlatform()) {
|
|
||||||
setFailure(
|
const filename = path.join( __dirname, getUploaderName(platform));
|
||||||
`Codecov: Encountered an unexpected platform: ${platform}`,
|
https.get(getBaseUrl(platform), (res) => {
|
||||||
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);
|
||||||
|
|
@ -40,7 +34,7 @@ try {
|
||||||
}).on('finish', async () => {
|
}).on('finish', async () => {
|
||||||
filePath.close();
|
filePath.close();
|
||||||
|
|
||||||
await verify(filename);
|
await verify(filename, platform);
|
||||||
await fs.chmodSync(filename, '777');
|
await fs.chmodSync(filename, '777');
|
||||||
|
|
||||||
const unlink = () => {
|
const unlink = () => {
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,14 @@ import * as openpgp from 'openpgp';
|
||||||
import * as fetch from 'node-fetch';
|
import * as fetch from 'node-fetch';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BASEURL,
|
getBaseUrl,
|
||||||
getUploaderName,
|
getUploaderName,
|
||||||
setFailure,
|
setFailure,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
const verify = async (filename: string) => {
|
const verify = async (filename: string, platform: string) => {
|
||||||
try {
|
try {
|
||||||
const uploaderName = getUploaderName();
|
const uploaderName = getUploaderName(platform);
|
||||||
|
|
||||||
// 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) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Get SHASUM and SHASUM signature files
|
// Get SHASUM and SHASUM signature files
|
||||||
const shasumRes = await fetch( `${BASEURL}.SHA256SUM`);
|
const shasumRes = await fetch( `${getBaseUrl(platform)}.SHA256SUM`);
|
||||||
const shasum = await shasumRes.text();
|
const shasum = await shasumRes.text();
|
||||||
|
|
||||||
const shaSigRes = await fetch( `${BASEURL}.SHA256SUM.sig`);
|
const shaSigRes = await fetch( `${getBaseUrl(platform)}.SHA256SUM.sig`);
|
||||||
const shaSig = await shaSigRes.text();
|
const shaSig = await shaSigRes.text();
|
||||||
|
|
||||||
// Verify shasum
|
// Verify shasum
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue