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

Use the standard src/tests paths, move package.json to the root. #292

Merged
merged 3 commits into from
May 13, 2024

Conversation

dblock
Copy link
Member

@dblock dblock commented May 13, 2024

Description

In #286 I am adding tests and things are getting messy having to deal with relative paths for tooling (for example, I'd like to lint .js files in tests that are dredd hooks). This PR adopts a more standard layout of tools and tests and moves package.json to the root, making it easier for developers to work in the repo.

A nice side-effect is that we can stop using relative paths in imports in tests by adding baseUrl into tsconfig.json and moduleDirectories: ['node_modules', 'tools'] into jest.config.js.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Contributor

API specs implemented for 299/649 (46%) APIs.

Signed-off-by: dblock <dblock@amazon.com>
Copy link
Contributor

API specs implemented for 299/649 (46%) APIs.

Signed-off-by: dblock <dblock@amazon.com>
@nhtruong
Copy link
Collaborator

Is this specific to dredd? As in can't it be placed in tools folder?

@dblock dblock changed the title Moved package.json to root. Use the standard src/tests paths, move package.json to the root. May 13, 2024
Copy link
Contributor

API specs implemented for 299/649 (46%) APIs.

@dblock
Copy link
Member Author

dblock commented May 13, 2024

Is this specific to dredd? As in can't it be placed in tools folder?

It's not. I think working in this repo is unnecessary cumbersome because you have to use relative paths for includes, and having to always remember to cd tools to run them. Tools then have to default to paths above tools (e.g. default output).

When adding spec tests (dredd) we run into an additional problem. Dredd has files such as hooks.js and we will place them into tests/spec (since these are tests for the spec that lives at the root). So now we want to run a linter on those files, but the package.json for the linter lives in ... tools, which is weird.

I could move tools into src/tools/ instead of just src, and still move package.json to the root, but that seems unnecessary.

@dblock
Copy link
Member Author

dblock commented May 13, 2024

@nhtruong if your issue is the name src, I renamed it back to tools, but still moved package.json to the root. LMK what you think.

Copy link
Contributor

API specs implemented for 299/649 (46%) APIs.

@nhtruong
Copy link
Collaborator

Is this specific to dredd? As in can't it be placed in tools folder?

It's not. I think working in this repo is unnecessary cumbersome because you have to use relative paths for includes, and having to always remember to cd tools to run them. Tools then have to default to paths above tools (e.g. default output).

When adding spec tests (dredd) we run into an additional problem. Dredd has files such as hooks.js and we will place them into tests/spec (since these are tests for the spec that lives at the root). So now we want to run a linter on those files, but the package.json for the linter lives in ... tools, which is weird.

I could move tools into src/tools/ instead of just src, and still move package.json to the root, but that seems unnecessary.

I see. That makes sense. I'm in!

@dblock
Copy link
Member Author

dblock commented May 13, 2024

I see. That makes sense. I'm in!

Before merging. Do you prefer tools/... or src/...?

Option A

src/merger, linter
tests/merger, linter

Option B

tools/merger, linter
tests/merger, linter

Option C

tools/merger, linter
tools/tests/merger, linter

@nhtruong
Copy link
Collaborator

This is not a nodes.js repo so I prefer tools over src as it tells us that applications in the folder are tools for the repo, not the focal point of the repo.

@dblock
Copy link
Member Author

dblock commented May 13, 2024

This is not a nodes.js repo so I prefer tools over src as it tells us that applications in the folder are tools for the repo, not the focal point of the repo.

Ok, and where do you want the tests for tools? B or C?

@nhtruong
Copy link
Collaborator

nhtruong commented May 13, 2024

Tests for the tools should be in tools. Test for the spec itself should be at the root of the repo. (So C-ish if that tests folder only refers to the tests for tools)

@nhtruong
Copy link
Collaborator

Btw I hope your IDE gives you a hand with renaming/moving files because all of these changes would be very painful without!

@dblock dblock force-pushed the move-to-root branch 2 times, most recently from b002aec to 6b7279b Compare May 13, 2024 14:48
Copy link
Contributor

API specs implemented for 299/649 (46%) APIs.

Signed-off-by: dblock <dblock@amazon.com>
Copy link
Contributor

API specs implemented for 299/649 (46%) APIs.

@dblock
Copy link
Member Author

dblock commented May 13, 2024

Tests for the tools should be in tools. Test for the spec itself should be at the root of the repo. (So C-ish if that tests folder only refers to the tests for tools)

Ok. Here's what I did:

  1. Moved package.json to root.
  2. Moved tools/linter and tools/merger to tools/src, otherwise tools/test looks like a tool.
  3. Moved tools/test to tools/tests.
  4. No more relative includes.

@nhtruong

@dblock dblock merged commit 6b36951 into opensearch-project:main May 13, 2024
6 checks passed
@dblock dblock deleted the move-to-root branch May 13, 2024 15:01
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.

2 participants