turtlequeue / setup-babashka

github actions for installing borkdude/babashka
Eclipse Public License 1.0
28 stars 4 forks source link

Please document how to cache so that bb is not re-downloaded on each run #15

Open holyjak opened 1 year ago

holyjak commented 1 year ago

I see that every run of the setup action, bb is downloaded anew. It should be possible to cache it.

Actually looking at DeLaGuardo/setup-clojure@10.1 it seems it does cache it itself:

Run DeLaGuardo/setup-clojure@10.1 ... Cache restored successfully Clojure CLI found in cache /opt/hostedtoolcache/ClojureToolsDeps/1.11.1-1208-10-1/x64

so perhaps setup-babashka could do the same? 🙏

nha commented 1 year ago

setup-babashka should also use the cache if available. See:

Is there an indication that this is not working as expected?

liny01-nbsa commented 7 months ago

Hi @nha , Below log is from one of our actions, and it's been running for weeks. And this is from its latest run

image

Looks, it couldn't find any cached version, and downloads bb.

This is the part of action

      - name: Install babashka v1.3.188
        uses: turtlequeue/setup-babashka@v1.5.0
        with:
          babashka-version: '1.3.188'
liny01-nbsa commented 7 months ago

@nha , I use the below snippet to workaround, it looks to work, is it possible that the issue is Windows only?

      - name: Cache Babashka binary (Workaround)
        uses: actions/cache@v4
        id: cache-bb
        with:
          # save-always: true
          path: C:\hostedtoolcache\windows\Babashka\1.3.188\x64
          key: ${{ runner.os }}-bb-1.3.188

      - name: Install babashka v1.3.188
        if: steps.cache-bb.outputs.cache-hit != 'true'
        uses: turtlequeue/setup-babashka@v1.5.0
        with:
          babashka-version: '1.3.188'

      - name: add bb to path
        if: steps.cache-bb.outputs.cache-hit == 'true'
        run: echo "C:\hostedtoolcache\windows\Babashka\1.3.188\x64" >> $env:GITHUB_PATH
nha commented 7 months ago

@liny01-nbsa Thank you for the report, I will look into it. While I do not use Windows myself, it should work all the same. Do I understand correctly that you are using the self-hosted github runner?

liny01-nbsa commented 7 months ago

@nha , no, we are using the hosted runner. windows-latest.

image

nha commented 5 months ago

Please give a try to v1.7.0.

I should also mention that I am not convinced if caching makes a practical difference here because it usually takes about 3 seconds to run the action without caching.

liny01-nbsa commented 5 months ago

@nha , thank you! That is a very interesting point. I don't have access to my workstation now. But from my screenshot, I noticed in about Jan 2024, a non-cached run would take > 1 min.

I will test the new version when I got back.

image

nha commented 5 months ago

Oh interesting. Here is a sample run from the main branch on windows, it took 3s:

Screenshot 2024-04-08 at 15 44 30

https://github.com/turtlequeue/setup-babashka/actions/runs/8510483088/job/23308162033