hynek / setup-cached-uv

Use uv in GitHub Actions by adding one line to the workflow.
MIT License
54 stars 2 forks source link

Cache not restored on Windows job #12

Closed pawamoy closed 4 days ago

pawamoy commented 1 month ago
Run hynek/setup-cached-uv@v2
Run irm https://astral.sh/uv/install.ps1 | iex
Downloading uv 0.2.33 (x86_64-pc-windows-msvc)
Installing to C:\Users\runneradmin\.cargo\bin
  uv.exe
  uvx.exe
everything's installed!
Run echo "UV_CACHE_DIR=/tmp/scu-uv-cache" >>$GITHUB_ENV
Run echo "DATE_CACHE_SUFFIX=-$(date +%V)" >>$GITHUB_ENV
Run actions/cache@v4
Cache not found for input keys: uv-Windows-ci-tests-31
Run gacts/run-and-post-run@4683764dd706df847f57b9bed39d08164bcd2690

Is Windows supported :relaxed:?

In the same workflow, you can check that the cache was correctly restored in both Linux and MacOS jobs.

pawamoy commented 1 month ago

I see this warning in Post Setup uv:

Warning: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.

hynek commented 1 month ago

hm this is annoying because it totally worked for me – I specifically looked at this: https://github.com/hynek/setup-cached-uv/actions/runs/10108588847/job/27954818080#step:7:5

this is the same opaque error I got when I couldn’t access the cache path before moving it to /tmp. I suppose /tmp is not allowlisted on Windows either (now?) and we’ll have to look for another path?

pawamoy commented 1 month ago

Happy to try any idea you get!

hynek commented 1 month ago

Hail Mary… @webknjaz any idea what would be the best practice here?

webknjaz commented 1 month ago

I think, this might be happening because @pawamoy uses a different shell value than you @hynek have:

-  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
+  shell: C:\Program Files\Git\bin\bash.EXE --noprofile --norc -e -o pipefail {0}

*(https://github.com/hynek/setup-cached-uv/actions/runs/10108588847/job/27954818080#step:4:4 vs. https://github.com/pawamoy/yore/actions/runs/10237910335/job/28321784155#step:5:3)

This action is running the uv install under Powershell: https://github.com/pawamoy/yore/actions/runs/10237910335/job/28321784155#step:4:19.

@pawamoy's workflow sets bash globally: https://github.com/pawamoy/yore/actions/runs/10237910335/workflow#L11. But that doesn't influence what the action does internally.

Not sure what can be done to mitigate this. Perhaps, there could be an input that helps the action decide whether to use some other bootstrap script…

P.S. I remember that bash under Windows also had quirks (as in, they might have two versions of it), forcing me to resort to despicable hacks: https://github.com/re-actors/checkout-python-sdist/blob/1f86110/action.yml#L50-L53.

pawamoy commented 1 month ago

I don't even remember why I'm setting Bash as shell globally, but I'd bet it's because of the annoying operating system indeed.

hynek commented 1 month ago

OK, is there a take-away for me here? 😅

webknjaz commented 2 weeks ago

I suppose I'd consult with the uv folks or provided a way for the end-users to choose a different installation script, if that works. This might as well be a bug in uv not matching forward and back slashes..

hynek commented 1 week ago

Given #15, I think the problem is actually simpler and it’s just that I can’t access certain directories from an action in a workflow of another project. :(

webknjaz commented 1 week ago

I can't imagine that being the case, honestly..

hynek commented 1 week ago

How else would you explain https://github.com/omnilib/aioitertools/actions/runs/10660169548/job/29543776223?pr=193#step:12:5? I've had different behavior between an action's CI and a user's CI many times, so I wouldn't be shocked.

hynek commented 1 week ago

looks like Astral has published their own action and I don't think there's a point in competing with them so maybe check them out and see if it works over there: https://github.com/astral-sh/setup-uv

webknjaz commented 1 week ago

How else would you explain omnilib/aioitertools/actions/runs/10660169548/job/29543776223?pr=193#step:12:5? I've had different behavior between an action's CI and a user's CI many times, so I wouldn't be shocked.

Dunno. Restart that job in debug mode to expose what's actually happening.

looks like Astral has published their own action

Fair, wonder if it breaks for them too.

hynek commented 4 days ago

fixed by #16