зеркало из https://github.com/Azure/BatchExplorer.git
Build results saved in full path.
Build pipeline configures the path, which is then used during testing to gather build results for codecov. Fixes AB#15017083
This commit is contained in:
Родитель
c60ed93883
Коммит
3b72192592
|
@ -1,6 +1,10 @@
|
|||
steps:
|
||||
- template: ./linux-dependencies.yml
|
||||
|
||||
- script: |
|
||||
butil configure --paths.batchExplorer=$(System.DefaultWorkingDirectory) --print
|
||||
displayName: Configure local paths
|
||||
|
||||
- script: npm run lint
|
||||
displayName: Lint
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
"build:prod": "lerna run workspace:build:prod --stream",
|
||||
"build:test": "lerna run workspace:build:test --stream",
|
||||
"clean": "lerna run --parallel workspace:clean --stream",
|
||||
"gather-build-results": "butil gather-build-results .",
|
||||
"gather-build-results": "butil gather-build-results",
|
||||
"launch": "npm run -s launch:web",
|
||||
"launch:desktop": "lerna run --parallel workspace:launch:desktop --stream",
|
||||
"launch:web": "lerna run --parallel workspace:launch:web --stream",
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import * as path from "path";
|
||||
import * as yargs from "yargs";
|
||||
import {
|
||||
batchExplorerHome,
|
||||
chmodx,
|
||||
configure,
|
||||
copyFiles,
|
||||
|
@ -23,8 +22,26 @@ yargs
|
|||
.command({
|
||||
command: "configure",
|
||||
aliases: ["config"],
|
||||
describe: "Configure CLI properties",
|
||||
handler: () => configure(),
|
||||
describe:
|
||||
"Configure CLI properties. If at least one configuration option " +
|
||||
"is specified, the configuration file is set or updated, without " +
|
||||
"a prompt",
|
||||
builder: (yargs: yargs.Argv) =>
|
||||
yargs
|
||||
.option("paths.batchExplorer", {
|
||||
type: "string",
|
||||
describe: "The path to Batch Explorer/Shared Libraries",
|
||||
})
|
||||
.option("paths.batchPortalExtension", {
|
||||
type: "string",
|
||||
describe: "The path to the Batch portal extension",
|
||||
})
|
||||
.option("print", {
|
||||
type: "boolean",
|
||||
describe: "Print the resultant configuration object",
|
||||
default: false,
|
||||
}),
|
||||
handler: (argv) => configure(argv),
|
||||
})
|
||||
.command({
|
||||
command: "cp <src> <dest>",
|
||||
|
@ -79,12 +96,12 @@ yargs
|
|||
handler: (argv) => rmrf(argv.directory),
|
||||
})
|
||||
.command({
|
||||
command: "gather-build-results <basePath>",
|
||||
command: "gather-build-results [basePath]",
|
||||
describe: "Collects build/test output into a top-level build directory",
|
||||
builder: (yargs: yargs.Argv) =>
|
||||
yargs.positional("basePath", {
|
||||
describe: "The directory from which to gather build results",
|
||||
default: batchExplorerHome,
|
||||
default: "",
|
||||
}),
|
||||
handler: (argv) => gatherBuildResults(path.resolve(argv.basePath)),
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"extends": "../common-config/tsconfig-base.json",
|
||||
"exclude": ["__mocks__", "__tests__"],
|
||||
"exclude": ["__mocks__", "__tests__", "bin"],
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"outDir": "bin",
|
||||
|
|
|
@ -9,7 +9,7 @@ import * as os from "os";
|
|||
import * as path from "path";
|
||||
import * as shell from "shelljs";
|
||||
|
||||
export const batchExplorerHome = path.resolve("../../");
|
||||
export const defaultBatchExplorerHome = path.resolve(__dirname, "../../");
|
||||
export const configFile = path.resolve(
|
||||
os.homedir(),
|
||||
".config/batch/butil.json"
|
||||
|
@ -17,6 +17,7 @@ export const configFile = path.resolve(
|
|||
|
||||
const portalReactPath = "src/src/BatchExtension/Client/ReactViews";
|
||||
const defaultJsonIndentSize = 2;
|
||||
const printJsonIndentSize = 4;
|
||||
|
||||
export interface Configuration {
|
||||
paths: {
|
||||
|
@ -25,6 +26,8 @@ export interface Configuration {
|
|||
};
|
||||
}
|
||||
|
||||
type ConfigPath = keyof Configuration["paths"];
|
||||
|
||||
export const info = (...args: string[]) => console.log(color.blue(...args));
|
||||
export const warn = (...args: string[]) => console.warn(color.yellow(...args));
|
||||
export const error = (...args: string[]) => console.error(color.red(...args));
|
||||
|
@ -56,11 +59,9 @@ export function validateDirectory(path: string) {
|
|||
return "Not a valid directory";
|
||||
}
|
||||
|
||||
export function resolvePath(...paths: string[]) {
|
||||
if (paths.length > 0 && paths[0]) {
|
||||
paths[0] = paths[0].replace(/^~/, os.homedir());
|
||||
}
|
||||
return path.resolve(...paths);
|
||||
export function resolvePath(aPath: string) {
|
||||
aPath = aPath?.replace(/^~/, os.homedir());
|
||||
return path.resolve(aPath);
|
||||
}
|
||||
|
||||
export async function loadConfiguration(): Promise<Configuration> {
|
||||
|
@ -77,7 +78,7 @@ export async function getEditorConfig(
|
|||
option: keyof editorconfig.KnownProps,
|
||||
filePattern?: string
|
||||
) {
|
||||
let configPath = `${batchExplorerHome}/.editorconfig`;
|
||||
let configPath = `${defaultBatchExplorerHome}/.editorconfig`;
|
||||
if (filePattern) {
|
||||
configPath += "/" + filePattern;
|
||||
}
|
||||
|
@ -144,7 +145,13 @@ export function chmodx(paths: string[] | unknown) {
|
|||
}
|
||||
|
||||
// integrations have one place to look for things like coverage reports
|
||||
export function gatherBuildResults(basePath: string) {
|
||||
export async function gatherBuildResults(basePath: string) {
|
||||
if (!basePath) {
|
||||
basePath =
|
||||
(await loadConfiguration()).paths?.batchExplorer ??
|
||||
defaultBatchExplorerHome;
|
||||
}
|
||||
console.log("BasePth", basePath);
|
||||
const baseBuildDir = path.join(basePath, "build");
|
||||
|
||||
const doCopy = (src: string, dst: string) => {
|
||||
|
@ -196,32 +203,54 @@ export async function unlinkLocalProjects() {
|
|||
});
|
||||
}
|
||||
|
||||
export type ConfigureCommandOptions = {
|
||||
"paths.batchExplorer"?: string;
|
||||
"paths.batchPortalExtension"?: string;
|
||||
print: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* Configure CLI properties
|
||||
*/
|
||||
export async function configure() {
|
||||
const config = readJsonOrDefault(configFile);
|
||||
export async function configure(options: ConfigureCommandOptions) {
|
||||
const config = await loadConfiguration();
|
||||
config.paths ||= {};
|
||||
const answers = await inquirer.prompt([
|
||||
{
|
||||
name: "batchPortalExtension",
|
||||
message: "Path to Batch Portal Extension",
|
||||
default: config.paths.batchPortalExtension,
|
||||
validate: validateDirectory,
|
||||
},
|
||||
{
|
||||
name: "batchExplorer",
|
||||
message: "Path to Batch Explorer",
|
||||
default: config.paths.batchExplorer || batchExplorerHome,
|
||||
validate: validateDirectory,
|
||||
},
|
||||
]);
|
||||
|
||||
for (const [key, value] of Object.entries(answers)) {
|
||||
config.paths[key] = resolvePath(value as string);
|
||||
// If valid configuration options are passed in the command-line, set or
|
||||
// update the config object and skip prompting.
|
||||
if (isConfigurationObject(options)) {
|
||||
for (const [key, configPath] of Object.entries(options.paths)) {
|
||||
if (isConfigPathKey(key)) {
|
||||
config.paths[key] = resolvePath(configPath);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const answers = await inquirer.prompt([
|
||||
{
|
||||
name: "batchPortalExtension",
|
||||
message: "Path to Batch Portal Extension",
|
||||
default: config.paths.batchPortalExtension,
|
||||
validate: validateDirectory,
|
||||
type: "string",
|
||||
},
|
||||
{
|
||||
name: "batchExplorer",
|
||||
message: "Path to Batch Explorer",
|
||||
default: config.paths.batchExplorer || defaultBatchExplorerHome,
|
||||
validate: validateDirectory,
|
||||
type: "string",
|
||||
},
|
||||
]);
|
||||
for (const [key, value] of Object.entries(answers)) {
|
||||
config.paths[key as ConfigPath] = resolvePath(value as string);
|
||||
}
|
||||
}
|
||||
|
||||
await saveJson(configFile, config);
|
||||
info(`Configuration saved to ${configFile}`);
|
||||
if (options.print) {
|
||||
printJson(config);
|
||||
}
|
||||
}
|
||||
|
||||
interface LinkOptions {
|
||||
|
@ -256,7 +285,7 @@ async function runLinkageTask(callback: (opts: LinkOptions) => void) {
|
|||
const targetConf = readJsonOrDefault(targetPackageJson);
|
||||
|
||||
const packageRoot = path.join(
|
||||
config.paths.batchExplorer || batchExplorerHome,
|
||||
config.paths.batchExplorer || defaultBatchExplorerHome,
|
||||
"packages"
|
||||
);
|
||||
|
||||
|
@ -289,3 +318,18 @@ async function runLinkageTask(callback: (opts: LinkOptions) => void) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
function isConfigurationObject(object: unknown): object is Configuration {
|
||||
if (!object || typeof object !== "object") {
|
||||
return false;
|
||||
}
|
||||
return "paths" in object;
|
||||
}
|
||||
|
||||
function isConfigPathKey(key: string): key is ConfigPath {
|
||||
return ["batchExplorer", "batchPortalExtension"].includes(key);
|
||||
}
|
||||
|
||||
function printJson(json: object) {
|
||||
info(JSON.stringify(json, null, printJsonIndentSize));
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче