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

[v12] web: Ignore .swc directory when computing web SHA #29898

Merged
merged 3 commits into from
Sep 8, 2023

Conversation

camscale
Copy link
Contributor

@camscale camscale commented Aug 2, 2023

Ignore any .swc directories when computing the SHA of SHAs to
determine if make ensure-webassets should rebuild the web UI. The
.swc directories are in the .gitignore file, so should also be
ignored when computing the SHA of the web files.

On a fresh checkout of teleport, running make ensure-webassets
causes a plugin to be build or downloaded into
web/packages/teleport/.swc/plugins/v4. As this is inside the directory
over which the SHA of SHAs is computed, if you re-run
make ensure-webassets, it ends up rebuilding the web UI for the same
result. It should not rebuild the web UI if it hasn't changed. The SHA
of SHAs generated from a fresh checkout of teleport should match another
fresh checkout. This fails as generating the enterprise webassets after
generating the OSS webassets includes the plugin as part of the SHA, and
that is not there on a fresh checkin.

This will make a difference if we want to build the web assets as a
separate step on CI so that the webassets directory can be copied into
other builds. This will allow a later version of node.js to be used to
build the web UI that what may be available on the OS we're building
Teleport on (I'm looking at you, Centos 7).

Fix a shellcheck-reported issue of quoting while we're here.

Also (partial) backport some previous PRs that made minor changes to
build.assets/build-webassets-if-changed.sh.

Issue: #21724
Backport: #29892
Backport: #21822
Backport: #22979 (partial)
Changelog: none

r0mant and others added 3 commits August 2, 2023 22:07
…orms

Signed-off-by: Roman Tkachenko <roman@goteleport.com>
Co-authored-by: Victor Sokolov <gzigzigzeo@gmail.com>
Partial backport of 42c472a, just
the `build.assets/build-webassets-if-changed.sh` script.
Ignore any `.swc` directories when computing the SHA of SHAs to
determine if `make ensure-webassets` should rebuild the web UI. The
`.swc` directories are in the `.gitignore` file, so should also be
ignored when computing the SHA of the web files.

On a fresh checkout of `teleport`, running `make ensure-webassets`
causes a plugin to be build or downloaded into
`web/packages/teleport/.swc/plugins/v4`. As this is inside the directory
over which the SHA of SHAs is computed, if you re-run
`make ensure-webassets`, it ends up rebuilding the web UI for the same
result. It should not rebuild the web UI if it hasn't changed. The SHA
of SHAs generated from a fresh checkout of teleport should match another
fresh checkout. This fails as generating the enterprise webassets after
generating the OSS webassets includes the plugin as part of the SHA, and
that is not there on a fresh checkin.

This will make a difference if we want to build the web assets as a
separate step on CI so that the `webassets` directory can be copied into
other builds. This will allow a later version of node.js to be used to
build the web UI that what may be available on the OS we're building
Teleport on (I'm looking at you, Centos 7).

Fix a shellcheck-reported issue of quoting while we're here.
@ryanclark
Copy link
Contributor

v12 doesn't use Vite so the SWC directory doesn't get created

@camscale
Copy link
Contributor Author

camscale commented Aug 2, 2023

v12 doesn't use Vite so the SWC directory doesn't get created

Thanks for that. I wasn't sure, but I checked the .gitignore and saw it had the Vite section for .swc. I'll close this.

@camscale camscale closed this Aug 2, 2023
@camscale camscale deleted the camh/v12/webassets-ignore-swc branch August 2, 2023 12:37
@gzdunek gzdunek restored the camh/v12/webassets-ignore-swc branch September 8, 2023 12:48
@gzdunek
Copy link
Contributor

gzdunek commented Sep 8, 2023

Actually, could we merge this PR? I'm backporting Node v18 to branch/v12 and without this PR checking if the webassets have already been built doesn't work properly. I'm not sure which exactly commit fixes this (because a few PRs were combined here), but I think we can just merge the whole PR.
Ignoring .swc always doesn't hurt us (and sometimes you can have this directory locally on the branch/v12, for example when you switching from master, so it makes sense to ignore it).

Friendly ping @ryanclark

@gzdunek gzdunek reopened this Sep 8, 2023
Copy link
Contributor

@ryanclark ryanclark left a comment

Choose a reason for hiding this comment

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

Agreed @gzdunek

@gzdunek gzdunek added this pull request to the merge queue Sep 8, 2023
Merged via the queue into branch/v12 with commit 28910b6 Sep 8, 2023
34 checks passed
@gzdunek gzdunek deleted the camh/v12/webassets-ignore-swc branch September 8, 2023 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants