Skip to content

chore: migrate all Coder modules to Registry repo #4

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

Merged
merged 23 commits into from
Apr 17, 2025
Merged

Conversation

Parkreiner
Copy link
Member

@Parkreiner Parkreiner commented Apr 16, 2025

Addresses part of coder/internal#532 (but doesn't fully close it out).

This is a huge PR, but chunking it up seemed pointless, since we're largely copying over existing files. I'm going to try commenting on the main areas I think are worth paying attention to

Changes made

  • Migrated over all Coder modules from coder/modules, and put them in their correct user namespaces.
  • Added README.md files to all newly-created user namespaces
  • Updated all image paths for every image used, to make sure they don't break (I switched the paths programmatically, and then manually verified every README to guarantee this).
  • Added README.md files for each contributor who previously made a module
  • Updated our tsconfig.json file to use modern libraries when run from the server, and made a custom tsconfig.json just for the windows-rdp module (which has more restrictive browser concerns)
  • Added CI step to run all the module tests we currently have

Notes

  • There were a lot of Bash script files that weren't carried over in this PR, partly because I don't know Bash well enough to know (1) whether they're still needed, or (2) modify them to account for the new file structure. Those can be brought over later.
  • We had a lint.ts file that provided some light validation of some of the modules. After going through it, there were so many bugs and issues with the code that I legitimately think that it barely provided a safety net at all. I got rid of it entirely, with the intention of adding the functionality that was originally intended to the current validation logic (to be handled in a separate PR).
  • I changed how we set up the .images directory, because it felt like it would be chaos if a bunch of users try to throw all their images in one giant directory, with no guidelines on how to do it. I instead made it so that images should be scoped by namespace, which felt a lot more manageable. The .icons directory is still at the top level, because realistically, there are only going to be so many types of icons referenced, so it's fine for those to be shared.
  • I don't think the maintainer_github and contributor_github fields make sense anymore, but those can be stripped out once we've updated the Registry site build step to use the new Registry repo
    • My gut instinct is to use the user namespace to determine the main owner of the module, and then add a contributors string list to indicate which other users have contributed meaningfully to it. We can then add validation to make sure that every value in that list exists as another namespace in the repo

What still needs to be migrated (in separate PRs)

These are the main files of interest that still probably need to be copied over from the /modules repo:

  • new.sh
  • terraform_validate.sh
  • update-version.sh

They're probably going to require enough changes that it's worth handling them in a separate PR.

@Parkreiner Parkreiner self-assigned this Apr 16, 2025
@@ -0,0 +1,6 @@
{
Copy link
Member Author

Choose a reason for hiding this comment

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

Truth be told, I don't really know what this file does. I just copied it over verbatim

Copy link
Member

Choose a reason for hiding this comment

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

This is VSCode setting to prevent it from indexing or searching in tfstate files.

@@ -0,0 +1,26 @@
#!/usr/bin/env sh
Copy link
Member Author

@Parkreiner Parkreiner Apr 16, 2025

Choose a reason for hiding this comment

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

More Bash I don't understand, but this file seemed especially important for showing someone how to make a module

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this is needed to bootstrap a new module. we can rewrite it as per the new directory structure later.

// they're part of the form. Avoids CSS stacking context issues, maybe?
/** @type {HTMLLIElement | null} */
const protocolOption = document.querySelector(
// biome-ignore lint/style/useTemplate: Have to skip interpolation for the main.tf interpolation
Copy link
Member Author

Choose a reason for hiding this comment

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

Added Biome warnings so that someone doesn't accidentally change these to template literal syntax in the future, without realizing that it'll break the entire module

@@ -0,0 +1,25 @@
{
Copy link
Member Author

@Parkreiner Parkreiner Apr 16, 2025

Choose a reason for hiding this comment

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

We previously had a weird franken-tsconfig file for the entire modules repo, because it was using modern modules for the server, but was restricted to an older browser-specific target as far as what features you could use

I remembered that you can chain tsconfig files, though, so I made the root file as modern/server-specific as possible, and then made this ad-hoc file be co-located with the module

Comment on lines +10 to +15
"paths": {
// Not the biggest fan of relative paths in TypeScript projects, but it
// does make things easier for non-Coder contributors to get tests
// imported and set up
"~test": ["./test/test.ts"]
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I know Kayla's really gotten mad the few times people have tried to bring these into core, but I figured that it would be one fewer pain points for an outside contributor, since this repo's structure is going to be so much simpler, comparatively

Comment on lines +206 to +211
// This is a fix for when you try to run the tests from a Coder workspace.
// When process.env is destructured into the object, it can sometimes have
// workspace-specific values, which causes the resulting URL to be different
// from what the tests have classically expected.
childEnv.CODER_AGENT_URL = undefined;
childEnv.CODER_WORKSPACE_NAME = undefined;
Copy link
Member Author

@Parkreiner Parkreiner Apr 16, 2025

Choose a reason for hiding this comment

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

I don't know when the last time someone ran the Bun tests locally was, but this was breaking for me, when it definitely wasn't last year (when I made the windows-rdp module)

@Parkreiner Parkreiner marked this pull request as ready for review April 16, 2025 23:03
@Parkreiner Parkreiner requested review from f0ssel and matifali April 16, 2025 23:05
@@ -0,0 +1,36 @@
name: deploy-registry
Copy link
Member Author

Choose a reason for hiding this comment

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

@bcpeinhardt I copied this file over directly, but do we need to change anything to make sure that it runs correctly, now that this is in a different repo?

Copy link
Member

Choose a reason for hiding this comment

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

Can we deploy this new architecture in parallel to the current one just to make sure we do not break existing stuff?

Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

This is huge Michael. Thanks for making this look so effortless.

@matifali
Copy link
Member

matifali commented Apr 17, 2025

I have a PR in progress for updating update-version.sh. I can migrate that directly to this repo.
coder/modules#426

@Parkreiner Parkreiner merged commit 376664c into main Apr 17, 2025
2 checks passed
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