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

Baselines not transfering to branch #259

Open
ghengeveld opened this issue Mar 22, 2024 · 3 comments
Open

Baselines not transfering to branch #259

ghengeveld opened this issue Mar 22, 2024 · 3 comments
Labels
enhancement Classification: Improvement to existing feature

Comments

@ghengeveld
Copy link
Member

ghengeveld commented Mar 22, 2024

From AP-4139

How is the user affected? And what is the expected behavior?

I have a main branch with existing snapshot baselines. When I create a new branch off an existing branch like so:

main » test-branch

I'd expect that the baselines from main carry over to my new branch and get reflected in the addon panel.

Currently, I don't see the baselines from main in the addon panel. It prompts me to "create a test baseline"

image (5)

What are the steps for reproducing the issue?

On your main branch, take snapshots and accept them as baselines.

Create a new branch called test-branch. Check it out.

❌ See that you're compelled to create all new snapshots on this branch. I've tried publishing the branch and I still have to create test baselines,

❌ When I run a new build, I generate new snapshots.

NOTE:

This could be the correct behavior given this message.

image (6)

If it is, I'd expect that the addon would tell me what's going on. That it knows there are local builds on main, that I'm on test-branch which was branched from main, and that I should setup CI for the builds to carry over.

@ghengeveld ghengeveld added enhancement Classification: Improvement to existing feature sev:S4 labels Mar 22, 2024
@ghengeveld
Copy link
Member Author

This is related to, but not the same as #249.

@ghengeveld
Copy link
Member Author

We might be able to solve this by passing the result of the Git command below to the lastBuildOnBranch query.

git for-each-ref --points-at HEAD --format="%(refname:short)"

This works when switching to a new branch, as the current commit will be pointed at by both the main and test-branch branches after creating test-branch from main. However, as soon as a new commit is made on test-branch, main will no longer be pointing at the same (new) commit.

@psychobolt
Copy link

psychobolt commented Nov 7, 2024

Only running local builds on a separate branch the only problem here as well as OP mentions. At least creating a new local baseline for the branch will correctly detect the parent build for my setup.

On a side note, I talked to Chromatic support with the issue on running local build on main. The issue with running local builds on main is it seems to override the permanent docs link from the main branch. Their suggestion is to not run local builds on main branch leading to confusion with UX stakeholders. They would be misled on the latest changes since they reflect the last unstable build (non-baseline). For Zeplin connected components, they would also be impacted by local builds. I would note this should be at least documented.

For now, I've disabled the Visual Test add-on for main branch conditionally in vite config e.g.

import { execSync } from 'node:child_process';

const gitBranch = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim();

export const config = {
  addons: [
    // ...
    ...(new RegExp(`^origin/${gitBranch}$`).test(process.env.BASE_REF ?? '') ? [] : [getAbsolutePath('@chromatic-com/storybook')]),
  ]
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Classification: Improvement to existing feature
Projects
None yet
Development

No branches or pull requests

3 participants