Skip to content

.werft/build: Cleaning code #8636

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 1 commit into from
Mar 8, 2022
Merged

.werft/build: Cleaning code #8636

merged 1 commit into from
Mar 8, 2022

Conversation

ArthurSens
Copy link
Contributor

Description

Keep built.ts cleaner by removing branch length check from it

Add branch length check to validation phase, as it seems more appropriate, while making logic clearer with better error handling

Release Notes

NONE

@codecov
Copy link

codecov bot commented Mar 7, 2022

Codecov Report

Merging #8636 (98388c2) into main (103f835) will decrease coverage by 3.69%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8636      +/-   ##
==========================================
- Coverage   14.87%   11.17%   -3.70%     
==========================================
  Files          52       18      -34     
  Lines        4963      993    -3970     
==========================================
- Hits          738      111     -627     
+ Misses       4153      880    -3273     
+ Partials       72        2      -70     
Flag Coverage Δ
components-gitpod-cli-app 11.17% <ø> (ø)
components-local-app-app-darwin-amd64 ?
components-local-app-app-darwin-arm64 ?
components-local-app-app-linux-amd64 ?
components-local-app-app-linux-arm64 ?
components-local-app-app-windows-386 ?
components-local-app-app-windows-amd64 ?
components-local-app-app-windows-arm64 ?
components-ws-daemon-app ?
components-ws-daemon-lib ?
install-installer-raw-app ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
components/ws-daemon/pkg/content/initializer.go
.../installer/pkg/components/ws-manager/deployment.go
install/installer/pkg/common/networkpolicies.go
components/ws-daemon/pkg/daemon/daemon.go
components/local-app/pkg/auth/pkce.go
install/installer/pkg/common/render.go
install/installer/pkg/common/common.go
components/ws-daemon/pkg/daemon/markunmount.go
components/ws-daemon/pkg/cpulimit/dispatch.go
components/ws-daemon/pkg/content/service.go
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 103f835...98388c2. Read the comment docs.

Copy link
Contributor

@mads-hartmann mads-hartmann left a comment

Choose a reason for hiding this comment

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

A tiny change request, otherwise I agree that the check fits better there ☺️


async function preCommitCheck(werft: Werft) {
werft.log("pre-commit checks", "Running pre-commit hooks.")
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

As you're re-throwing the error I would suggest removing the try/catch logic here all-together ☺️

Copy link
Contributor Author

@ArthurSens ArthurSens Mar 7, 2022

Choose a reason for hiding this comment

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

Ah nice catch...

I think we could follow this pattern on other areas too:

  • One public function that is directly called by build.ts
  • The public function would call private functions on a try-catch block
  • Private functions would throw errors instead of running werft.fail

Keep built.ts clean by removing branch lenght check from it

Add branch length check to validation phase, while making logic clearer with better error handling

Signed-off-by: ArthurSens <[email protected]>
@roboquat roboquat merged commit 21c53c4 into main Mar 8, 2022
@roboquat roboquat deleted the as/cleaning branch March 8, 2022 10:14
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