gravitational / teleport

The easiest, and most secure way to access and protect all of your infrastructure.
https://goteleport.com
GNU Affero General Public License v3.0
17.62k stars 1.76k forks source link

Remove WASM build from UI test workflows #45801

Open zmb3 opened 2 months ago

zmb3 commented 2 months ago

Investigate whether we can remove the WASM build from the UI test workflows. The RDP WASM component should not be needed for the web UI tests, and it currently takes just as long as the full test suite, which means that we could cut test runtime in half by removing this step.

ravicious commented 1 month ago

AFAIK the idea behind this would be to replace these three imports with some kind of a shim:

https://github.com/gravitational/teleport/blob/f4fc673e45015843fe1c1ad5d2e682482338a255/web/packages/teleport/src/lib/tdp/client.ts#L21-L24

Here's what Isaiah said when we were talking about it back in December 2023:

The difficulty with adding type-shims is that those types will always be searched for in teleport/ironrdp/pkg/ironrdp, which is generated by wasm-pack with a .gitignore that ignores everything (*).

This means that we could check in the types generated in web/packages/teleport/src/ironrdp/pkg/ironrdp.d.ts and it will cause e.g. yarn type-check to pass without needing to build the full wasm module. The problem will arise when that API changes --- we will need to remember to git add --force those changes. An alternative is that we use this non-upstreamed change in wasm-pack to avoid that gitignore creation. That could work relatively smoothly, we would then just maintain our own .gitignore in web/packages/teleport/src/ironrdp/pkg/ that looks like

*
!.gitignore
!ironrdp.d.ts

Keep in mind that that this was said in the context of removing the need to compile WASM code completely. Back then if you didn't compile WASM stuff, you couldn't really use Connect in dev mode as it'd show type errors from the whole project in an overlay inside the app. This has since been removed after we migrated to Vite.

In the case of a CI step, we don't have to worry about gitignore that much. We can keep the shim in a separate directory. In the CI step, we can move the shim to where the code expects WASM files to be. Devs working on those WASM components would need to remember about updating the shim though, but the CI would remind them about that anyway.