Skip to content

Commit 1ffdbf9

Browse files
authored
Add additional troubleshooting entry for Ancestor hash not determinable
When running LHCI in GH Actions due to how checkout action clones the repo with a fetch depth of 1 by default the base branch might be missing so LH will not be able to find it during health check. Changing the action settings and fetching the base using a new step will fix this problem for almost all cases where the repo is big enough. This has been discussed here actions/checkout#93 and here actions/checkout#213
1 parent 438f3e1 commit 1ffdbf9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/troubleshooting.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,29 @@ Different environments and ways of running Lighthouse will tend to see different
7777
- Geographic location
7878

7979
The team does not have the bandwidth to assist with debugging this problem. Please do _not_ file an issue about it if you're unable to get scores from different environments to match.
80+
81+
## Running LHCI in Github Actions I constantly get Ancestor hash not determinable
82+
83+
If you are using `actions/checkout@v2` to checkout your repository and based on the size and traffic on your repo this error might happen due to how he checkout action is configured and is not a LHCI issue.
84+
85+
Checkout action by default doesn't clone the entire repo and the number of commits to fetch is set to 1 for performance reasons. When LHCI runs the health check the ancestor hash might be missing because the branch / hash is not there in the local history.
86+
87+
In order to fix it change / add the following:
88+
89+
```yml
90+
name: Run Lighthouse tests
91+
jobs:
92+
lhci:
93+
name: Lighthouse
94+
runs-on: ubuntu-latest
95+
steps:
96+
- uses: actions/checkout@v2
97+
with:
98+
fetch-depth: 20
99+
- name: Fetch base_ref HEAD to use it as Ancestor hash in LHCI
100+
run: git fetch --depth=1 origin +refs/heads/${{github.base_ref}}:refs/remotes/origin/${{github.base_ref}}
101+
```
102+
103+
The additions are `fetch-depth: 20` added to `actions/checkout@v2` and a new step to fetch base_ref HEAD to use it as ancestor hash in LHCI.
104+
105+
The fetch depth set to 20 is a good default, but might not work in all cases, you can adjut it based on your needs.

0 commit comments

Comments
 (0)