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

feat(core): add support for http based caches #30593

Merged
merged 3 commits into from
Apr 9, 2025
Merged

Conversation

AgentEnder
Copy link
Member

@AgentEnder AgentEnder commented Apr 2, 2025

Implements http based remote caches per the RFC here: #30548

Copy link

vercel bot commented Apr 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Apr 9, 2025 6:20pm

Copy link

nx-cloud bot commented Apr 2, 2025

View your CI Pipeline Execution ↗ for commit 2a84b29.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 25m 4s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 21s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check --base=494f1... ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 1s View ↗
nx documentation ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-04-09 19:24:57 UTC

@AgentEnder AgentEnder force-pushed the feat/http-cache branch 3 times, most recently from 6c1f51d to 12992ab Compare April 3, 2025 16:00
@AgentEnder AgentEnder force-pushed the feat/http-cache branch 2 times, most recently from 4ff722d to 4d6674c Compare April 8, 2025 16:46
@AgentEnder AgentEnder marked this pull request as ready for review April 8, 2025 18:49
@AgentEnder AgentEnder requested review from a team, FrozenPandaz and vsavkin as code owners April 8, 2025 18:49
@@ -19,7 +22,7 @@ import { join } from 'path';
describe('cache', () => {
beforeEach(() => newProject({ packages: ['@nx/web', '@nx/js'] }));

afterEach(() => cleanupProject());
// afterEach(() => cleanupProject());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bring this back

const output = runCLI(`build ${projectName}`, {
env: {
NX_SELF_HOSTED_REMOTE_CACHE_SERVER: 'http://localhost:3000',
NX_NATIVE_LOGGING: 'nx::native::cache::http_remote_cache',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove

@@ -461,6 +513,7 @@ describe('cache', () => {
}
}
});
console.log(lines);
Copy link
Collaborator

Choose a reason for hiding this comment

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

rm

cacheServer.kill();
});

it('should request cache from remote cache', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
it('should request cache from remote cache', async () => {
it('should PUT and GET cache from remote cache', async () => {

code_header.set_cksum(); // Ensure the checksum is set correctly
archive
.append_data(&mut code_header, "code", &code.to_be_bytes()[..])
.unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why would this fail? Should we handle that?

trace!("Reading tarball into memory");
let archive_bytes = archive.into_inner().unwrap();
let buffer = archive_bytes.finish()?;
// let mut buffer = Vec::new();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove

trace!("Finished tarball");

trace!("Reading tarball into memory");
let archive_bytes = archive.into_inner().unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use a ? here?

Suggested change
let archive_bytes = archive.into_inner().unwrap();
let archive_bytes = archive.into_inner()?;

.body(buffer) // Convert the bytes to a Vec<u8> for the request body
.send()
.await
.map_err(|e| anyhow::anyhow!("Failed to send request: {}", e))?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make sure this logs the error/ reponse body so that people know why the remote cache did not upload.

} else {
let path_on_disk = output_dir.join(entry_path);
trace!("Extracting entry to {}", path_on_disk.display());
fs::create_dir_all(path_on_disk.parent().unwrap())?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use .expect()

Comment on lines 55 to 56
{% tabs %}
{% tab title="Nx 20.8+" %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Its weird to have a tabs component with only one tab. It looks like the tab component doesn't handle it well either.

Screenshot 2025-04-09 at 12 56 35 PM

Copy link
Collaborator

@isaacplmann isaacplmann left a comment

Choose a reason for hiding this comment

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

Docs content looks good, other than the single tab issue.

@AgentEnder AgentEnder enabled auto-merge (squash) April 9, 2025 17:02
@AgentEnder AgentEnder merged commit 0525426 into master Apr 9, 2025
13 checks passed
@AgentEnder AgentEnder deleted the feat/http-cache branch April 9, 2025 19:25
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.

4 participants