Skip to content

fix(code-server): USE_CACHED should still install extensions #252

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 14 commits into from
Jun 3, 2024

Conversation

michaelbrewer
Copy link
Contributor

@michaelbrewer michaelbrewer commented May 25, 2024

When USE_CACHED is true and no extensions have been installed Then we should still try to install them

close #251


Tests performed

  • bun test -t code-server

Scenario: use_cached and extensions_dir is set, but no extensions installed

module "code-server" {
  source         = "./code_server"
  agent_id       = coder_agent.main.id
  order          = 1
  folder         = "/home/${local.username}/modules"
  install_prefix = "/home/${local.username}/.code-server"
  extensions_dir = "/home/${local.username}/.code-server/extensions"
  auto_install_extensions = true
  use_cached = true
}

Given USE_CACHED is true
AND a cached copy of code-server
AND we have a list of extensions to install at startup
Then we expect the extensions to be installed

Output when no extensions was installed before

⚙️ Creating settings file...
Installing code-server!
🥳 code-server has been installed in /home/local/.code-server
🧩 Installing extensions from /home/local/modules/.vscode/extensions.json...
Installing extensions...
Installing extension 'hashicorp.terraform'...
Extension 'hashicorp.terraform' v2.30.1 was successfully installed.
👷 Running code-server in the background...
Check logs at /tmp/code-server.log!

Output if extensions was already installed before

🧩 Installing extensions from /home/local/modules/.vscode/extensions.json...
Installing extensions...
Extension 'hashicorp.terraform' v2.30.1 is already installed. Use '--force' option to update to latest version or provide '@' to install a specific version, for example: 'hashicorp.terraform@1.2.3'.
Installing extensions...
Extension 'esbenp.prettier-vscode' v10.4.0 is already installed. Use '--force' option to update to latest version or provide '@' to install a specific version, for example: 'esbenp.prettier-vscode@1.2.3'.
👷 Running code-server in the background...
Check logs at /tmp/code-server.log!

Scenario: offline = true

module "code-server" {
  source         = "./code_server"
  agent_id       = coder_agent.main.id
  order          = 1
  folder         = "/home/${local.username}/modules"
  install_prefix = "/home/${local.username}/.code-server"
  extensions_dir = "/home/${local.username}/.code-server/extensions"
  offline = true
}

Expected output

🥳 Found a copy of code-server
👷 Running code-server in the background...
Check logs at /tmp/code-server.log!

When USE_CACHED is true and no extensions have been installed
Then we should still try to install them
@michaelbrewer
Copy link
Contributor Author

@mafredri something weird is happening with git-config tests? (bun test -t git-config works locally)

@michaelbrewer
Copy link
Contributor Author

@mafredri - this PR #254 resolves the unit tests failing due to the fix in the newer coder/coder module

@michaelbrewer
Copy link
Contributor Author

@code-asher - here is the PR for fixing cases where code-server has been reinstalled, but not any of the extensions.

@code-asher code-asher self-requested a review May 29, 2024 00:03
@michaelbrewer michaelbrewer requested a review from code-asher May 30, 2024 06:19
@michaelbrewer
Copy link
Contributor Author

@code-asher a little simpler to only support installing extension when the the EXTENSION_DIR is set

@michaelbrewer
Copy link
Contributor Author

@code-asher you are right :). Installing again when there are ones that already exist is really fast

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Code looks good!

@michaelbrewer michaelbrewer requested a review from code-asher May 31, 2024 06:17
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Awesome!!

@code-asher code-asher merged commit 4021d85 into coder:main Jun 3, 2024
2 checks passed
@michaelbrewer michaelbrewer deleted the fix/cached-extensions branch June 9, 2024 05:22
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.

fix(code-server): add extensions to be auto-installed even when a cached copy of coder is found
2 participants