LogoLogo
  • Welcome to Redefine
    • About
    • Quick Start ⏱️
      • Verification Examples
    • How Does It Work? 🔬
  • Configuration
    • Install Command
    • Configuration Parameters
    • Parallel Test Execution
      • Redefine Parallel
      • Remote Workers
        • Delayed Workers and Reruns
    • Selection Modes
      • Discover
      • Optimize
      • Fail-Fast
      • Prioritize
    • CI Platforms
    • Redefine Flow
  • Troubleshooting
    • Verify Troubleshooting
      • Environment Troubleshooting
      • Git Troubleshooting
      • Testing Frameworks
        • Cypress Troubleshooting
        • Pytest Troubleshooting
  • Integrations
    • Supported Technologies
    • AI Slack Notifications
Powered by GitBook
On this page
  • Install
  • Configure
  • Verify
  • Run in Discover Mode
  • Examples
  1. Welcome to Redefine

Quick Start ⏱️

PreviousAboutNextVerification Examples

Last updated 10 months ago

Install

Set up the Redefine CLI tool in your CI environment by copy-pasting the code below.

pip install -U redefine

The Redefine CLI tool supports Python 3.6+ and is currently only available for CI environments, not the local developer's environment.

Configure

Set up the authentication key

Additional Configurations

Check out Configuration Parameters for additional configuration options.

Verify

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:

redefine verify --pytest
redefine verify --cypress
redefine verify --mocha

For more information on successful verification output and examples of failure cases, check out Verification Examples.

For a full list of error messages and resolutions, see Verify Troubleshooting.

Run in Discover Mode

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:

redefine install --discover --pytest
redefine install --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 install --discover --cypress --project /path/to/project
redefine install --discover --cypress --config-file /path/to/file
redefine install --discover --mocha

For more information about selection modes, please see Selection Modes.

Examples

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.

- name: Redefine GitHub Action
    id: run_redefine
    uses: redefinedev/redefine-action@main
    with:
        auth: ${{ secrets.REDEFINE_AUTH_KEY }}
        testing-framework: pytest
        mode: discover
- name: Test with pytest  
    id: pytest 
    run: pytest tests
    stages {
        stage('run pytest with redefine') {
            environment {
                REDEFINE_AUTH=credentials('REDEFINE_AUTH_KEY')
            }
            steps {
                '''
                pip install -U redefine
                redefine install --discover --pytest 
                pytest tests
                '''
            }
        }
    name: run Redefine
    command: |
        pip install -U redefine
        redefine install --discover --pytest
    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
redefine install --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
    - redefine install --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
      redefine install --discover --pytest 
      pytest tests

Tracking the discovery progress

Store the Redefine authentication key in your CI system by following the recommended best practices for your specific CI platform: , , , , , or . 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 , We'd be happy to assist you!

For all the GitHub Action options see the action's .

Monitor the progress of the discovery process and verify the data using the , which offers a user-friendly way to track the process and ensure accurate results.

GitHub Actions
GitLab CI
Jenkins
CircleCI
Buildkite
TeamCity
help@redefine.dev
docs
Redefine Onboarding Wizard