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

Surface duration it took to create an artifact to the runner #30

Closed
tom-sherman opened this issue Dec 4, 2023 · 3 comments
Closed

Surface duration it took to create an artifact to the runner #30

tom-sherman opened this issue Dec 4, 2023 · 3 comments

Comments

@tom-sherman
Copy link

Relates to vercel/remote-cache#17

To properly report on time saved in Vercel Remote Cache, we need to know how long the cache artifact took to generate (the time the task took).

Is this something that is already provided by NX and could be passed through? Or does this require upstream changes in NX?

@NiklasPor
Copy link
Owner

What time do you exactly need?:

  • Time to restore from cache (local or remote)
  • Time to create the artifact (time to execute build / lint / test)

The returned task runner includes startTime and endTime. I could surface the data inside the createCustomRunner callback.
It would be an array of tasks that would be passed to the cache. Here's an excerpt of it:

// Source: nx@17.0.2\node_modules\nx\src\config\task-graph.d.ts
export interface Task {
   ...
    /**
     *
     * Unix timestamp of when a Batch Task starts
     **/
    startTime?: number;
    /**
     *
     * Unix timestamp of when a Batch Task ends
     **/
    endTime?: number;
    /**
     * Determines if a given task should be cacheable.
     */
    cache?: boolean;

@tom-sherman
Copy link
Author

Time to create the artifact (time to execute build / lint / test)

Yes, that's right I think. See https://github.com/vercel/remote-cache/tree/main/packages/remote#store-artifact

duration is the compute time to create the artifact in milliseconds

Passing an array of tasks should do it 👍

@NiklasPor
Copy link
Owner

@tom-sherman tasks are available starting at version 17.1.0

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

No branches or pull requests

2 participants