Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is getAncestorHash in healthcheck relevent as implemented yet ? #485

Closed
jfmou opened this issue Nov 6, 2020 · 2 comments · Fixed by #487
Closed

is getAncestorHash in healthcheck relevent as implemented yet ? #485

jfmou opened this issue Nov 6, 2020 · 2 comments · Fixed by #487
Assignees
Labels
bug Something isn't working P1

Comments

@jfmou
Copy link

jfmou commented Nov 6, 2020

I'm having little trouble understanding the point of this check which fails on my pipeline most of the time.
We do "merge with commit" our feature branches into develop then develop into master.
The base branch for our repo in our lhci server is develop.

When auditing our feature branches or freshly merged develop with lhci the check systematicaly fails since baseBranch isn't set, resulting in getAncestorHashForBranch using master as default branch which is not present as an ancestor of develop (nor the feature branches).

Uploads never failed that said, since the implementation seems more robust, requesting server data for baseBranch :

api.setBuildToken(options.token);
const project = await api.findProjectByToken(options.token);
if (!project) {
throw new Error('Could not find active project with provided token');
}
const baseBranch = project.baseBranch || 'master';
const hash = getCurrentHash();
const branch = getCurrentBranch();
const ancestorHash =
branch === baseBranch ? getAncestorHashForBase() : getAncestorHashForBranch('HEAD', baseBranch);

It doesn't fail the job and is only a warning, but it triggers me on the check itself and what to expect about it, since it always assume master is an ancestor.
I guess It would never failed if we did used fast forward merge strategy right ? Making master and develop always an ancestor of the feature branch.

I may be missing something here, but when i audit our master it succeeds, making me think I have a good lead.
Any ideas ?

@patrickhulce
Copy link
Collaborator

Thanks for filing @jfmou! You're right we should be threading through the baseBranch into the getAncestorHash function instead of hardcoding master there :)

function getAncestorHash(hash = 'HEAD') {
const envHash = getEnvVarIfSet([
// Manual override
'LHCI_BUILD_CONTEXT__ANCESTOR_HASH',
]);
if (envHash) return envHash;
return getCurrentBranch() === 'master'
? getAncestorHashForBase(hash)
: getAncestorHashForBranch(hash);
}

We'll need to make the same project API request to fetch the baseBranch

@patrickhulce patrickhulce added bug Something isn't working P1 labels Nov 6, 2020
@patrickhulce patrickhulce self-assigned this Nov 6, 2020
@jfmou
Copy link
Author

jfmou commented Nov 9, 2020

Well glad to help ! Thanks for your feedback. Love this product 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants