folke / ultra-runner

🏃⛰ Ultra fast monorepo script runner and build tool
https://www.npmjs.com/package/ultra-runner
Apache License 2.0
1.2k stars 32 forks source link

Ultra runner --build feature doesn't work in CI environments when non tracked files are downloaded from cache #158

Closed remorses closed 3 years ago

remorses commented 3 years ago

I want to use ultra runner to have faster CI pipelines, only rebuilding changed packages

Ultra runner uses the ultra.cache.json files to detect when something changed, to detect if a non tracked file changes it compares it with the last modified timestamp from the json file.

This doesn't work in the CI because downloading the cache will modify the last modified timestamp.

In my opinion we shouldn't check the last modified timestamp of non tracked files, we should only check that they exist.

We can do this removing the --directory argument from the git ls-files command and not doing the last modified time check.

Removing the --directory argument from the ls-files produces output like this

+ artifacts/file.js
+ artifacts/file.d.ts
- artifacts/
normal_file.js

I can work on a PR if you agree

folke commented 3 years ago

that would probably break a couple of cases.

The most obvious I can think of, would be if you update a package which changes node-modules.

If we only check that the file exists, a new build would not be triggered if the package update only changes existing files.

Unless I'm misunderstanding something here?

The following issue might also be relevant: https://github.com/folke/ultra-runner/issues/101#issuecomment-639005917

remorses commented 3 years ago

Another solution would be to check if the artifacts last modified time is the same as the ultra.cache.json file, this would mean that they have been downloaded together from CI cache and that the artifacts content is up to date with the last ultra run

This would be done only behind a flag obviously, what do you think? Can i open a PR for this?

remorses commented 3 years ago

I tired redoing this in an isolated repository on gitlab here and it works, the problem was probably the custom runner that downloads from S3

The fact that ultra works with CI cache out of the box is super cool, what an awesome tool 😍

folke commented 3 years ago

@remorses well thank you sir 😅