Branching is available in preview. Please contact us to enable it for your team.
Feature branches
If feature changes introduce UI changes, tests need to be updated for that particular branch. Test runs from other branches will fail, because they don’t have corresponding UI changes.
Environment branches
Your pre-prod branch has new app changes that add/modify tests, but you want to be able to run tests on prod, without those changes.
Get started
Based on the use-case to solve, there are two types of branches in Empirical.Preview branches
These short-lived branches that represent feature branches with preview deployments. These branches are expected to be merged into a persistent branch.
Persistent branches
These are long-lived branches that represent deployment environments. One of the persistent branches is the default branch which is where your features are first merged.
Configure default branch name
For new projects, the default branch ismain, and this can be modified in Settings.
The choice of default branch matters if you have multiple persistent branches. Just like one of your persistent
branches is where new features land, you need to have a corresponding default branch in Empirical where new tests
land. For example, if your features get merged to staging branch in your app, it is a good idea for the
Empirical default branch to be called staging.
Setup preview branches
- Navigate to Branches and enable branching
- Triggering test runs: when using one of the CI/CD triggers, ensure that you are passing the source branch
- GitHub Actions trigger: No action required, branch info is sent internally
- API call trigger: Ensure you are passing the
build.branchparameter in the request payload
- Add merge branch step to your CI workflows: this will inform Empirical that a feature branch has been merged
into a persistent branch
- Preview branches get auto-deleted when they are merged
Lifecycle of preview branches
Lifecycle of preview branches
A preview branch is created when the first test run trigger is received for that branch, and deleted when the preview branch is merged.
- First test run for the branch: checks out the branch from the default branch
- Subsequent test runs for the branch: create a merge commit between this branch and the default branch, and runs the default commit.
This simulates what the test code would look like after merging, and ensures that new changes to the default branch are available for
the test run. This is similar to GitHub’s pull_request event.
- Note that if the test code are not auto-mergeable (due to merge conflicts), the test run will not start. This preempts an error that will happen on the merge step.
Setup persistent branches
- Navigate to Branches and enable branching
- On the same page, configure persistent branches
- When a new persistent branch is first configured, Empirical ensures that the branch exists in the repo, and if not, checks it out from the default branch
- Since it is a git branch, you can also check it out at a particular commit using git commands manually
- Even if a branch already exists in the git repo, it must be labeled as “persistent” in the Empirical dashboard
- Triggering test runs: when using one of the CI/CD triggers, ensure that you are passing the source branch
- GitHub Actions trigger: No action required, branch info is sent internally
- API call trigger: Ensure you are passing the
build.branchparameter in the request payload - If you are passing environment to the request payload, keep doing that: branch does not replace environments
- Add merge branch step to your CI workflows: this will inform Empirical that a persistent branch has been merged
into another persistent branch
- Unlike preview branches, persistent branches don’t get deleted on merges
Lifecycle of preview branches
Lifecycle of preview branches
A persistent branch is created when the branch is configured on the Empirical dashboard, or earlier, if it already exists in the git repo. The
branch is not automatically deleted.On incoming test run requests, the latest commit from the branch is run. Unlike preview branches, there is no merge commit between branches.