Commit Graph

99 Commits

Author SHA1 Message Date
E.G f4bd7689a3
[2.x] test: Migrate FileInfoSpec.scala to verify.BasicTestSuite (#8544)
* test: Migrate FileInfoSpec.scala to verify.BasicTestSuite (#8542)

Migrate FileInfoSpec.scala from ScalaTest's AnyFlatSpec to
verify.BasicTestSuite, following the pattern established by other
test files in the util-cache module.

Changes:
- Replace AnyFlatSpec class with BasicTestSuite object
- Convert 'it should ... in' syntax to 'test(...)' syntax
- Use Scala 3 syntax with colon indentation
- Change === to == for assertions (BasicTestSuite style)
- Add explicit Unit return types for consistency
- Add 'end FileInfoSpec' marker

Fixes #8542
2026-01-15 22:19:30 -05:00
E.G 0afc624009
[2.x] test: Migrate SingletonCacheSpec.scala to verify.BasicTestSuite (#8546)
Migrate SingletonCacheSpec.scala from ScalaTest's AnyFlatSpec to
verify.BasicTestSuite, following the pattern established by other
test files in the util-cache module.

Changes:
- Replace AnyFlatSpec class with BasicTestSuite object
- Convert 'should ... in' syntax to 'test(...)' syntax
- Use Scala 3 syntax with colon indentation
- Change === to == for assertions (BasicTestSuite style)
- Replace intercept[Exception] with scala.util.Try pattern
- Add 'end SingletonCacheSpec' and 'end ComplexType' markers

Related to the ongoing test migration effort.

Co-authored-by: GlobalStar117 <GlobalStar117@users.noreply.github.com>
2026-01-15 14:09:25 -05:00
azdrojowa123 106b8b9978
[2.x] Always create symlinks to the cache in the target locations #8445 (#8461)
CI / test (temurin, 11, 10, ubuntu-latest) (push) Waiting to run Details
CI / test (temurin, 11, 10, windows-latest) (push) Waiting to run Details
CI / test (temurin, 11, 11, ubuntu-latest) (push) Waiting to run Details
CI / test (temurin, 21, 1, ubuntu-22.04) (push) Waiting to run Details
CI / test (zulu, 25, 3, ubuntu-latest) (push) Waiting to run Details
CI / test (zulu, 25, 4, ubuntu-latest) (push) Waiting to run Details
CI / test (zulu, 25, 5, ubuntu-latest) (push) Waiting to run Details
CI / test (zulu, 25, 7, ubuntu-latest) (push) Waiting to run Details
CI / test (zulu, 8, 2, ubuntu-latest) (push) Waiting to run Details
Client Test / test (temurin, 17, macos-latest) (push) Waiting to run Details
Client Test / test (zulu, 8, ubuntu-latest) (push) Waiting to run Details
Client Test / test (zulu, 8, windows-latest) (push) Waiting to run Details
Submit Dependency Graph / Submit Dependency Graph (push) Waiting to run Details
Server Test / test (push) Waiting to run Details
* always create symlinks to the cache in the target locations, even if the digest matches #8445
* create a test (currently failing even on #develop) that fails because if `zipPath` in `sbt.util.ActionCache.packageDirectory` is a symlink to the CAS, in later calls, this path in the CAS gets overridden by the new sources.

- in this test, after "run 1" in line 15, the produced file "target/out/jvm/scala-3.7.4/a/classes.sbtdir.zip" is a symlink to the CAS, let's call it SH1.
- when "run 3" is executed, `IO.zip` saves the new value to `zipPath`, which is "target/out/jvm/scala-3.7.4/a/classes.sbtdir.zip -> SH1", so SH1 gets overridden.
- when the last "run 1" is executed, the cache retrieves SH1, but it contains the data from "run 3" (the test fails with "actual A.x is 3").

* when packaging a directory into a zip, use a temp directory to avoid overwriting the cache #8461
2026-01-12 19:38:59 -05:00
MkDev11 fe6125d8d1
[2.x] feat: Cache failed compilation to avoid repeated failures (#8490)
When a compilation fails with CompileFailed, the failure is now cached
so that subsequent builds with the same inputs don't re-run the failed
compilation. This significantly improves the experience when using BSP
clients like Metals that may trigger many compilations in a row.

The implementation:
- Adds CachedCompileFailure, CachedProblem, and CachedPosition types
  to serialize compilation failures
- Modifies ActionCache.cache to catch CompileFailed exceptions and
  store them in the cache with exitCode=1
- On cache lookup, checks for cached failures first and re-throws
  the cached exception if found
- Fixes DiskActionCacheStore.put to preserve exitCode from request
- Adds unit test to verify cached failure behavior

Fixes #7662
2026-01-12 16:03:05 -05:00
MkDev11 985cf94bb7
fix: Only disable symlinks when truly not supported (#8479)
CI / test (temurin, 11, 10, ubuntu-latest) (push) Waiting to run Details
CI / test (temurin, 11, 10, windows-latest) (push) Waiting to run Details
CI / test (temurin, 11, 11, ubuntu-latest) (push) Waiting to run Details
CI / test (temurin, 21, 1, ubuntu-22.04) (push) Waiting to run Details
CI / test (zulu, 25, 3, ubuntu-latest) (push) Waiting to run Details
CI / test (zulu, 25, 4, ubuntu-latest) (push) Waiting to run Details
CI / test (zulu, 25, 5, ubuntu-latest) (push) Waiting to run Details
CI / test (zulu, 25, 7, ubuntu-latest) (push) Waiting to run Details
CI / test (zulu, 8, 2, ubuntu-latest) (push) Waiting to run Details
Client Test / test (temurin, 17, macos-latest) (push) Waiting to run Details
Client Test / test (zulu, 8, ubuntu-latest) (push) Waiting to run Details
Client Test / test (zulu, 8, windows-latest) (push) Waiting to run Details
Submit Dependency Graph / Submit Dependency Graph (push) Waiting to run Details
Server Test / test (push) Waiting to run Details
2026-01-11 13:04:37 -05:00
MkDev11 db06acb31e
test: Migrate CacheSpec to verify.BasicTestSuite (#8474)
Migrate CacheSpec from ScalaTest AnyFlatSpec to verify.BasicTestSuite
following the project's test framework standardization.

Changes:
- Convert class to object extending BasicTestSuite
- Replace ScalaTest 'should/in' syntax with test() method
- Replace fail() with assert(false, message)
- Replace === with ==
- Use Scala 3 indentation-based syntax
- Remove ScalaTest import, add verify.BasicTestSuite import

All tests pass successfully.

Fixes #8466

Generated-by: Cascade (AI pair programmer)
2026-01-11 07:19:22 -05:00
john0030710 3abddf461a Fix side-effect file syncing when using symlink optimization
- Ensure output files are synced even when reading from symlink
- Call findActionResult to get ActionResult for side-effect files
- Maintains performance benefit while ensuring correctness
- Addresses @eed3si9n's concern about tasks generating files on the side
2026-01-10 00:25:59 +01:00
john0030710 08fe019dc0 Use proper exception handling with Exception.nonFatalCatch.opt
- Replace try-catch with Exception.nonFatalCatch.opt for cleaner code
- Follows Scala best practices for non-fatal exception handling
- More functional and idiomatic approach
- Avoids catching fatal exceptions like VirtualMachineError
2026-01-10 00:23:05 +01:00
john0030710 6a63565b0e Improve symlink optimization using FileConverter
- Use config.fileConverter.toPath() instead of string manipulation
- Avoid hardcoded '/' prefix removal
- More robust and maintainable approach
- Fix IO.read() to include UTF-8 charset parameter
2026-01-10 00:20:32 +01:00
john0030710 d998161a6e Fix #8429: Add symlink optimization to ActionCache.get
- Check for symlinked value files before reading AC JSON
- When symlink exists and is valid, read directly from it
- Fallback to original AC file reading if symlink read fails
- Improves performance by avoiding unnecessary AC file reads
- All existing tests pass
2026-01-09 15:11:09 +01:00
Eugene Yokota 7d76f8f33e [2.x] fix: Workaround for NoSuchFileException
**Problem**
In some scripted tests, we've seen NoSuchFileException.

**Solution**
Catch the exceptions related to caching.
2025-12-25 04:38:43 -05:00
Eugene Yokota c8edb171ee [2.x] Adds cleanExpunge command
**Problem**
We might want to clear the disk cache.

**Solution**
This adds cleanExpunge command.
2025-11-22 23:12:18 -05:00
Eugene Yokota 4265b92aa4 perf: Cache content hash of binary files
**Problem**
sha256 is currently a bottleneck for no-op compilation.

**Solution**
This adds a local, in-memory cache of sha256 hashes of binary files
using their timestamp and file size.
The size of the digest cache can be configured using localDigestCacheByteSize,
which is set to 1MB by default.
2025-11-11 15:59:42 -05:00
Matt Dziuban 77ca8ea29a Add test for recovering from invalid JSON in disk cache. 2025-10-07 14:01:38 -04:00
Matt Dziuban c660c56644 Move `IO.read` and `Parser.parseUnsafe` calls inside `try`. 2025-10-07 13:28:10 -04:00
xuwei-k 14b7ddf867 remove redundant `val` modifier 2025-10-06 09:28:27 +09:00
Eugene Yokota 2fa3159f18 Update to Contraband 0.8.0 2025-09-19 00:46:34 -04:00
xuwei-k 708fffa290 delete unused "internal" package code 2025-09-06 19:41:12 +09:00
Eugene Yokota 353ee59cdb fix: Workaround syncFile issue
**Problem**
We get non-deterministic NoSuchFileException.

**Solution**
Catch the exception.
2025-08-21 08:13:49 +02:00
Eugene Yokota be5152dbfb sjson-new 0.14.0-M4 2025-08-15 22:12:06 -04:00
Eugene Yokota 6a7b56a645 Default to cached task
This flips the default `:=` operation to the cached task.
To opt out of the cache, use `Def.uncached(...)` or
mark the key with `@cacheLevel(include = Array.empty)`
2025-06-21 08:54:51 +09:00
Eugene Yokota 3b4547718e Remove deprecated methods 2025-05-11 05:23:41 -04:00
Eugene Yokota 967ecb49bc deps: Scala 3.7.0 2025-05-11 01:30:07 -04:00
xuwei-k fa6daec812 remove unused imports 2025-05-09 16:46:48 +09:00
eugene yokota 4c0ab346a7
Merge pull request #8101 from eed3si9n/wip/scalacoptions
[2.x] Scala compiler plugin support
2025-05-04 01:25:35 -04:00
Eugene Yokota d10e5b6f48 Add test for cache hits 2025-05-02 03:23:29 -04:00
Eugene Yokota 537359eb9b fix: Fix action cache
**Problem**
Action cache is capturing absolute path.

**Solution**
Use virtial path.
2025-04-28 03:16:18 -04:00
xuwei-k 5d660ab8b5 remove unnecessary `case`
- 3ca3633505/rules/src/main/scala/fix/RemoveParameterUntuplingCase.scala
- https://docs.scala-lang.org/scala3/reference/other-new-features/parameter-untupling.html
- https://docs.scala-lang.org/scala3/reference/other-new-features/parameter-untupling-spec.html
2025-02-22 08:48:29 +09:00
xuwei-k da26f3078b use withFilter instead of filter 2025-01-04 09:10:36 +09:00
xuwei-k 13d6626564 update .scalafmt.conf. enforce new scala 3 syntax 2025-01-02 11:25:34 +09:00
xuwei-k d7ec1013da remove unused type params 2025-01-01 18:42:59 +09:00
xuwei-k 2167a72ac3 correspond file name and class name 2025-01-01 16:12:30 +09:00
Eugene Yokota 799bd65ba5 fix: Retry create directory
**Problem**
Files.createDirectories can fail.

**Solution**
Use IO version, which retries.
2024-12-29 03:18:18 -05:00
xuwei-k f11d9d76f0 remove more implicit. use given and using 2024-11-18 14:39:00 +09:00
xuwei-k d193c990d1 remove implicit params. change to using 2024-11-18 06:49:22 +09:00
xuwei-k c5b7038f3a use `given` instead of `implicit val` 2024-11-17 17:35:23 +09:00
Eugene Yokota 56941dac04 refactor: Update Scala 3 syntax 2024-10-27 23:55:30 -04:00
Eugene Yokota 14f7d29afc Contraband 0.7.0 2024-10-27 16:21:18 -04:00
xuwei-k 6bf5b8b30f Update contraband sources 2024-10-18 20:34:44 +09:00
Adrien Piquerez f08f272d23 [2.x] Fix scripted cache tests 2024-09-18 10:28:11 +02:00
eugene yokota 2cb36bcaa8
[2.x] fix: fallback to file copy (#7668)
**Problem**
Disk cache currently uses symbolic links, which won't
work on Windows without the Administrator privileges or
Developer Mode.

**Solution**
This falls back to using file copy.
2024-09-15 13:03:07 -04:00
Eugene Yokota 291778086d findActionResult can return Either 2024-09-12 02:01:28 -04:00
Eugene Yokota 2aba06bb90 Refactor ActionCache to split into smaller functions 2024-09-08 14:42:24 -04:00
Eugene Yokota 721f202ae5 Hermetic incremental test
**Problem**
Current implementation of testQuick depends on the concept of timestamp,
which probably won't work well with the new consistent analysis store or
the idea of remote caching.

**Solution**
This is a step towards cached testing by making the incrementality hermetic
(no longer depends on the timestamp). Instead this calculates the aggregated
SHA-256 of the class files involved in the test.
2024-09-08 12:50:45 -04:00
Eugene Yokota d6a65d71e0 Set dirzip to 2010 timestamp 2024-08-21 02:43:36 -04:00
Eugene Yokota c9e5924b09 Implement on after sync event
When the disk cache syncs dirzip file, it compares the
item hashes against the existing files, and synchronizes them
using the disk cache.
2024-08-18 12:57:29 -04:00
Eugene Yokota 987ab5f214 Add Def.declareOutputDirectory function 2024-08-18 12:57:29 -04:00
Eugene Yokota c8ddbaed0e Implement InternalActionResult 2024-08-18 12:57:29 -04:00
Eugene Yokota fbd1fb8398 Check the digest during sync
**Problem**
Currently `syncBlobs` delete the existing files in the out directory when remote cache kicks in.

**Solution**
1. This refactors `Digest(...)` and adds support for `Digest.apply(Path)` and `Digest.sameDigest(...)`
2. This uses the `sameDigest` to compare the digest and replace the existing out files only when it needs to
2024-08-13 02:39:12 -04:00
Eugene Yokota c81d269ed2 Merge branch '1.10.x' into wip/merge-1.10.x 2024-05-07 04:39:25 -04:00