question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I2I: Consolidate source code under `src/`

See original GitHub issue

In the earlier days of amp, the root directory was fairly sparse. “Top-level” directories like 3p, ads, builtins, and extensions had separate functions, while src was synonymous with the AMP runtime. IIUC, one motivation for this at the time was so external contributors could easily view the repo and understand where to contribute an ad provider, 3p integration, or new component/extension.

Today, the root directory has dozens of config files and directories (.babel-cache/, .circleci/, .codecov.yml, .css-cache/, .editorconfig, .eslintignore, .eslintplugin.js, .eslintrc.js, .git/, .gitattributes, .github/, .gitignore, .lando.yml, .lgtm.yml, .npmrc, .nyc_output/, .pre-closure-cache/, .prettierignore, .prettierrc, .renovaterc.json, .vscode/), build/dist files, node_modules, third_party, and a handful of other directories containing tools, docs, and more.

More generally, I suspect if we re-created the repo today, we’d put all the source files under src, separate from built system, build files, documentation, and testing. Down the line, this can also allow for consolidation and simplification of some lint rules, presubmits, etc.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
rcebulkocommented, Jun 16, 2021

One concern is that this will make it more difficult to view the blame of the moved directories, whose original paths will be effectively treated as deleted. It’s still possible by calling git blame with a commit hash prior to the relocation, but retrieving this is slightly more friction than not and could be hard for new contributors as time goes on. For me, being able to do this is valuable for components I’m less familiar with as well as those with long histories.

As long as I used git mv properly (which I intend to), history/blame still works naturally within GitHub. For example, when I moved src/utils/string.js to src/core/types/string/index.js, you can still see the blame from 6 years ago on the “new”/moved file. So, I think that may not be an issue, unless I’m missing something.

Another point – when moving extensions inside src, would this change then move any unit, e2e, and validator tests typically located inside extensions/**/test outside of src to the separate testing directory described?

I would say moving any test files within extensions/, if anything, would merit an entirely separate design review.

Personal tangent on what I think we should do with test files down the line, in separate design review(s) As an aside, personally I would be in favor of moving more tests closer to source files (and `test/unit/core` is structured to mirror the source tree so this could be done easily for core). If that were to happen, I'd propose in conjunction shifting the naming convention from `foo.js`/`test-foo.js` to `foo.js`/`foo.test.js` or `foo-test.js` so source+test files are grouped together in sorting. But that would again be at least a separate design review, if not two.

Regardless of the note above, the scope of this DR would be almost exclusively git mv {3p,ads,builtins,extensions} src/ (and updating corresponding imports), and not any shuffling of test files at this time.

0reactions
stale[bot]commented, Nov 23, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

content/public/common/content_switches.cc - chromium/src - Git at ...
Use of this source code is governed by a BSD-style license that can be ... Tells whether the code is running browser tests...
Read more >
Understanding important folders and files - IBM
Learn about the source code folder structure to find the components that you need to customize, where to save your customizations, and the...
Read more >
eclipse - Combine two folder in one src together - Stack Overflow
Code structure I am required to separate src into two folders which is java and resources. However when I compile the code, I...
Read more >
munit recorder
Because MUnit does not start any of the flow sources (such as triggers or listeners), ... Configure the code coverage report for unit...
Read more >
A Clustering-Based MPSoC Design Flow for Data ... - ResearchGate
ing tokens onto a channel c, e.g., src(c1) = a1 for the DFG depicted in ... declarations in the source code shown in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found