Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Logging #38

Merged
merged 10 commits into from
Feb 1, 2023
Merged
496 changes: 410 additions & 86 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions dist/licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,19 @@ The above copyright notice and this permission notice shall be included in all c

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ansi-styles
MIT
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


asynckit
MIT
The MIT License (MIT)
Expand Down
109 changes: 64 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2",
"ansi-styles": "^6.2.1",
"form-data": "^4.0.0"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions src/action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as core from "@actions/core";
import * as os from "os";
import * as path from "path";
import log from "./log";

export interface Inputs {
root: string | null;
Expand All @@ -24,7 +25,7 @@ function getNumberInput(key: string): number | null {
}

export function processInputs(): Inputs {
core.info("Processing the action inputs...");
log.info("Processing the action inputs...");
const inputs: Inputs = {
root: getStringInput("root"),
gcovExecutable: getStringInput("gcov-executable"),
Expand All @@ -37,7 +38,7 @@ export function processInputs(): Inputs {
// Auto set coveralls output if not specified
if (inputs.coverallsSend && inputs.coverallsOut === null) {
inputs.coverallsOut = path.join(os.tmpdir(), "coveralls.json");
core.info(`Auto set Coveralls output to '${inputs.coverallsOut}'`);
log.info(`Auto set Coveralls output to ${log.emph(inputs.coverallsOut)}`);
}
return inputs;
}
7 changes: 2 additions & 5 deletions src/coveralls.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as core from "@actions/core";
import * as fs from "fs";
import * as chrono from "./chrono";
import * as http from "./http";
import log from "./log";

export async function patch(coverallsOut: string) {
let data: string = fs.readFileSync(coverallsOut).toString();
Expand All @@ -13,11 +12,9 @@ export async function patch(coverallsOut: string) {
}

export async function send(coverallsOut: string) {
await core.group("Sending report to Coveralls...", async () => {
const time = chrono.now();
await log.group("Sending report to Coveralls...", async () => {
await http.postForm("https://coveralls.io/api/v1/jobs", {
json_file: fs.createReadStream(coverallsOut),
});
core.info(`Done in ${time.elapsed()}`);
});
}
11 changes: 4 additions & 7 deletions src/deps/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as io from "@actions/io";
import * as os from "os";
import * as action from "../action";
import * as chrono from "../chrono";
import log from "../log";
import * as pip from "./pip";

async function isMissing(tool: string): Promise<boolean> {
Expand Down Expand Up @@ -44,19 +43,17 @@ async function smartInstall(pkg: string) {
}

async function checkGcovr() {
core.info("Checking gcovr...");
log.info(`Checking ${log.emph("gcovr")}...`);
if (await isMissing("gcovr")) {
await pip.installPackage("gcovr");
}
}

async function checkLlvm() {
core.info("Checking llvm-cov...");
log.info(`Checking ${log.emph("llvm-cov")}...`);
if (await isMissing("llvm-cov")) {
await core.group("Installing LLVM...", async () => {
const time = chrono.now();
await log.group(`Installing ${log.emph("LLVM")}...`, async () => {
await smartInstall("llvm");
core.info(`Done in ${time.elapsed()}`);
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/deps/pip/info.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as core from "@actions/core";
import * as exec from "../../exec";
import log from "../../log";

export interface PackageInfo {
name: string;
Expand All @@ -20,7 +20,7 @@ export async function showPackageInfo(
if (strs.length >= 2) {
info[strs[0].trim()] = strs[1].trim();
} else {
core.info(`WARNING: Invalid line: ${strs}`);
log.warning(`Invalid line: ${strs}`);
}
}
return {
Expand Down
82 changes: 40 additions & 42 deletions src/deps/pip/install.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as core from "@actions/core";
import * as exec from "../../exec";
import log from "../../log";
import { PackageInfo, showPackageInfo } from "./info";
import { cachePackage, restorePackage } from "./cache";

Expand All @@ -20,46 +20,44 @@ async function installPackageDependencies(packageInfo: PackageInfo) {
}

export async function installPackage(packageName: string) {
const pkgInfo = await showPackageInfo(packageName);
if (pkgInfo !== null) {
await installPackageDependencies(pkgInfo);
return;
}
packageName = validatePackageName(packageName);
await core.group(`Installing ${packageName} package...`, async () => {
core.info(`Restoring ${packageName} package from cache...`);
if (await restorePackage(packageName)) {
core.info(`Done restoring ${packageName} package from cache`);
core.info(`Validating ${packageName} package...`);
const pkgInfo = await showPackageInfo(packageName);
if (pkgInfo !== null) {
core.info(`Package ${packageName} is valid`);
await installPackageDependencies(pkgInfo);
return;
let pkgInfo = await showPackageInfo(packageName);
if (pkgInfo === null) {
packageName = validatePackageName(packageName);
pkgInfo = await log.group(
`Installing ${log.emph(packageName)} package...`,
async (): Promise<PackageInfo> => {
log.info("Restoring package from cache...");
if (await restorePackage(packageName)) {
log.info("Validating package...");
const pkgInfo = await showPackageInfo(packageName);
if (pkgInfo !== null) {
log.info("Package is valid");
return pkgInfo;
}
log.warning("Invalid package. Cache probably is corrupted!");
}
log.info("Installing package using pip...");
await exec.exec("python3", [
"-m",
"pip",
"install",
"--user",
"--no-deps",
packageName,
]);
log.info("Saving package to cache...");
await cachePackage(packageName);
log.info("Validating package...");
const pkgInfo = await showPackageInfo(packageName);
if (pkgInfo === null) {
throw new Error(
"Invalid package. Installation probably is corrupted!"
);
}
log.info("Package is valid");
return pkgInfo;
}
core.info(
`WARNING: Invalid ${packageName} package. Cache probably is corrupted!`
);
}
core.info(`Installing ${packageName} package using pip...`);
await exec.exec("python3", [
"-m",
"pip",
"install",
"--user",
"--no-deps",
packageName,
]);
core.info(`Saving ${packageName} package to cache...`);
await cachePackage(packageName);
core.info(`Validating ${packageName} package...`);
const pkgInfo = await showPackageInfo(packageName);
if (pkgInfo === null) {
throw new Error(
`Invalid ${packageName} package. Installation probably is corrupted!`
);
}
core.info(`Package ${packageName} is valid`);
await installPackageDependencies(pkgInfo);
});
);
}
await installPackageDependencies(pkgInfo);
}
Loading