-
Notifications
You must be signed in to change notification settings - Fork 0
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: Compile each project individually #969
Conversation
@@ -6,7 +6,8 @@ | |||
"test": "npm run test --workspaces --if-present", | |||
"test-update": "jest -u", | |||
"synth": "npm run synth --workspace=cdk", | |||
"typecheck": "tsc", | |||
"pretypecheck": "npm -w common run typecheck", | |||
"typecheck": "npm run typecheck --workspaces", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -6,7 +6,8 @@ | |||
"test": "npm run test --workspaces --if-present", | |||
"test-update": "jest -u", | |||
"synth": "npm run synth --workspace=cdk", | |||
"typecheck": "tsc", | |||
"pretypecheck": "npm -w common run typecheck", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretypecheck
will always run before typecheck
see https://docs.npmjs.com/cli/v10/using-npm/scripts#pre--post-scripts. We need to compile the shared package first, as other projects depend on it, and it doesn't look like TypeScript understands this dependency.
@@ -4,7 +4,8 @@ | |||
"type": "module", | |||
"scripts": { | |||
"postinstall": "prisma generate", | |||
"test": "jest --detectOpenHandles --config ../../jest.config.js --selectProjects common" | |||
"test": "jest --detectOpenHandles --config ../../jest.config.js --selectProjects common", | |||
"typecheck": "tsc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When compiling the common
package, write the resulting files to disk (i.e. no --noEmit
flag), so that it can be used by the other projects during their compile.
@@ -3,7 +3,8 @@ | |||
"version": "0.0.0", | |||
"scripts": { | |||
"start": "./script/start", | |||
"test": "find . | egrep '.yml|.yaml' | xargs yamllint" | |||
"test": "find . | egrep '.yml|.yaml' | xargs yamllint", | |||
"typecheck": "echo 'Nothing to typecheck'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package has no TypeScript code, so there's nothing to do.
@@ -4,7 +4,8 @@ | |||
"description": "Diagrams as code", | |||
"type": "module", | |||
"scripts": { | |||
"generate": "mmdc -i diagram.mmd -o output.svg " | |||
"generate": "mmdc -i diagram.mmd -o output.svg ", | |||
"typecheck": "echo 'Nothing to typecheck'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package has no TypeScript code, so there's nothing to do.
The `common` package has a compile error: ``` TS2742: The inferred type of createPullRequest cannot be named without a reference to `octokit-plugin-create-pull-request/node_modules/@octokit/types`. This is likely not portable. A type annotation is necessary. ``` It looks like compiling at the root isn't granular enough, as the error wasn't reported during builds. This change updates to compiling each project individually, so that we catch such issues at CI.
There is a compilation error currently: ``` TS2742: The inferred type of createPullRequest cannot be named without a reference to `octokit-plugin-create-pull-request/node_modules/@octokit/types`. This is likely not portable. A type annotation is necessary. ``` The return type of `composeCreatePullRequest` is a bit tricky to infer. We're (currently) only using the `html_url` property, so update `createPullRequest` to return that, and therefore the return type of `createPullRequest` becomes `Promise<string | undefined>`.
@@ -46,6 +52,8 @@ export async function createPullRequest( | |||
files, | |||
})), | |||
}); | |||
|
|||
return response?.data.html_url; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main change here, and resolves the compilation error in the PR description.
The return type of composeCreatePullRequest
is a bit tricky to infer. As we're (currently) only using the html_url
property, update createPullRequest
to return that, and therefore the return type of createPullRequest
becomes Promise<string | undefined>
.
export async function createPullRequest( | ||
octokit: Octokit, | ||
{ | ||
props: CreatePullRequestOptions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change moves the object destructing out of the function signature, in an attempt to improve readability. This is totally subjective though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth doing a test run of snyk-integrator to make sure it still behaves as expected?
Absolutely! How? Is |
Yeah there's a couple of ways to do this. You can either:
|
I've done this, with a resulting PR of #976. @NovemberTang and I have been discussing the snyk-integrator over chat. Here's a summary for others: In general, masquerading as PROD should be avoided as there are potentially unknown side-effects. For example, imagine there are multiple stage aware branches in the application, we'll trigger all of them when only wanting to test one. Testing on PROD isn't ideal, for similar reasons. Mutating the lambda within the AWS console should also be avoided, as it removes the audit trail, and introduces elements of human error. Updating the lambda with a traditional deployment means all the CI checks have passed, increasing confidence. In this specific scenario, only one piece of the application is stage aware, and that is the part we are wanting to test. Whilst there are opportunities to refactor parts of the code to create more pure functions, it is most pragmatic to test on PROD, as this PR unblocks others. We will make the refactors in follow up PRs. |
What does this change, and why?
The
common
package has a compile error:It looks like compiling at the root isn't granular enough, as the error wasn't reported during builds.
This change resolves the compilation error, and updates to compiling each project individually. Sadly, this lengthens the build time.
This was discovered as part, and is a required, of #965.
How has it been verified?
See the build logs.