Compare commits

...

146 commits
0.2.0 ... main

Author SHA1 Message Date
renovate[bot]
30962902d2
chore(deps): update node.js to v24.14.0 (#147)
Some checks failed
CI / setup-bazel (macos) (push) Has been cancelled
CI / setup-bazel (ubuntu) (push) Has been cancelled
CI / setup-bazel (windows) (push) Has been cancelled
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-25 07:27:53 -08:00
Nick Nichols
417f3387fe
Fix syntax error in README.md for disk-cache (#146) 2026-02-23 10:15:09 -08:00
renovate[bot]
887da5f6b9
chore(deps): update node.js to v24.13.1 (#145)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-10 11:04:30 -08:00
renovate[bot]
3217c4f420
fix(deps): update dependency @actions/tool-cache to v4 (#143)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-06 06:49:57 -08:00
renovate[bot]
18fd541ab1
fix(deps): update dependency @actions/core to v3 (#141)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-05 21:43:13 -08:00
renovate[bot]
e74b1abaf7
fix(deps): update dependency @actions/github to v9 (#140)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-05 21:41:13 -08:00
renovate[bot]
3af227a251
chore(deps): update dependency @actions/tool-cache to v3.0.1 (#139)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-05 21:41:05 -08:00
renovate[bot]
c9a2a71272
fix(deps): update dependency @actions/glob to ^0.6.0 (#142)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-05 21:37:59 -08:00
renovate[bot]
09d5e77e57
fix(deps): update dependency @actions/cache to v6 (#144)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-05 21:37:52 -08:00
renovate[bot]
5a2f9a2f05
fix(deps): update dependency @actions/github to v8 (#134)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-26 15:31:48 -08:00
renovate[bot]
bb67c3ebd7
chore(deps): update dependency @actions/cache to v5.0.3 (#133)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-16 06:54:32 -08:00
renovate[bot]
b6a8ab687e
chore(deps): update node.js to v24.13.0 (#132)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-14 18:30:30 -08:00
github-actions
083175551c Release 0.18.0 2026-01-11 16:34:54 +00:00
Michael Vorburger
b607b8f591
Add post-if !cancelled() condition (#128) 2026-01-11 08:33:54 -08:00
Titus Fortner
be4ac32ff6
allow saving cache to be optional (#131) 2026-01-11 08:30:32 -08:00
github-actions
00e306f4a9 Release 0.17.0 2026-01-10 20:28:13 +00:00
Xavier Bonaventura
b26a6f0e11
Fix bazel version not working with disk cache (#119) 2026-01-10 12:27:24 -08:00
renovate[bot]
dbfe7273a9
fix(deps): update dependency @actions/github to v7 (#129)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-08 12:20:35 -08:00
renovate[bot]
1dc7f4819d
fix(deps): update dependency @actions/tool-cache to v3 (#130)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-08 12:20:27 -08:00
Michael Vorburger
82d28f5023
fix: add logging when failing to restore cache (#127)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-08 11:48:02 -08:00
Michael Vorburger
1bf89734c9
docs: add missing initial "npm install" to Development on README (#126) 2026-01-08 11:46:54 -08:00
renovate[bot]
e820d6a037
chore(deps): update dependency @actions/cache to v5.0.2 (#123)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-08 09:27:50 -08:00
renovate[bot]
66d3c1cddb
chore(deps): update dependency @actions/core to v2.0.2 (#124)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-08 09:27:28 -08:00
Michael Vorburger
271e4c2614
fix: Improve error handling in restoreCache (fixes #120) (#122)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-08 09:25:30 -08:00
github-actions
43d7d5ceab Release 0.16.0 2025-12-16 16:03:21 +00:00
Karthik Sethuraman
905421c656
allow a list of files for repositoryCacheConfig (#117)
---------
Co-authored-by: Karthik Sethuraman <ksethuraman@linkedin.com>
2025-12-16 08:02:30 -08:00
renovate[bot]
5528b8082a
Update dependency @actions/cache to v5 (#115)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-12 08:02:25 -08:00
renovate[bot]
39aba44572
Update dependency @actions/core to v2 (#113)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-12 08:01:32 -08:00
renovate[bot]
51f283a17f
Update Node.js to v24.12.0 (#114)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-12 08:01:26 -08:00
Leo Contreras
7594e1b588
Pulling of external-cache parallellized (#110) 2025-12-04 07:26:59 -08:00
renovate[bot]
1ff8ab47ae
Update Node.js to v24 (#106)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-04 07:15:14 -08:00
renovate[bot]
6fe279591f
Update actions/checkout action to v6 (#109)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-04 07:14:46 -08:00
renovate[bot]
81ef0d9acc
Update dependency yaml to v2.8.2 (#112)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-04 07:14:32 -08:00
renovate[bot]
4432ac8a23
Update actions/setup-node action to v6 (#104)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-14 06:42:37 -07:00
renovate[bot]
2fab424f7c
Update dependency @vercel/ncc to v0.38.4 (#99)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-30 08:35:48 -07:00
renovate[bot]
798f81ecfc
Update Node.js to v22.20.0 (#103)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-30 08:35:44 -07:00
renovate[bot]
22f06fe4d3
Update dependency @actions/cache to v4.1.0 (#102)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-30 08:35:31 -07:00
renovate[bot]
812c6371ef
Update actions/setup-node action to v5 (#98)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-08 13:37:26 -07:00
renovate[bot]
f22529d52b
Update Node.js to v22.19.0 (#97)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-31 07:45:02 -07:00
renovate[bot]
b1c5ac5231
Update actions/checkout action to v5 (#95)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-11 09:08:54 -07:00
renovate[bot]
b02abd0245
Update dependency @actions/cache to v4.0.5 (#94)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-08 08:49:06 -07:00
renovate[bot]
ec193958e9
Update Node.js to v22.18.0 (#93)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-05 07:15:59 -07:00
renovate[bot]
25ec8ddd82
Update dependency yaml to v2.8.1 (#92)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-05 07:15:51 -07:00
Malte Poll
54c9086be8
Include architecture in cache key (#91)
Otherwise, running tests on macos-13 and macos-15 uses the same cache key for Intel and Apple Silicon.

Note: I had some trouble regenerating the `dist` without introducing huge changes in the output. For that reason I skipped updating `index.js.map`.
2025-08-05 06:42:41 -07:00
renovate[bot]
20a70d3f31
Update Node.js to v22.17.1 (#89) 2025-07-16 14:08:46 -07:00
renovate[bot]
4d8cee1d8a
Update dependency @actions/github to v6.0.1 (#85) 2025-06-28 08:04:16 -07:00
renovate[bot]
3d67a4f0cf
Update dependency yaml to v2.8.0 (#86) 2025-06-28 08:04:02 -07:00
renovate[bot]
976e823acb
Update Node.js to v22.17.0 (#87) 2025-06-28 08:01:54 -07:00
github-actions
4fd964a13a Release 0.15.0 2025-05-27 15:16:11 +00:00
Alex Rodionov
40aa0be72e
Co-locate Bazel output base with workspace (#82)
Fixes #81
2025-05-27 08:15:10 -07:00
kekxv
f26390261c
Add .exe on windows (#83) 2025-05-27 08:07:41 -07:00
Alex Rodionov
14421f585a
Revert "Update actions/cache version to 4.2.2 to resolve caching warning pack…" (#80)
This reverts commit 9ccf8a2650.
2025-04-28 09:44:58 +09:00
Yaxiong Zhao
9ccf8a2650
Update actions/cache version to 4.2.2 to resolve caching warning package.json (#79) 2025-04-24 20:33:17 +09:00
renovate[bot]
c46b5ab465
Update dependency @actions/cache to v4.0.3 (#74)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-19 11:49:23 +01:00
renovate[bot]
f3b2b002ba
Update dependency @actions/cache to v4.0.2 (#70)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-26 07:01:57 -08:00
github-actions
e8776f58fb Release 0.14.0 2025-02-21 15:20:26 +00:00
Caleb Zulawski
e0e802d0ce
Add module-root option for changing module location within the repository (#69) 2025-02-21 07:17:33 -08:00
renovate[bot]
98248079ae
Update dependency @actions/cache to v4.0.1 (#66)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-14 13:04:08 -08:00
renovate[bot]
bb67a55494
Update Node.js to v22.14.0 (#65)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-11 10:51:51 -08:00
github-actions
663f88d97a Release 0.13.0 2025-01-24 22:04:41 +00:00
Brett McLarnon
bc949b7ed4
Include repository cache files in the disk cache key. (#64)
Like BUILD file changes, changes to workspace dependencies can
significantly affect the contents of the disk cache. Prior to this
change, upreving dependencies wasn't itself sufficient to update the
disk cache, resulting in repeatedly rebuilding dependencies until some
subsequent commit happened to modify BUILD files.
2025-01-24 14:03:38 -08:00
renovate[bot]
30f539412d
Update Node.js to v22.13.1 (#63)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-21 13:21:18 -08:00
renovate[bot]
768017f3c7
Update dependency @actions/tool-cache to v2.0.2 (#62)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-16 06:48:32 -08:00
renovate[bot]
6cabfc01da Update Node.js to v22.13.0 2025-01-07 14:28:19 -08:00
github-actions
529dbc2648 Release 0.12.1 2025-01-07 22:27:12 +00:00
Alex Rodionov
104a0a36a0 Fix regression with missing token
Closes #59
2025-01-07 14:25:12 -08:00
github-actions
c50333a369 Release 0.12.0 2025-01-05 23:09:59 +00:00
Philipp Stephani
451432a104 Enable caches for all Bazel commands, not just build-related ones.
Caching applies to all commands,
cf. https://bazel.build/versions/8.0.0/reference/command-line-reference#flag--disk_cache.
2025-01-05 15:09:17 -08:00
github-actions
465f1612ad Release 0.11.0 2025-01-05 22:57:32 +00:00
Alex Rodionov
438b351914 Export BAZELISK_GITHUB_TOKEN variable
Fixes #57
2025-01-05 14:55:26 -08:00
renovate[bot]
99f63cfeed Update dependency yaml to v2.7.0 2024-12-31 13:00:28 -08:00
github-actions
bbf8fe8b21 Release 0.10.0 2024-12-21 00:30:08 +00:00
Alex Rodionov
0f9296f333 Allow changing output base path 2024-12-20 16:28:37 -08:00
renovate[bot]
89b8ef0f1d
Update dependency @actions/cache to v4 (#53)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-05 09:39:11 +03:00
renovate[bot]
fda5cfcc5a
Update Node.js to v22.12.0 (#52)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-04 10:08:40 +03:00
renovate[bot]
8d0361d6cf
Update dependency yaml to v2.6.1 (#51)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-19 11:33:03 -08:00
renovate[bot]
3e48ddd52f
Update dependency @vercel/ncc to v0.38.3 (#50)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-15 07:02:24 -08:00
renovate[bot]
0acdc344dc
Update dependency @actions/cache to v3.3.0 (#49)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-01 21:41:41 -07:00
github-actions
f3f50ea679 Release 0.9.1 2024-10-30 21:49:27 +00:00
Andy Aylward
2ebddb28d9
Use process.env.RUNNER_TEMP instead of os.tmpdir() (#47) 2024-10-30 14:16:51 -07:00
renovate[bot]
93a72482ba
Update Node.js to v22 (#45)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-29 14:26:45 -07:00
renovate[bot]
3736b3b360
Update dependency yaml to v2.6.0 (#43)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-13 11:23:47 -07:00
renovate[bot]
b136f2f9d4
Update dependency @actions/core to v1.11.1 (#41)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-08 13:08:31 -07:00
renovate[bot]
41b624e715
Update dependency node to v20.18.0 (#40)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-03 13:36:30 -07:00
renovate[bot]
f02085cc85
Update dependency @actions/core to v1.11.0 (#39)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-02 13:06:25 -07:00
github-actions
90b3523338 Release 0.9.0 2024-09-23 19:51:05 +00:00
renovate[bot]
e49447a08d
Update dependency @vercel/ncc to v0.38.2 (#38)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-23 12:50:18 -07:00
Chris Gray
5d804ff512
Add a process.exit after storing caches (#37)
Fixes #36
2024-09-23 12:50:02 -07:00
renovate[bot]
0d27eba2b7
Update dependency yaml to v2.5.1 (#35)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-04 13:00:36 -07:00
renovate[bot]
735c9d1fec
Update dependency node to v20.17.0 (#34)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-21 11:25:34 -07:00
renovate[bot]
101c7f5cf1
Update dependency @actions/glob to ^0.5.0 (#33)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-15 21:58:50 -07:00
renovate[bot]
a125380b35
Update dependency node to v20.16.0 (#32)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-24 08:00:56 -07:00
renovate[bot]
d4889c5698
Update dependency yaml to v2.5.0 (#31)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-24 08:00:46 -07:00
renovate[bot]
812d05bd7b
Update dependency node to v20.15.1 (#30) 2024-07-13 17:18:46 -07:00
renovate[bot]
121a042b5d
Update dependency node to v20.15.0 (#29)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-21 07:09:32 -07:00
renovate[bot]
330cba8289
Update dependency yaml to v2.4.5 (#27)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-08 15:53:55 -07:00
renovate[bot]
0fa4d31c00
Update dependency yaml to v2.4.4 (#26)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-08 12:57:17 -07:00
github-actions
e403ad5071 Release 0.8.5 2024-06-04 13:57:06 +00:00
Mark Szabo
a948e3e824
Set octokit's baseUrl explicitly (#24) 2024-06-04 06:56:06 -07:00
renovate[bot]
a70df706fa
Update dependency yaml to v2.4.3 (#22)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-02 06:59:43 -07:00
renovate[bot]
363eb36ada
Update dependency node to v20.14.0 (#20)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-28 12:58:21 -07:00
github-actions
f92f4331c7 Release 0.8.4 2024-05-20 20:44:47 +00:00
Alex Rodionov
c4b6956617 Fix release workflow tag creation 2024-05-20 13:44:06 -07:00
github-actions
57947c1f02 Release 0.8.3 2024-05-20 20:31:25 +00:00
Alex Rodionov
06441bbdcd
Make bazelisk in a tool cache available in the PATH (#19)
Fixes #17
2024-05-20 13:30:16 -07:00
renovate[bot]
67f0a68f0e
Update dependency node to v20.13.1 (#16)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-10 20:58:51 -07:00
renovate[bot]
78f3ff98e3
Update dependency node to v20.13.0 (#15)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-07 11:30:08 -07:00
renovate[bot]
155526ac0d
Update dependency yaml to v2.4.2 (#14)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-28 11:24:09 -07:00
Alex Rodionov
6e5145c6a9 Update version before release 2024-04-13 20:28:40 -05:00
github-actions
9676c3194c Release 0.8.2 2024-04-12 18:01:48 +00:00
Alex Rodionov
f5feac6e9d Improve release workflow 2024-04-12 13:00:43 -05:00
Alex Rodionov
7d9487bea5 Draft release workflow 2024-04-12 12:15:08 -05:00
renovate[bot]
c776e115ed
Update dependency node to v20.12.2 (#12)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-10 15:10:57 -05:00
Alex Rodionov
10af16b874 Rename action 2024-03-20 11:40:35 -07:00
Alex Rodionov
b388b84bb6 Release 0.8.1 2024-03-13 10:31:00 -07:00
Alex Rodionov
c033bc050f
Don't follow symlinks when hashing cache files (#10)
Fixes performance regression in 2eb83dc753
2024-03-13 10:28:27 -07:00
Alex Rodionov
1cc0c15a80 Transfer to bazel-contrib 2024-03-11 08:25:23 -07:00
renovate[bot]
2e3586828e
Update dependency @vercel/ncc to ^0.38.0 (#8)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-10 10:40:59 -07:00
renovate[bot]
8b1f4bfa4d
Update dependency yaml to v2.4.1 (#9)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-10 10:40:50 -07:00
Alex Rodionov
b7383df9e2
Fix version in package.json (#7) 2024-03-09 11:12:39 -08:00
renovate[bot]
c423f000c1
Update dependency @actions/cache to v3.2.4 (#4)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-09 11:09:32 -08:00
renovate[bot]
6632e95245
Update dependency node to v20.11.1 (#5)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-09 11:07:55 -08:00
renovate[bot]
ef5b98eedd
Add renovate.json (#3)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-09 11:06:24 -08:00
Alex Rodionov
abf706cba9 Release 0.8.0 2024-03-05 15:51:47 -08:00
Alex Rodionov
5058960dd0 Support passing files to hash in repository-cache 2024-03-05 14:25:19 -08:00
Alex Rodionov
527d41d462 Release 0.7.1 2024-03-01 11:15:47 -08:00
Alex Rodionov
2eb83dc753 Fix file hashing when saving cache 2024-03-01 11:13:42 -08:00
Alex Rodionov
c7b4d0412f Release 0.7.0 2024-02-29 17:53:15 -08:00
Alex Rodionov
1428e4eb46 Support bzlmod 2024-02-26 10:58:05 -08:00
Alex Rodionov
fcc0a6a0df Add how-to build instruction 2024-02-26 10:57:57 -08:00
Alex Rodionov
8b3d6f9169 Add better examples in README 2024-02-26 10:55:32 -08:00
Alex Rodionov
299d048546 Remove no-op configuration example
Fixes #2
2024-02-25 16:47:09 -08:00
Alex Rodionov
0565e39cc0 Update version to 0.6.0 2024-02-13 08:59:38 -08:00
Alex Rodionov
8b62d10a25 Update to NodeJS 20 2024-02-13 06:22:58 -08:00
Alex Rodionov
42a3e0dfad Release 0.5.0 2024-02-07 06:38:33 -08:00
Alex Rodionov
14997dcb06 Support bazelisk-version input
Also adds instruction on how to migrate from bazelbuild/setup-bazelisk
2024-02-07 06:24:11 -08:00
Alex Rodionov
1ee945be88 Add basic CI check 2024-02-07 06:24:11 -08:00
Alex Rodionov
e2ceb8f4c3 Release 0.4.0 2024-01-18 11:57:13 -08:00
Alex Rodionov
fb0c8c5285 Allow to disable specific external caches 2024-01-18 11:56:04 -08:00
Alex Rodionov
bf3d4ffc18 Release 0.3.2 2023-11-26 17:12:33 -08:00
Alex Rodionov
54203cbc41 Fix regression in gathering folder size 2023-11-26 17:11:31 -08:00
Alex Rodionov
b322095c95 Release v0.3.1 2023-11-26 14:37:11 -08:00
Alex Rodionov
c507aa075e Ignore errors when gathering file size 2023-11-26 13:07:54 -08:00
Alex Rodionov
561ddfa28f Update dependencies 2023-11-24 13:36:42 -08:00
Alex Rodionov
d23b2a7513 Write homerc both to USERPROFILE and HOME on Windows 2023-04-27 07:38:12 -07:00
Alex Rodionov
3e0beb3116 Clean up documentation 2023-03-04 11:54:46 -08:00
18 changed files with 172238 additions and 111943 deletions

25
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,25 @@
name: CI
on:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
setup-bazel:
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os:
- macos
- ubuntu
- windows
steps:
- uses: actions/checkout@v6
- uses: ./
- if: failure() && runner.debug == '1'
uses: mxschmitt/action-tmate@v3

37
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,37 @@
name: Release
run-name: Release ${{ inputs.tag }}
on:
workflow_dispatch:
inputs:
tag:
description: Tag to release
required: true
default: 0.1.0
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
cache: npm
node-version-file: package.json
- run: |
sed -ri 's/"version": ".+"/"version": "${{ inputs.tag }}"/' package.json
sed -ri 's/setup-bazel@.+$/setup-bazel@${{ inputs.tag }}/g' README.md
- run: npm install
- run: npm run build
- run: |
git config user.name github-actions
git config user.email github-actions@github.com
- run: git commit -am "Release ${{ inputs.tag }}"
- run: git push
- run: git tag -a ${{ inputs.tag }} -m "Release ${{ inputs.tag }}"
- run: git push --tags
- run: gh release create ${{ inputs.tag }} --generate-notes
env:
GH_TOKEN: ${{ github.token }}

View file

@ -1 +1 @@
nodejs 16.15.0
nodejs 24.14.0

292
README.md
View file

@ -1,8 +1,21 @@
# setup-bazel
This action allows to properly configure Bazel on all supported operating systems
This action allows to properly configure Bazelisk and Bazel on all operating systems
and provides an advanced fine-grained caching to improve workflows performance.
## Usage
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
```
## Inputs
### `bazelisk-cache`
@ -11,12 +24,89 @@ Cache [`bazelisk`][1] downloads based on contents of a `.bazelversion` file.
Default `false`.
### `bazelisk-version`
[`bazelisk`][1] version to download and use.
Supports semver specification and ranges.
Leave empty to use [pre-installed Bazelisk][8].
Default `""`.
<details>
<summary>Examples</summary>
#### Install Bazelisk 1.x
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
bazelisk-version: 1.x
```
#### Install exact Bazelisk version
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
bazelisk-version: 1.19.0
```
</details>
### `bazelrc`
Extra contents to write to a user's [`bazelrc`][4] file.
You can use multiline YAML strings.
Default `""`.
<details>
<summary>Examples</summary>
#### Enable Bzlmod
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
bazelrc: common --enable_bzlmod
```
#### Add colors and timestamps
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
bazelrc: |
build --color=yes
build --show_timestamps
```
</details>
### `cache-save`
Whether to save caches at the end of the workflow.
Set to `false` for pull requests to allow cache restoration without saving,
which prevents PRs from polluting the cache while still benefiting from it.
Default `true`.
<details>
<summary>Examples</summary>
#### Disable cache saving on pull requests
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
cache-save: ${{ github.event_name != 'pull_request' }}
```
</details>
### `disk-cache`
Enable [`disk_cache`][2] and store it on GitHub based on contents of `BUILD` files.
@ -25,77 +115,183 @@ You can also pass a string to use as a cache key to separate caches from differe
Default `false`.
<details>
<summary>Examples</summary>
#### Share a single disk cache
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
disk-cache: true
```
#### Separate disk caches between workflows
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
disk-cache: ${{ github.workflow }}
```
</details>
### `external-cache`
Cache `external/` repositories based on contents of a `WORKSPACE` file.
Cache `external/` repositories based on contents of `MODULE.bazel` and `WORKSPACE` files.
Only repositories exceeding 10MB are being cached.
Each repository is stored in a separate cache.
You can also pass a YAML object where key is the name of the external repository
and value is the list of files which contents are used to calculate cache key.
You can also pass a `manifest` object where key is the name of the external repository
and value is a file (or list of files) which contents are used to calculate cache key.
If the value is `false`, the external repository won't be cached.
Default `false`.
<details>
<summary>Examples</summary>
#### Enable external repositories caches
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
external-cache: true
```
#### Cache NPM repositories based on `package-lock.json` contents
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
external-cache: |
manifest:
npm: package-lock.json
```
#### Do not cache Ruby on Windows
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
external-cache: |
manifest:
ruby: ${{ runner.os == 'Windows' && 'false' || 'true' }}
```
</details>
### `google-credentials`
Google Cloud account key to use for [remote caching authentication][9].
Default `""`.
<details>
<summary>Examples</summary>
#### Authenticate via key
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
google-credentials: ${{ secrets.GOOGLE_CLOUD_KEY }}
```
</details>
### `module-root`
Bazel module root directory, where `MODULE.bazel` and `WORKSPACE` is found.
Change this value to the module root if it's not the repository root.
Default `"."`.
### `output-base`
Change Bazel output base directory.
You might want to change it when running on self-hosted runners with a custom directory layout.
Default is one of the following:
- `$HOME/.bazel` on Linux and macOS
- `D:/_bazel` on Windows
<details>
<summary>Examples</summary>
#### Use `C` drive letter
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
output-base: C:/_bazel
```
</details>
### `repository-cache`
Enable [`repository_cache`][3] and store it on GitHub based on contents of a `WORKSPACE` file.
Enable [`repository_cache`][3] and store it on GitHub based on contents of `MODULE.bazel` and `WORKSPACE` files.
You can also pass a file (or list of files) which contents are used to calculate cache key.
Default `false`.
### `token`
<details>
<summary>Examples</summary>
GitHub API token used by `external-cache` to fetch all available caches.
Not used when external cache is disabled.
#### Store a single repository cache
Default [`${{ github.token }}`][5].
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
repository-cache: true
```
## Examples
#### Store a repository cache from a custom location
### Simple configuration
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
repository-cache: examples/gem/WORKSPACE
```
```yaml
- uses: p0deje/setup-bazel@0.2.0
#### Store a repository cache from a list of custom locations
```yaml
- uses: bazel-contrib/setup-bazel@0.18.0
with:
repository-cache: |
- MODULE.bazel
- requirements_locked.txt
```
</details>
## Migrating from [`bazelbuild/setup-bazelisk`][6]
You can simply replace `bazelbuild/setup-bazelisk` action with `bazel-contrib/setup-bazel`.
However, if you used a `bazel-version` input before, you will need to remove it in favor
[other ways to specify Bazel version][7].
## Development
To build action, run the following command:
```sh
$ npm install
$ npm run build
```
### Additional `.bazelrc` options
## Release
```yaml
- uses: p0deje/setup-bazel@0.2.0
with:
bazelrc: |
build --show_timestamps
```
Use [Release][10] workflow to cut a new release.
### Full caching enabled
```yaml
- uses: p0deje/setup-bazel@0.2.0
with:
bazelisk-cache: true
disk-cache: true
external-cache: true
repository-cache: true
```
### Separate disk cache between workflows
```yaml
- uses: p0deje/setup-bazel@0.2.0
with:
disk-cache: ${{ github.workflow }}}
```
### Cache external repository based on different files
```yaml
- uses: p0deje/setup-bazel@0.2.0
with:
external-cache: |
manifest:
npm: package-lock.json
```
[1]: https://github.com/bazelbuild/bazelisk
[2]: https://bazel.build/remote/caching#disk-cache
[3]: https://docs-staging.bazel.build/2338/versions/main/guide.html#the-repository-cache
[4]: https://bazel.build/run/bazelrc
[5]: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
[6]: https://github.com/bazelbuild/setup-bazelisk
[7]: https://github.com/bazelbuild/bazelisk/blob/master/README.md#how-does-bazelisk-know-which-bazel-version-to-run
[8]: https://github.com/actions/runner-images/pull/490
[9]: https://bazel.build/reference/command-line-reference#flag--google_credentials
[10]: https://github.com/bazel-contrib/setup-bazel/actions/workflows/release.yml

View file

@ -1,36 +1,57 @@
name: Setup Bazel
name: Setup Bazel environment
description: Setup a Bazel environment, including Bazelisk and fine-grained caching
inputs:
bazelisk-cache:
description: Caches Bazelisk downloads based on .bazelversion
required: false
default: false
default: "false"
bazelisk-version:
description: The Bazelisk version to download and use if necessary
default: ""
bazelrc:
description: Extra contents to write to user .bazelrc
required: false
default: ""
cache-save:
description: Whether to save caches. Set to false for pull requests to allow restores but prevent saves.
required: false
default: "true"
cache-version:
description: Version of all caches
required: false
default: 1
default: "1"
disk-cache:
description: Cache actions outputs based on BUILD
required: false
default: false
default: "false"
external-cache:
description: Cache external 10MB+ repositories based on WORKSPACE
description: Cache external 10MB+ repositories based on MODULE.bazel/WORKSPACE
required: false
default: ""
google-credentials:
description: Google Cloud account key for remote cache
required: false
default: ""
repository-cache:
description: Cache repositories based on WORKSPACE
module-root:
description: Bazel module root directory. Default is `.`
required: false
default: false
default: "."
output-base:
description: Bazel output base directory. Default is $HOME/.cache/bazel (POSIX) or D:/_bazel (Windows)
required: false
default: ""
repository-cache:
description: Cache repositories based on MODULE.bazel/WORKSPACE
required: false
default: "false"
token:
description: GitHub token to query Bazelisk releases
required: false
default: ${{ github.token }}
runs:
using: node16
using: node20
main: dist/main/index.js
post: dist/post/index.js
post-if: "!cancelled()"

View file

@ -4,15 +4,32 @@ const yaml = require('yaml')
const core = require('@actions/core')
const github = require('@actions/github')
const bazeliskVersion = core.getInput('bazelisk-version')
const cacheSave = core.getBooleanInput('cache-save')
const cacheVersion = core.getInput('cache-version')
const externalCacheConfig = yaml.parse(core.getInput('external-cache'))
const moduleRoot = core.getInput('module-root')
const homeDir = os.homedir()
const arch = os.arch()
const platform = os.platform()
let bazelOutputBase = core.getInput('output-base')
if (!bazelOutputBase) {
if (platform === 'win32') {
// check if GITHUB_WORKSPACE starts with D:
if (process.env.GITHUB_WORKSPACE?.toLowerCase()?.startsWith('d:')) {
bazelOutputBase = 'D:/_bazel'
} else {
bazelOutputBase = `C:/_bazel`
}
} else {
bazelOutputBase = `${homeDir}/.bazel`
}
}
let bazelDisk = core.toPosixPath(`${homeDir}/.cache/bazel-disk`)
let bazelRepository = core.toPosixPath(`${homeDir}/.cache/bazel-repo`)
let bazelOutputBase = `${homeDir}/.bazel`
let bazelrcPaths = [core.toPosixPath(`${homeDir}/.bazelrc`)]
let userCacheDir = `${homeDir}/.cache`
switch (platform) {
@ -20,41 +37,57 @@ switch (platform) {
userCacheDir = `${homeDir}/Library/Caches`
break
case 'win32':
bazelDisk = 'D:/_bazel-disk'
bazelRepository = 'D:/_bazel-repo'
bazelOutputBase = 'D:/_bazel'
bazelDisk = `${bazelOutputBase}-disk`
bazelRepository = `${bazelOutputBase}-repo`
userCacheDir = `${homeDir}/AppData/Local`
if (process.env.HOME) {
bazelrcPaths.push(core.toPosixPath(`${process.env.HOME}/.bazelrc`))
}
break
}
const baseCacheKey = `setup-bazel-${cacheVersion}-${platform}`
const baseCacheKey = `setup-bazel-${cacheVersion}-${platform}-${arch}`
const bazelrc = core.getMultilineInput('bazelrc')
const diskCacheConfig = core.getInput('disk-cache')
const diskCacheEnabled = diskCacheConfig !== 'false'
let diskCacheName = 'disk'
if (diskCacheEnabled) {
// Before Bazel 6.3, providing --disk_cache to common is an error,
// with Bazel 6.3 and onwards, common accepts any legal Bazel option
// https://github.com/bazelbuild/bazel/issues/3054
bazelrc.push(`build --disk_cache=${bazelDisk}`)
if (diskCacheName !== 'true') {
diskCacheName = `${diskCacheName}-${diskCacheConfig}`
}
}
const repositoryCacheEnabled = core.getBooleanInput('repository-cache')
const repositoryCacheConfig = yaml.parse(core.getInput('repository-cache'))
const repositoryCacheEnabled = repositoryCacheConfig !== false
let repositoryCacheFiles = [
`${moduleRoot}/MODULE.bazel`,
`${moduleRoot}/WORKSPACE.bazel`,
`${moduleRoot}/WORKSPACE.bzlmod`,
`${moduleRoot}/WORKSPACE`
]
if (repositoryCacheEnabled) {
bazelrc.push(`build --repository_cache=${bazelRepository}`)
bazelrc.push(`common --repository_cache=${bazelRepository}`)
if (repositoryCacheConfig !== true) {
repositoryCacheFiles = Array(repositoryCacheConfig).flat()
}
}
const googleCredentials = core.getInput('google-credentials')
const googleCredentialsSaved = (core.getState('google-credentials-path').length > 0)
if (googleCredentials.length > 0 && !googleCredentialsSaved) {
const tmpDir = core.toPosixPath(fs.mkdtempSync(os.tmpdir()))
const tmpDir = core.toPosixPath(fs.mkdtempSync(process.env.RUNNER_TEMP))
const googleCredentialsPath = `${tmpDir}/key.json`
fs.writeFileSync(googleCredentialsPath, googleCredentials)
bazelrc.push(`build --google_credentials=${googleCredentialsPath}`)
core.saveState('google-credentials-path', googleCredentialsPath)
}
const externalCacheConfig = yaml.parse(core.getInput('external-cache'))
const bazelExternal = core.toPosixPath(`${bazelOutputBase}/external`)
const externalCache = {}
if (externalCacheConfig) {
@ -67,16 +100,21 @@ if (externalCacheConfig) {
externalCache.baseCacheKey = `${baseCacheKey}-external-`
externalCache.manifest = {
files: [
'WORKSPACE.bazel',
'WORKSPACE'
`${moduleRoot}/MODULE.bazel`,
`${moduleRoot}/WORKSPACE.bazel`,
`${moduleRoot}/WORKSPACE.bzlmod`,
`${moduleRoot}/WORKSPACE`
],
name: `external-${manifestName}-manifest`,
path: `${os.tmpdir()}/external-cache-manifest.txt`
}
externalCache.default = {
enabled: true,
files: [
'WORKSPACE.bazel',
'WORKSPACE'
`${moduleRoot}/MODULE.bazel`,
`${moduleRoot}/WORKSPACE.bazel`,
`${moduleRoot}/WORKSPACE.bzlmod`,
`${moduleRoot}/WORKSPACE`
],
name: (name) => { return `external-${name}` },
paths: (name) => {
@ -89,25 +127,32 @@ if (externalCacheConfig) {
for (const name in externalCacheConfig.manifest) {
externalCache[name] = {
enabled: externalCacheConfig.manifest[name] != false,
files: Array(externalCacheConfig.manifest[name]).flat()
}
}
}
const token = core.getInput('token')
core.exportVariable('BAZELISK_GITHUB_TOKEN', token)
module.exports = {
baseCacheKey,
cacheSave,
bazeliskCache: {
enabled: core.getBooleanInput('bazelisk-cache'),
files: ['.bazelversion'],
files: [`${moduleRoot}/.bazelversion`],
name: 'bazelisk',
paths: [core.toPosixPath(`${userCacheDir}/bazelisk`)]
},
bazeliskVersion,
bazelrc,
diskCache: {
enabled: diskCacheEnabled,
files: [
'**/BUILD.bazel',
'**/BUILD'
...repositoryCacheFiles,
`${moduleRoot}/**/BUILD.bazel`,
`${moduleRoot}/**/BUILD`
],
name: diskCacheName,
paths: [bazelDisk]
@ -116,15 +161,15 @@ module.exports = {
paths: {
bazelExternal,
bazelOutputBase: core.toPosixPath(bazelOutputBase),
bazelrc: core.toPosixPath(`${homeDir}/.bazelrc`)
bazelrc: bazelrcPaths
},
os: {
arch,
platform,
},
platform,
repositoryCache: {
enabled: repositoryCacheEnabled,
files: [
'WORKSPACE.bazel',
'WORKSPACE'
],
files: repositoryCacheFiles,
name: 'repository',
paths: [bazelRepository]
},

142190
dist/main/index.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

139009
dist/post/index.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

139
index.js
View file

@ -2,10 +2,12 @@ const fs = require('fs')
const { setTimeout } = require('timers/promises')
const core = require('@actions/core')
const cache = require('@actions/cache')
const github = require('@actions/github')
const glob = require('@actions/glob')
const tc = require('@actions/tool-cache')
const config = require('./config')
async function run () {
async function run() {
try {
await setupBazel()
} catch (error) {
@ -13,32 +15,108 @@ async function run () {
}
}
async function setupBazel () {
async function setupBazel() {
core.startGroup('Configure Bazel')
console.log('Configuration:')
console.log(JSON.stringify(config, null, 2))
core.info('Configuration:')
core.info(JSON.stringify(config, null, 2))
await setupBazelrc()
core.endGroup()
await setupBazelisk()
await restoreCache(config.bazeliskCache)
await restoreCache(config.diskCache)
await restoreCache(config.repositoryCache)
await restoreExternalCaches(config.externalCache)
}
async function setupBazelrc () {
fs.writeFileSync(
config.paths.bazelrc,
`startup --output_base=${config.paths.bazelOutputBase}\n`
)
async function setupBazelisk() {
if (config.bazeliskVersion.length == 0) {
return
}
for (const line of config.bazelrc) {
fs.appendFileSync(config.paths.bazelrc, `${line}\n`)
core.startGroup('Setup Bazelisk')
let toolPath = tc.find('bazelisk', config.bazeliskVersion)
if (toolPath) {
core.debug(`Found in cache @ ${toolPath}`)
} else {
toolPath = await downloadBazelisk()
}
core.addPath(toolPath)
core.endGroup()
}
async function downloadBazelisk() {
const version = config.bazeliskVersion
core.debug(`Attempting to download ${version}`)
// Possible values are 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x' and 'x64'.
// Bazelisk filenames use 'amd64' and 'arm64'.
let arch = config.os.arch
if (arch == 'x64') {
arch = 'amd64'
}
// Possible values are 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos' and 'win32'.
// Bazelisk filenames use 'darwin', 'linux' and 'windows'.
let platform = config.os.platform
if (platform == "win32") {
platform = "windows"
}
let filename = `bazelisk-${platform}-${arch}`
if (platform == 'windows') {
filename = `${filename}.exe`
}
const token = process.env.BAZELISK_GITHUB_TOKEN
const octokit = github.getOctokit(token, {
baseUrl: 'https://api.github.com'
})
const { data: releases } = await octokit.rest.repos.listReleases({
owner: 'bazelbuild',
repo: 'bazelisk'
})
// Find version matching semver specification.
const tagName = tc.evaluateVersions(releases.map((r) => r.tag_name), version)
const release = releases.find((r) => r.tag_name === tagName)
if (!release) {
throw new Error(`Unable to find Bazelisk version ${version}`)
}
const asset = release.assets.find((a) => a.name == filename)
if (!asset) {
throw new Error(`Unable to find Bazelisk version ${version} for platform ${platform}/${arch}`)
}
const url = asset.browser_download_url
core.debug(`Downloading from ${url}`)
const downloadPath = await tc.downloadTool(url, undefined, `token ${token}`)
core.debug('Adding to the cache...');
fs.chmodSync(downloadPath, '755');
let bazel_name = "bazel";
if (platform == 'windows') {
bazel_name = `${bazel_name}.exe`
}
const cachePath = await tc.cacheFile(downloadPath, bazel_name, 'bazelisk', version)
core.debug(`Successfully cached bazelisk to ${cachePath}`)
return cachePath
}
async function setupBazelrc() {
for (const bazelrcPath of config.paths.bazelrc) {
fs.writeFileSync(
bazelrcPath,
`startup --output_base=${config.paths.bazelOutputBase}\n`
)
fs.appendFileSync(bazelrcPath, config.bazelrc.join("\n"))
}
}
async function restoreExternalCaches (cacheConfig) {
async function restoreExternalCaches(cacheConfig) {
if (!cacheConfig.enabled) {
return
}
@ -55,33 +133,36 @@ async function restoreExternalCaches (cacheConfig) {
// Now restore all external caches defined in manifest
if (fs.existsSync(path)) {
const manifest = fs.readFileSync(path, { encoding: 'utf8' })
for (const name of manifest.split('\n').filter(s => s)) {
await restoreCache({
enabled: true,
files: cacheConfig[name]?.files || cacheConfig.default.files,
name: cacheConfig.default.name(name),
paths: cacheConfig.default.paths(name)
})
}
const restorePromises = manifest.split('\n').filter(s => s)
.map(name => {
return restoreCache({
enabled: cacheConfig[name]?.enabled ?? cacheConfig.default.enabled,
files: cacheConfig[name]?.files || cacheConfig.default.files,
name: cacheConfig.default.name(name),
paths: cacheConfig.default.paths(name)
});
});
await Promise.all(restorePromises);
}
}
async function restoreCache (cacheConfig) {
async function restoreCache(cacheConfig) {
if (!cacheConfig.enabled) {
return
}
const delay = Math.random() * 1000 // timeout <= 1 sec to reduce 429 errors
await setTimeout(delay, async function () {
core.startGroup(`Restore cache for ${cacheConfig.name}`)
await setTimeout(delay)
core.startGroup(`Restore cache for ${cacheConfig.name}`)
try {
const hash = await glob.hashFiles(cacheConfig.files.join('\n'))
const name = cacheConfig.name
const paths = cacheConfig.paths
const restoreKey = `${config.baseCacheKey}-${name}-`
const key = `${restoreKey}${hash}`
console.log(`Attempting to restore ${name} cache from ${key}`)
core.debug(`Attempting to restore ${name} cache from ${key}`)
const restoredKey = await cache.restoreCache(
paths, key, [restoreKey],
@ -89,17 +170,19 @@ async function restoreCache (cacheConfig) {
)
if (restoredKey) {
console.log(`Successfully restored cache from ${restoredKey}`)
core.info(`Successfully restored cache from ${restoredKey}`)
if (restoredKey === key) {
core.saveState(`${name}-cache-hit`, 'true')
}
} else {
console.log(`Failed to restore ${name} cache`)
core.info(`Failed to restore ${name} cache`)
}
} catch (err) {
core.warning(`Failed to restore ${name} cache with error: ${err}`)
} finally {
core.endGroup()
}())
}
}
run()

1058
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,10 @@
{
"name": "setup-bazel",
"version": "0.2.0",
"version": "0.18.0",
"description": "Install and configure Bazel for GitHub Actions",
"main": "index.js",
"engines" : {
"node" : "16.x"
"engines": {
"node": "24.x"
},
"scripts": {
"build": "ncc build index.js -s -o dist/main && ncc build post.js -s -o dist/post",
@ -13,11 +13,12 @@
"author": "Alex Rodionov <p0deje@gmail.com>",
"license": "MIT",
"dependencies": {
"@actions/cache": "https://github.com/p0deje/toolkit/raw/730a2921638a36a31bb6bef6a70f34bff2c99aff/packages/cache/actions-cache-3.1.2.tgz",
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@actions/glob": "^0.3.0",
"@vercel/ncc": "^0.36.0",
"@actions/cache": "^6.0.0",
"@actions/core": "^3.0.0",
"@actions/github": "^9.0.0",
"@actions/glob": "^0.6.0",
"@actions/tool-cache": "^4.0.0",
"@vercel/ncc": "^0.38.0",
"yaml": "^2.2.1"
}
}

23
post.js
View file

@ -5,19 +5,26 @@ const core = require('@actions/core')
const glob = require('@actions/glob')
const config = require('./config')
const { getFolderSize } = require('./util')
const process = require('node:process');
async function run () {
async function run() {
await saveCaches()
process.exit(0)
}
async function saveCaches () {
async function saveCaches() {
if (!config.cacheSave) {
core.info('Cache saving is disabled (cache-save: false)')
return
}
await saveCache(config.bazeliskCache)
await saveCache(config.diskCache)
await saveCache(config.repositoryCache)
await saveExternalCaches(config.externalCache)
}
async function saveExternalCaches (cacheConfig) {
async function saveExternalCaches(cacheConfig) {
if (!cacheConfig.enabled) {
return
}
@ -37,7 +44,7 @@ async function saveExternalCaches (cacheConfig) {
if (sizeMB >= cacheConfig.minSize) {
const name = path.basename(externalPath)
await saveCache({
enabled: true,
enabled: cacheConfig[name]?.enabled ?? cacheConfig.default.enabled,
files: cacheConfig[name]?.files || cacheConfig.default.files,
name: cacheConfig.default.name(name),
paths: cacheConfig.default.paths(name)
@ -58,7 +65,7 @@ async function saveExternalCaches (cacheConfig) {
}
}
async function saveCache (cacheConfig) {
async function saveCache(cacheConfig) {
if (!cacheConfig.enabled) {
return
}
@ -74,12 +81,14 @@ async function saveCache (cacheConfig) {
const paths = cacheConfig.paths
const hash = await glob.hashFiles(
cacheConfig.files.join('\n'),
undefined,
// We don't want to follow symlinks as it's extremely slow on macOS.
{ followSymbolicLinks: false }
)
const key = `${config.baseCacheKey}-${cacheConfig.name}-${hash}`
console.log(`Attempting to save ${paths} cache to ${key}`)
core.debug(`Attempting to save ${paths} cache to ${key}`)
await cache.saveCache(paths, key)
console.log('Successfully saved cache')
core.info('Successfully saved cache')
} catch (error) {
core.warning(error.stack)
} finally {

6
renovate.json Normal file
View file

@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
]
}

11
util.js
View file

@ -12,8 +12,9 @@ async function getFolderSize (rootItemPath, options = {}) {
async function processItem (itemPath) {
if (options.ignore?.test(itemPath)) return
const stats = fs.lstatSync(itemPath, { bigint: true })
const stats = lstatSync(itemPath, { bigint: true })
if (typeof stats !== 'object') return
fileSizes.set(stats.ino, stats.size)
if (stats.isDirectory()) {
@ -39,4 +40,12 @@ async function getFolderSize (rootItemPath, options = {}) {
return folderSize
}
function lstatSync(path, opts) {
try {
return fs.lstatSync(path, opts)
} catch (error) {
return
}
}
module.exports = { getFolderSize }