Skip to content

Conversation

@kraenhansen
Copy link
Contributor

Description

Merging this PR will:

  1. Add sandboxes: The creation of temporary directories for installers and app to store files into.
  2. Simplify the downloadFile to use fetch and avoid having to implement following redirection manually and adopt to Anna's suggestion of using stream.promises.pipeline.
  3. I've replaced skipDownload (which had two purposes - testing locally built / packaged compass as well as spending less time downloading) with a download cache based on the ETag header of the server response and a new --forceDownload flag to clear the cache before download.
  4. When building and packaging Compass locally, a dist/target.json with "build info" is produced, so to test a locally built and packaged Compass, we don't need to invoke Hadron build again. I've added a --localPackage to skip hadron-build and download entirely and instead use the compass/dist directory (and its artifacts).
  5. I wanted to make the parsing / assertion of the build-info bind types, such that the extraction of the filename property could be generalized and we could have code like: if (kind === 'osx_dmg') { console.log(buildInfo.osx_dmg_filename) (i.e. a conditional on the kind of package narrows buildInfo). I've added the extraction of the filename from the "build info" based on the kind of package as well.

Checklist

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@kraenhansen kraenhansen added the no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion) label Jan 16, 2025
@kraenhansen kraenhansen self-assigned this Jan 16, 2025
.catch(function (err) {
console.error(err.stack);
process.exit(1);
process.exitCode = 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

From https://nodejs.org/api/process.html#processexitcode:

Rather than calling process.exit() directly, the code should set the process.exitCode and allow the process to exit naturally by avoiding scheduling any additional work for the event loop:

Copy link
Contributor

Choose a reason for hiding this comment

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

It is like I know this and keep independently rediscovering it yet still forget.

'IS_RHEL',
])
);
writeBuildInfo(infoArgs);
Copy link
Contributor

Choose a reason for hiding this comment

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

Part of me wants to change hadron-build so we can get this info as a variable without an intermediate file, but I've been a bit weary of changing that code because it is used in so many ways and often only at release time. Although I suppose nowadays we release dev too, so it should be safer.

filepath,
destinationPath: context.sandboxPath,
});
cleanups.push(uninstall);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably uninstall before clearing out the sandbox because if it runs an uninstaller that uninstaller will be inside the sandbox.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point - deleting the sandbox should be the last cleanup task 👍

Copy link
Contributor

@lerouxb lerouxb left a comment

Choose a reason for hiding this comment

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

Great work!

import { type fetch as undiciFetch } from 'undici-types';

// Hacking types here because the DOM types doesn't match the fetch implemented by Node.js
const fetch = globalThis.fetch as unknown as typeof undiciFetch;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could be avoided if we moved the code into its own package with types properly locked down.

@kraenhansen kraenhansen merged commit 84ffd4d into main Jan 16, 2025
31 checks passed
@kraenhansen kraenhansen deleted the kh/smoke-test/sandboxing-and-refactor branch January 16, 2025 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants