Quick Start ⏱️

Set up the Redefine CLI tool in your CI environment by copy-pasting the code below.
Pip Package Installer
pip install -U redefine --index-url https://pip.redefine.dev/
The Redefine CLI tool supports Python 3.6+ and is currently only available for CI environments, not the local developer's environment.
Store the Redefine authentication key in your CI system by following the recommended best practices for your specific CI platform: GitHub Actions, GitLab CI, Jenkins, CircleCI, Buildkite, or TeamCity. Once stored, you can export the authentication key to the Redefine CLI by setting the environment variable as
REDEFINE_AUTH
. This ensures that the CLI can access the authentication key securely and use it for authentication purposes.If you haven't received your Redefine credentials yet, please reach out to us at [email protected], We'd be happy to assist you!
Identify the primary working branch in your repository that will serve as the stable branch for Redefine. For example, you could use
main
as your stable branch name. This will ensure Redefine is operating on the correct branch when processing your project.To configure your stable branch, use the following command:
redefine config set stable_branch=<stable_branch_name>
Once Redefine has been installed and configured, make sure that everything is working properly by running the
verify
command. This command verifies whether your CI environment is compatible with Redefine, and returns a success message if all is good or an error message detailing any issues that need fixing. To run the command, follow these steps:Pytest
Cypress
redefine verify --pytest
redefine verify --cypress
For more information on successful verification output and examples of failure cases, check out Verification Examples.
With Discover mode, Redefine analyzes your coding patterns and test results to create the initial test optimization model. To start the discovery process, simply replace the
verify
command from the previous step with the following command:Pytest
Cypress
redefine start --discover --pytest
redefine start --discover --cypress
If you are running Cypress using the flags
--project
or --config-file
, Please add it to the 'redefine start' command as well.For example:
redefine start --discover --cypress --project /path/to/project
redefine start --discover --cypress --config-file /path/to/file
The following examples show the final Redefine for development environments setup using
pytest
. This gives an idea of what your configuration should look like once everything is in place.Github Actions
Jenkins
CircleCI
TeamCity
Gitlab CI
Buildkite
- name: Run Redefine
id: run_redefine
env:
REDEFINE_AUTH: ${{ secrets.REDEFINE_AUTH_KEY}}
run: |
pip install -U redefine --index-url https://pip.redefine.dev/
redefine config set stable_branch=dev
redefine start --discover --pytest
- name: Test with pytest
id: pytest_tests
run: pytest tests
stages {
stage('run pytest with redefine') {
environment {
REDEFINE_AUTH=credentials('REDEFINE_AUTH_KEY')
}
steps {
sh '''
pip install -U redefine --index-url https://pip.redefine.dev/
redefine config set stable_branch=dev
redefine start --discover --pytest
pytest tests
'''
}
}
name: run Redefine
command: |
pip install -U redefine --index-url https://pip.redefine.dev/
redefine config set stable_branch=dev
redefine verify
environment:
REDEFINE_AUTH: $REDEFINE_AUTH_KEY
- run:
name: test with pytest
command: pytest tests
export REDEFINE_AUTH=%secure:REDEFINE_AUTH_KEY%
export TEAMCITY_GIT_PATH=%teamcity.build.checkoutDir%
export TEAMCITY_HEAD_COMMIT_HASH=%build.vcs.number%
export TEAMCITY_PIPELINE_NAME=%teamcity.project.id%
export TEAMCITY_JOB_NAME=%system.teamcity.buildConfName%
export TEAMCITY_GIT_ACTION=%teamcity.pullRequest.branch.pullrequests%
export TEAMCITY_SOURCE_BRANCH=%teamcity.pullRequest.source.branch%
export TEAMCITY_TARGET_BRANCH=%teamcity.pullRequest.target.branch%
pip install -U redefine --index-url https://pip.redefine.dev/
redefine config set stable_branch=dev
redefine start --discover --pytest
pytest tests
id_tokens:
VAULT_ID_TOKEN:
aud: https://gitlab.com
secrets:
REDEFINE_AUTH:
vault: production/redefine/auth_key@ops
token: $REDEFINE_AUTH
stage: test
script:
- pip install -U redefine --index-url https://pip.redefine.dev/
- redefine config set stable_branch=dev
- redefine start --discover --pytest
- pytest tests
steps:
- label: "run pytest tests with redefine"
command: |
# redefine expects an environment variable named REDEDINE_AUTH
# check the documentation on how to use a secret in buildkite: https://buildkite.com/docs/pipelines/secrets
export REDEFINE_AUTH=<your-secret>
pip install -U redefine --index-url https://pip.redefine.dev/
redefine config set stable_branch=master
redefine start --discover --pytest
pytest tests
Tracking the discovery progress
Monitor the progress of the discovery process and verify the data using the Redefine Onboarding Wizard, which offers a user-friendly way to track the process and ensure accurate results.
Last modified 6d ago