Find out which tests a pull request touches, and run them, without adding steps to your CI pipeline. With change validation in GitHub, mabl checks each pull request in your repository when it opens or gets a new commit. It runs the suites you choose and the tests the change impacts, and reports the result on the pull request as a GitHub check. You decide which checks must pass before a pull request can merge. If your repository uses a merge queue, mabl can check each queue entry as well.
Early access
Change validation is in early access for accounts with generative AI features. Pricing and packaging are subject to change.
To learn how mabl decides what to run and how it reports each check, see How change validation works.
Before you start
You need:
- A mabl account with test impact analysis and generative AI features.
- Permission to install GitHub Apps on the repository, or a teammate who has it.
- The Owner or Editor role in the mabl workspace, to turn the setting on.
- The mabl application and environment you want pull requests tested in.
- The latest version of the mabl CLI, to check your policy file.
- An environment that's ready when a pull request opens, such as a shared QA or staging environment. The App can't wait for a preview of each commit to deploy. See Limitations.
Connect the mabl GitHub App
- If the mabl GitHub App (listed in GitHub as mabl-bot) isn't installed on your repository yet, install it and connect it to your mabl workspace, as described in GitHub integration setup. If it's already installed, make sure it has access to the repository.
- In mabl, open the GitHub integration's settings, turn on Allow change validation on pull requests, and save. The setting appears only for accounts with test impact analysis and generative AI features.
Permissions and workspace
- GitHub permissions. If the App is already installed, you don't need to approve anything new in GitHub. Change validation uses permissions the App already has. The App reads your policy file with read access to repository contents. If an installation hasn't granted that permission, the mabl check on each pull request fails and says so. Approve the permission in your GitHub organization's settings for the mabl GitHub App.
- One workspace. The App works with the one mabl workspace its installation is connected to, so the application, environment, and credentials in your policy file must come from that workspace. If more than one workspace is connected to the same installation, mabl doesn't check the repository's pull requests.
The App's API key
The first time the App asks mabl to validate a pull request, mabl creates an API key for it in your workspace, named "GitHub App change validation". It appears with your other API keys. Leave it in place.
- If you turn the setting off, mabl removes the key.
- If someone disables the key, turn the setting off and on again to replace it.
- If someone deletes the key, mabl creates a new one at the next request.
When the key is replaced, pull requests that were already open can't continue, because each pull request's change agent acts for the key that was current at its first request. The check says Change validation didn't run and names the fix: a workspace Owner or Editor, or a workspace API key, resets the agent with POST /changeValidation/reset, and the next push starts a new one. New pull requests aren't affected.
Add a policy file
The policy file, .mabl/policy.yaml, tells mabl which application and environment to test in and what to check at each stage of your workflow. The file is also what turns change validation on for a repository: without one, mabl doesn't validate the repository's pull requests, and the App posts no check.
-
Create
.mabl/policy.yamlat the root of your repository. For example, this policy runs the impacted tests in the environment you name on each pull request, and reports the results without blocking the pull request:version: 1 applications: web: mabl_application: '{application-id}' target: environment: '{environment-id}' stages: pull_request: checks: - kind: impactedReplace each value in curly brackets with the ID from your workspace. See mabl resource IDs.
-
Check the file with the mabl CLI:
mabl policy resolveThe command exits 0 when the file is valid. When it isn't, the command lists each error with its line and column.
-
Commit the file and merge it into the branch your pull requests target. mabl reads the policy at the pull request's base commit, the commit it branched from, so an author can't change the rules in their own pull request. A policy added in a pull request applies to later pull requests, after it merges. An open pull request picks up a policy change on the branch it targets when it next merges that branch in, or is rebased onto it.
The stages the App asks for
The App asks for two stages, and only when your policy declares them:
-
pull_request, when a pull request opens, reopens, or gets a new commit. -
merge_queue, when a pull request enters a GitHub merge queue. For a queue entry, mabl reads the policy at the tip of the branch the queue merges into.
A stage with any other name, or a stage that belongs to a deployed commit (scope: revision), needs your own CI to ask for it. See Run change validation from your own CI.
If your own pipeline also sends stage requests for the repository, give the stages it requests names the App doesn't use. mabl refuses a verdict on a stage that another API key requested, so a stage both request can't be judged for either.
With each request, the App sends the pull request's title and description, its diff size, and the files it changes, grouped by application. mabl uses the changed files to decide which applications the change touches. When a pull request changes more than 300 files, GitHub doesn't list them all, so every application in the policy counts as touched.
Choose which impacted tests run (optional)
With the policy above, mabl reads the steps of each impacted test before running it, and runs only the tests with no step that writes data. To change which impacted tests run, add rules under an impacted key:
-
Run tests that write data. List a test label under
trusted.test_labels, and give that label to the tests you're comfortable running on any pull request, such as tests that reliably clean up everything they create. -
Keep impacted tests to the plans you choose. Name suites of plans under
include.suites. -
Leave tests out. List a test label under
exclude.test_labels, for example to set aside a flaky test without changing the policy again.
To run a fixed set of plans in a stage, such as your smoke tests, add a suite check. Set up a mabl policy file has an example with each of these. Its starter policy tests a preview of each commit at a {sha7} URL, which the App skips, so leave that url out or replace it with a fixed one. For every setting, see the policy file reference on GitHub.
A suite selects plans by label. mabl runs a matching plan only if it's turned on, has the stage's target application and environment, and has the Deployment trigger, which is under Triggers in the plan's settings. A suite whose label matches no such plan runs nothing. See Set up plans for deployment events.
Block merges until a check passes (optional)
By default, a policy check that fails is a warning: mabl reports it, but the mabl GitHub check still passes. To block a merge until mabl's tests pass:
-
In the policy file, set
must_pass: trueon each check that must pass:checks: - kind: impacted must_pass: true waiver: {label: skip-impacted-tests}The optional
waivernames a pull request label. A pull request that carries the label gets through without the check. -
In GitHub, add
mabl change validationto the required status checks of your branch's branch protection rule or ruleset. If you use a merge queue, the same check reports on each queue entry.
Before you require the check, give each stage the App asks for a fixed target and a suite check whose plans run on deployment events for that target, so the App doesn't skip the stage and mabl always has tests to run. See Limitations.
The App posts the check on a queue entry only when it asks mabl for a merge_queue stage. If you require the check, give your policy a merge_queue stage with a fixed target, so the check reports on every queue entry.
Results
mabl reports each stage as one check on the pull request's newest commit, named mabl change validation. For a merge queue entry, the check is on the queue's commit.
On the pull request
The check starts as Change validation in progress once mabl accepts the request. It lists each application in the policy and its stages, with a link to the policy file. When no check with must_pass: true is still running, the check shows the result. With no must_pass checks, that can be as soon as the first plan finishes, while others still run:
-
Change validation passed - Every check with
must_pass: truepassed or was waived. Other failed checks appear in the summary but don't block. -
Change validation failed - A check with
must_pass: truefailed or can't be judged, or mabl can't judge the stage at all. Details opens the deployment event of the check that decided it.
The check also reports problems with the policy file:
- The policy is invalid - The check fails and lists each error with its line and column. Because mabl reads the policy from the base commit, fix the file on the branch the pull request targets. The pull request picks up the fix once it merges that branch in.
- The policy can't be read - The check fails, for example because the file is larger than 64 KiB, or because the App doesn't have read access to repository contents.
A neutral check means mabl didn't validate the commit, and nothing in your repository has to change. GitHub counts a neutral check as passing, so a required check doesn't block a merge while mabl is unreachable. The check is neutral when:
- Change validation didn't run - mabl couldn't be reached or refused the request. The next commit asks again.
-
Nothing to validate - The policy has no
pull_requeststage, the target URL uses{sha7}, or mabl can't accept the pull request's labels or branch name. The check says which. - Not checked: pull request from a fork - mabl doesn't validate pull requests from forks.
In mabl
The tests each stage runs appear as a deployment event under Results > By deployment, alongside your other deployments. The impacted tests run together as one plan run, named after the stage, such as "pull_request impacted tests". Each suite in the stage runs its own plans in the same deployment event. If Run GitHub checks on deployment is on, these deployment events don't get a separate mabl deployment tests check.
When the pull request changes
- A new commit starts the stage again for the new commit. The result for the earlier commit no longer counts.
- A label change, or a change of the branch the pull request targets, takes effect the next time the pull request gets a new commit.
- A pull request from a fork isn't validated, and the check says so.
mabl branches
If your policy uses mabl_branch: match-pr, mabl runs the pull request's tests on an open mabl branch with the same name as the pull request's git branch, or on master when there isn't one. The App doesn't read a Mabl branch: line from the pull request's description, and it doesn't tell mabl when a pull request merges, so merge_mabl_branches has no effect with the App. To merge a mabl branch with its pull request, use your own CI for the merged event, as Run change validation from your own CI describes.
Turn it off
-
For one pull request: add the label your policy names as a check's
waiver, so the pull request gets through without that check. -
For a repository: remove the stages you no longer want checked from
.mabl/policy.yaml, or remove the file. A stage that isn't in the policy has no checks, and a repository without a policy file gets no check at all. - For every repository the App can access: turn off Allow change validation on pull requests in the GitHub integration's settings. mabl removes the App's API key.
Limitations
-
Preview deployments of each commit. The App can't wait for a preview of each commit to deploy. If a stage's target
urlorapi_urlcontains{sha7}, the App doesn't ask mabl for the stage. On a pull request, the check says there's nothing to validate. On a merge queue entry, the App posts nothing. Use a fixed URL, or leaveurlout so tests run at the environment's own URL. If you test each commit on its own preview, keep using the GitHub Action, where your workflow runs the mabl step after the deploy. - A stage where nothing runs. If mabl accepts the request but none of the stage's checks has anything to run, the check stays Change validation in progress until the next push. An impacted check has nothing to run when it keeps none of the tests it found. A suite check has nothing to run when its label matches no plan that's turned on, has the stage's target application and environment, and has the Deployment trigger. A required check that stays in progress keeps the pull request from merging, so don't require the check until each stage the App asks for has a suite check with at least one plan set up this way.
These aren't available with the App yet:
- A comment on the pull request with mabl's report. The GitHub Action can keep one.
- Comment commands on the pull request.
- Re-running the check from GitHub. Push a new commit to run the stage again.
- Merging a pull request's mabl branch when the pull request merges. See mabl branches.
- Stages that run after a merge deploys, with
scope: revision. Ask for those from your own CI.