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

fix(node): unable to run projen package on windows #2761

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

iliapolo
Copy link
Contributor

TODO


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2023

Codecov Report

Merging #2761 (4a4995f) into main (effc339) will decrease coverage by 0.03%.
The diff coverage is 73.17%.

❗ Current head 4a4995f differs from pull request most recent head 371620b. Consider uploading reports for the commit 371620b to get more accurate results

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main    #2761      +/-   ##
==========================================
- Coverage   96.30%   96.28%   -0.03%     
==========================================
  Files         181      181              
  Lines       33385    33407      +22     
  Branches     3062     3065       +3     
==========================================
+ Hits        32153    32166      +13     
- Misses       1232     1241       +9     
Impacted Files Coverage Δ
src/build/build-workflow.ts 85.74% <56.00%> (-1.65%) ⬇️
src/cdk/jsii-project.ts 96.18% <100.00%> (-0.06%) ⬇️
src/javascript/node-project.ts 93.41% <100.00%> (+0.01%) ⬆️
src/release/release.ts 98.46% <100.00%> (+<0.01%) ⬆️
src/task.ts 98.41% <100.00%> (ø)

... and 1 file with indirect coverage changes

Comment on lines 13 to 25
if (process.env.CI) {
// in jsii we consider the entire repo (post build) as the build artifact
// which is then used to create the language bindings in separate jobs.
copyFiles(".", repoTempDir, [".git", "node_modules"]);
if (fs.existsSync(artifactsDirectory)) {
fs.rmdirSync(artifactsDirectory, { recursive: true });
}
fs.renameSync(repoTempDir, artifactsDirectory);
} else {
child.execSync(`npx projen ${PACKAGE_ALL_TASK_NAME}`, {
stdio: ["inherit", "inherit", "inherit"],
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this makes it any easier for you, I strongly believe that the if CI check should be done inside the GitHub Actions workflow (at which point it's not an if anymore) and not as part of the task.

But I realize you primarily want to fix this for windows. So this is still better than what we have today.

@mrgrain mrgrain mentioned this pull request Oct 9, 2023
14 tasks
mergify bot pushed a commit that referenced this pull request Feb 21, 2024
…ment (#3377)

## Motivation

I was taking inspiration from #2761. I didn't closely follow what was available there because it's outdated, but I used a similar approach.

There are different issues related to developing `projen` on Windows. The most related ones to bootstrapping are #1529 and #2427.

To break the Windows development problem into pieces, I started with bootstraping because it is command I run the most run when developing projen. The other projen tasks can be reviewed and modified if necessary in future PRs.

I should create an issue to expose this idea, but before doing that, I'm trying to see if breaking it like that is viable and starting with bootstrapping.

## Implementation

I decided to do something similar to #2761 and use a NodeJS script. Then, I translated the existing Bash script, as of today, to NodeJS. Also, `.projenrc.js` will generate that script, similar to how it works with the existing Bash script. Windows has no CI implementation because the `build` and `package` tasks could fail. 

## Changes

## Change 1 projen.js

1. The bootstrapping script is a translation from Bash to NodeJS.
2. The critical bits are the `bootstrap` and `execCommand` functions.
3. In `execCommand`, the important part is `{ stdio: "inherit" }` to make sure to pass input and get output from the executed command by passing down the parent process streams to the child process.
4. I didn't add tests.

## Change 2 .projenrc.js

1. Replacing `projen.bash` with `projen.js`
2. Adding functions in the entrypoint `.projenrc.js`: `execCommand`  and `bootstrap`. These are only to simplify how `projen.js` is generated. Could it be better to move those two functions to another file so as not to pollute .projenrc.js?
4. I didn't add tests.

## Change 3 all files with marker

1. The marker was autoupdated to use `node ./projen.js`

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants