Skip to content

Commit

Permalink
fix: Add logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Nov 5, 2023
1 parent 704af85 commit 93c89b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function installBinaryen() {

// https://github.com/WebAssembly/wabt
async function installWabt() {
core.info('Installing Web Assembly Binary Toolkit (WABT)');
core.info('Installing WebAssembly wabt');

let platform = 'ubuntu';

Expand Down Expand Up @@ -74,31 +74,30 @@ async function findBuildablePackages() {
profile?: Record<string, { 'opt-level'?: string }>;
}

const builds: BuildInfo[] = [];
let output = '';

await exec.exec('cargo', ['metadata', '--format-version', '1', '--no-deps'], {
listeners: {
stdout: (data: Buffer) => {
output += data.toString();
},
},
});
const output = (
await exec.getExecOutput('cargo', ['metadata', '--format-version', '1', '--no-deps'])
).stdout;

const metadata = JSON.parse(output) as Metadata;
const builds: BuildInfo[] = [];
const metadata = JSON.parse(output.trim()) as Metadata;

await Promise.all(
metadata.packages.map(async (pkg) => {
if (!metadata.workspace_members.includes(pkg.id)) {
core.debug(`Skipping ${pkg.name}, not a workspace member`);
return;
}

core.debug(`Found ${pkg.name}, loading manifest ${pkg.manifest_path}, checking targets`);

const manifest = JSON.parse(
await fs.promises.readFile(pkg.manifest_path, 'utf8'),
) as Manifest;

pkg.targets.forEach((target) => {
if (target.crate_types.includes('cdylib')) {
core.debug(`Found cdylib target, adding build`);

builds.push({
optLevel: manifest.profile?.release?.['opt-level'] ?? 's',
packageName: pkg.name,
Expand All @@ -109,6 +108,8 @@ async function findBuildablePackages() {
}),
);

core.info(`Found ${builds.length} builds`);

return builds;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@moonrepo/build-proto-plugin",
"version": "0.0.1",
"version": "0.0.2",
"description": "A GitHub action to build, optimize, and prepare a proto WASM plugin for release.",
"main": "dist/index.js",
"scripts": {
Expand Down

0 comments on commit 93c89b6

Please sign in to comment.