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

feat: improved progress tracking of jsii-pacmak #4136

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 18 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ jobs:
with:
distribution: 'zulu'
java-version: '8'
- name: Set up Node 14
- name: Set up Node 16
uses: actions/setup-node@v3
with:
cache: yarn
node-version: '14'
node-version: '16'
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -124,11 +124,11 @@ jobs:
with:
distribution: 'zulu'
java-version: '8'
- name: Set up Node 14
- name: Set up Node 16
uses: actions/setup-node@v3
with:
cache: yarn
node-version: '14'
node-version: '16'
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -194,7 +194,7 @@ jobs:
dotnet: ['6.0.x']
go: ['1.18']
java: ['8']
node: ['14'] # EOL 2023-04-30
node: ['16']
os: [ubuntu-latest]
python: ['3.7']
# Add specific combinations to be tested against "node 14" (to restrict cardinality)
Expand All @@ -205,60 +205,53 @@ jobs:
dotnet: '6.0.x'
go: '1.18'
java: '8'
node: '14'
node: '16'
python: '3.7'
# Test using macOS
- title: 'macOS'
os: macos-latest
dotnet: '6.0.x'
go: '1.18'
java: '8'
node: '14'
node: '16'
python: '3.7'
# Test alternate Nodes
- title: 'Node 16'
java: '8'
dotnet: '6.0.x'
go: '1.18'
node: '16' # EOL 2023-09-11
os: ubuntu-latest
python: '3.7'
- title: 'Node 18'
java: '8'
dotnet: '6.0.x'
go: '1.18'
node: '18' # EOL 2025-04-30
os: ubuntu-latest
python: '3.7'
- title: 'Node 19'
- title: 'Node 20'
java: '8'
dotnet: '6.0.x'
go: '1.18'
node: '19' # EOL 2023-06-01
node: '20' # EOL 2023-09-11
os: ubuntu-latest
python: '3.7'
# Test alternate .NETs
- title: '.NET 7.0'
java: '8'
dotnet: '7.0.x'
go: '1.18'
node: '14'
node: '16'
os: ubuntu-latest
python: '3.7'
# Test alternate Gos
- title: 'Go 1.19'
java: '8'
dotnet: '6.0.x'
go: '1.19'
node: '14'
node: '16'
os: ubuntu-latest
python: '3.7'
# Test alternate Javas
- title: 'Java 11'
java: '11'
dotnet: '6.0.x'
go: '1.18'
node: '14'
node: '16'
os: ubuntu-latest
python: '3.7'
# Test alternate Pythons
Expand All @@ -267,28 +260,28 @@ jobs:
dotnet: '6.0.x'
go: '1.18'
java: '8'
node: '14'
node: '16'
os: ubuntu-latest
- title: 'Python 3.9'
python: '3.9'
dotnet: '6.0.x'
go: '1.18'
java: '8'
node: '14'
node: '16'
os: ubuntu-latest
- title: 'Python 3.10'
python: '3.10'
dotnet: '6.0.x'
go: '1.18'
java: '8'
node: '14'
node: '16'
os: ubuntu-latest
- title: 'Python 3.11'
python: '3.11'
dotnet: '6.0.x'
go: '1.18'
java: '8'
node: '14'
node: '16'
os: ubuntu-latest

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -440,10 +433,10 @@ jobs:
with:
distribution: 'zulu'
java-version: '8'
- name: Set up Node 14
- name: Set up Node 16
uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '16'
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
Expand Down
42 changes: 37 additions & 5 deletions packages/jsii-pacmak/lib/builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Rosetta } from 'jsii-rosetta';
import { ListrDefaultRenderer, ListrTaskWrapper } from 'listr2';
import * as path from 'path';

import * as logging from './logging';
Expand Down Expand Up @@ -51,6 +52,12 @@ export interface BuildOptions {
* type checking is not possible.
*/
readonly runtimeTypeChecking: boolean;

/**
* A function to report progress to the user (e.g: via the command line
* interface).
*/
readonly reportProgress: (message: string) => void;
}

/**
Expand All @@ -59,7 +66,9 @@ export interface BuildOptions {
* Building can happen one target at a time, or multiple targets at a time.
*/
export interface TargetBuilder {
buildModules(): Promise<void>;
buildModules(
task: ListrTaskWrapper<unknown, ListrDefaultRenderer>,
): Promise<void>;
}

/**
Expand All @@ -80,7 +89,26 @@ export class IndependentPackageBuilder implements TargetBuilder {
private readonly options: BuildOptions,
) {}

public async buildModules(): Promise<void> {
public async buildModules(
task: ListrTaskWrapper<unknown, ListrDefaultRenderer>,
): Promise<void> {
await task
.newListr<BuildOptions>(
this.modules.flatMap((modules) =>
modules.map((module) => ({
title: module.name,
task: async (options, _task) => {
if (options.codeOnly) {
return this.generateModuleCode(module, options);
}
return this.buildModule(module, options);
},
})),
),
{ ctx: this.options },
)
.run();

if (this.options.codeOnly) {
await Promise.all(
flatten(this.modules).map((module) =>
Expand All @@ -100,7 +128,9 @@ export class IndependentPackageBuilder implements TargetBuilder {

private async generateModuleCode(module: JsiiModule, options: BuildOptions) {
const outputDir = this.finalOutputDir(module, options);
logging.debug(`Generating ${this.targetName} code into ${outputDir}`);
options.reportProgress(
`Generating ${this.targetName} code into ${outputDir}`,
);
await this.makeTarget(module, options).generateCode(
outputDir,
module.tarball,
Expand All @@ -112,12 +142,14 @@ export class IndependentPackageBuilder implements TargetBuilder {
const outputDir = this.finalOutputDir(module, options);

const src = await Scratch.make((tmpdir) => {
logging.debug(`Generating ${this.targetName} code into ${tmpdir}`);
options.reportProgress(
`Generating ${this.targetName} code into ${tmpdir}`,
);
return target.generateCode(tmpdir, module.tarball);
});

try {
logging.debug(`Building ${src.directory} into ${outputDir}`);
options.reportProgress(`Building ${src.directory} into ${outputDir}`);
return await target.build(src.directory, outputDir);
} catch (err) {
logging.warn(`Failed building ${this.targetName}`);
Expand Down
Loading