Closed aguang-xyz closed 8 months ago
Hi @aguang-xyz,
You are at the correct place. The caches belonging to the PR branch are only scoped to the respective PRs and not the main
branch. Could you please explain further why you think its wrong? There's a big chance that older PRs might make stale caches active as other PRs might have updated the lockfile
with different dependencies which might not be a part of the PR branch.
Hi @kotewar,
Let's say there is an repository:
main
;dev
branch.It contains a CI workflow which will be triggered every time when we create a pull request towards main
branch.
name: CI
on:
pull_request:
branches:
- main
jobs:
bazel-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: latest
- name: Setup bazelisk
run: npm install -g @bazel/bazelisk
- name: Setup bazel cache
uses: actions/cache@v3
with:
path: "~/.cache/bazel"
key: ${{ runner.os }}-bazel
- name: Run tests
run: bazel --output_user_root=~/.cache/bazel test //...
As a developer, I may:
dev
branch and create a pull request refs/pull/1/merge
(triggers CI run #1
).dev
branch again and create a new pull request refs/pull/2/merge
(triggers CI run #2
).Currently these two runs cannot share caches (because as you mentioned "The caches belonging to the PR branch are only scoped to the respective PRs")
But if we scope the caches down to it's source branch dev
, we can speed up CI runs in this case.
Hi, Is there any update on this?? We would really be benefitted with this change and save a lot of time and action minutes.
This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days.
This issue was closed because it has been inactive for 5 days since being marked as stale.
HI,
I see this is marked with the enhancement label. Think this should stay open.
Hi there,
As described in the Cache scopes section, cache entries are isolated by branch level.
If I understand correctly, the run triggered by pull request should also belong to it's source branch.
But in some of my project, after creating a pull request from
dev
tomain
. I can see that the cache entry indicates it's branch name isrefs/pull/{pr-id}/merge
. That seems wrong and thus pull request triggered runs cannot be speed up at the moment.I tried to do some investigation my self and seems like the logic of resolving branch name is happend on server side. So feel free to point me where is the better place to track this issue (if this isn't the right space).
Many thanks, Grey