Skip to content

Sbt dependency cache key is calculated incorrectly, causing slowness & inconsistent run times #477

Closed
@Dogacel

Description

@Dogacel

Description:
Sbt dependency cache key is calculated incorrectly.

Task version:
v3.11.0

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Repro steps:
Run this workfile on some scala project, later modify some scala or sbt file under project/ and compare hashes.

name: Test Hashfiles
on: push

jobs:
  test:
    # Detect which parts of the application has changed. Such as API code, db migrations etc.
    name: Test
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3
        with:
          # arbitrary number to fetch enough number of commits in a PR, instead of whole history.
          fetch-depth: 1000

      - name: Test Before
        shell: bash
        run: echo "${{ hashFiles('**/*.sbt', '**/project/build.properties', '**/project/**.{scala,sbt}') }}"

      - name: Test After
        shell: bash
        run: echo "${{ hashFiles('**/*.sbt', '**/project/build.properties', '**/project/**.scala', '**/project/**.sbt') }}"

In our case, before modification of api/project/Dependencies.scala:

Test Before: 09f3783957f7496e05c5b7618773c57281bfdf1f33f8cb10e94e88579c3e5308
Test After: 74c085d46b2d61ad084b24ff74f0a1f8252fc91a0b72c5aa6717c6639f1494fc

After modification:

Test Before: 09f3783957f7496e05c5b7618773c57281bfdf1f33f8cb10e94e88579c3e5308
Test After: cf44e926587b9345fe8347c6df516a5d6ef95346eb13731bd98634cedf122a4f

As you can see cache is calculated incorrectly.

Expected behavior:
When an sbt or scala file has changed under

Actual behavior:
All sbt and scala files are ignored under **/project/ and this is causing the cache to act slower / inconsistent. I also realized pruning cache was speeding up our CI runs a lot but they were slowing down by time and they were getting slower and slower almost every day.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions