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

[Heartbeat] Better handling of subfolders in package.json #30119

Closed
andrewvc opened this issue Jan 31, 2022 · 6 comments
Closed

[Heartbeat] Better handling of subfolders in package.json #30119

andrewvc opened this issue Jan 31, 2022 · 6 comments
Labels
enhancement good first issue Indicates a good issue for first-time contributors Heartbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team

Comments

@andrewvc
Copy link
Contributor

It is currently the case that heartbeat browser options only copy the exact folder specified to the tmp directory used for actually running it. This can be confusing to users who specify a path in a subfolder below their package.json, and can result in failed includes etc.

This issue proposes:

  1. Returning an error if the specified folder does not contain a package.json file
  2. Adding a new filter_journeys.folder option to let users actually filter by folder.

In the case of using the new filter_journeys.folder option heartbeat will run npm @elastic/synthetics $filter_journeys.folder to do the filtering.

@andrewvc andrewvc added enhancement Heartbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team labels Jan 31, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/uptime (Team:Uptime)

@andrewvc andrewvc added the good first issue Indicates a good issue for first-time contributors label Jan 31, 2022
@vigneshshanmugam
Copy link
Member

vigneshshanmugam commented Jan 31, 2022

Some thoughts here,

@andrewvc
Copy link
Contributor Author

andrewvc commented Jan 31, 2022

Hmmm, the user who reported this was using local folders. So maybe it's just those that need additional error handling?

target_directory only unzips that folder.

If your folder structure is:

README.md
synthetics/package.json
synthetics/tests-a/test-a.ts
synthetics/tests-b/test-b.ts
synthetics/common.ts

and you have a target_directory of synthetics/tests-a things won't work right since we're missing the package.json and presumably the user wants common.ts (if it's used as a require)

In this case, what I'm saying is there'd be a separate filter_journeys.folder option that would be set to synthetics/tests-a, but the user would set synthetics as the target_directory

@vigneshshanmugam
Copy link
Member

you have a target_directory of synthetics/tests-a things won't work right since we're missing the package.json

If the user passed in synthetics/tests-a as the local path, then he wont get message from Synthetics runner as we cannot find the root package.json as we dont know the project structure due to missing parent folder.

In this case, the runner would throw error as it cannot find root package.json file - https://github.com/elastic/synthetics/blob/251f504aa859ab0c4a119b5a59f7bbc84c586510/src/helpers.ts#L151

I am not sure about if its worth adding folder level filtering, We do already support names and tags filtering.

@andrewvc
Copy link
Contributor Author

andrewvc commented Feb 1, 2022

We agreed that we'll not add the new filter_journeys option, but we will change the target_directory option's behavior. We will now unpack the full zip and just cwd to that directory to avoid dependency issues.

@paulb-elastic
Copy link
Contributor

Replaced by the PUSH option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue Indicates a good issue for first-time contributors Heartbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team
Projects
None yet
Development

No branches or pull requests

4 participants