Skip to content

Conversation

@mdjastrzebski
Copy link
Collaborator

@mdjastrzebski mdjastrzebski commented Dec 12, 2024

Summary

Scope:

  • detect project root and CI
  • calculate native fingerprint
  • Android:
    • download artifact if available
    • use local artifact if available
  • iOS:
    • download artifact if available
    • compress and decompress with tar.gz to preserve permission
    • use local artifact if available
  • generic design to accommodate other CI/artifact providers
  • --no-remote-build-cache CLI option

UX:

Android:
CleanShot 2024-12-27 at 13 36 30@2x

iOS:
CleanShot 2024-12-27 at 13 37 38@2x

Test plan

@mdjastrzebski mdjastrzebski force-pushed the feat/remote-cache-build branch 3 times, most recently from 0f0320c to 0f73681 Compare December 17, 2024 14:55
@mdjastrzebski mdjastrzebski force-pushed the feat/remote-cache-build branch from 0f73681 to 46298ac Compare December 19, 2024 12:16
@mdjastrzebski mdjastrzebski changed the base branch from main to chore/publish-packages-to-private-npm December 19, 2024 12:16
Base automatically changed from chore/publish-packages-to-private-npm to main December 20, 2024 09:44
import path from 'node:path';
import { getProjectRoot } from '../project.js';

export const LOCAL_BUILD_CACHE_DIRECTORY = '.rnef-build-cache';
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use cacheManager or helpers from there? We have logic that will store the cache in:

  • home/user/.cache/rnef on Linux
  • /Users/User/Library/Caches/rnef on MacOS
  • C:\Users\User\AppData\Local\Temp\rnef on Windows

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wonder it it would not be a better idea to have the cache folder under project path, otherwise there is a risk for collision between project, etc. That would be only benefitial if there is something that can be cached BETWEEN different projects. @thymikee wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would rather suggests defining 2 types of RNEF cache:

  • global: shared between RNEF projects (current cacheManager)
  • project: related to given project, kept under project root

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently cache manager is project-bound (so no collisions) and I would prefer to keep it this way unless there’s clear benefit to have global cache. Most tools keep their caches outside of the project and there’s no clear winner (some in ~/.cache, some in system caches, some in os tmpdir, some even in node_modules). I’d keep it where it is right now and stick to one directory

Copy link
Collaborator Author

@mdjastrzebski mdjastrzebski Dec 31, 2024

Choose a reason for hiding this comment

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

From what you pasted, the cache manager is global:

  • /home/user/.cache/rnef on Linux
  • /Users/User/Library/Caches/rnef on MacOS
  • C:\Users\User\AppData\Local\Temp\rnef on Window

Copy link
Collaborator Author

@mdjastrzebski mdjastrzebski Dec 31, 2024

Choose a reason for hiding this comment

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

Seems like this is work fairly manual, with project-specific cache keys constructed at cacheManager.get call-sites. The existing solution looks error-prone, as it uses names from package.json which might be duplicate and relies on caller constructing such project-unique key. IMO it would be better idea to keep these caches under project directory, e.g. <project-root>/.rnef/cache.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, let's go with .rnef/ for now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, changed to:

◇  Downloaded cached build: .rnef/cache/remote-build/rnef-android-debug-01a6d8b8bbda48a412cbf19738475df9efd56155/app-debug.apk

@thymikee Let me know if I should refactor cacheManager to put stuff in .rnef/cache instead of system temp directory.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep cache in one place please, so yeah refactor :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll do it in a separate PR.

@mdjastrzebski mdjastrzebski requested a review from thymikee January 2, 2025 10:39
@mdjastrzebski mdjastrzebski requested a review from thymikee January 2, 2025 11:56
# Conflicts:
#	packages/plugin-platform-android/src/lib/commands/listAndroidTasks.ts
#	packages/plugin-platform-android/src/lib/commands/runAndroid/runAndroid.ts
@mdjastrzebski mdjastrzebski merged commit 63d85d8 into main Jan 2, 2025
1 check passed
@mdjastrzebski mdjastrzebski deleted the feat/remote-cache-build branch January 2, 2025 16:03
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.

3 participants