Multi-Environment Builds

Scrutinizer allows you to set up multiple build environments with minimal effort. The configuration that you previously placed directly under build, now just moves under a named key under nodes. All the options that you could previously configure, now can be adjusted for each node separately.

Use Case: Testing Different Sub-Projects

If you place different projects in a single repository, let's say a frontend angular application and an API backend, multi environments allow you to set-up different environments for them while still benefiting from our build command inference:

build:
    nodes:
        angular:
            # Assumes that the API project is in a sub-path 'frontend' in your repository root
            root_path: './frontend'
            environment:
                node: v7.4

            tests:
                override:
                    - ng test

        api:
            # Assumes that the API project is in a sub-path 'backend' in your repository root
            root_path: './backend'
            environment:
                php: 7.1

            tests:
                override:
                    - vendor/bin/phpunit

Use Case: Testing Different Versions

Another use-case for multi-environment builds, is testing against different versions of a language:

# .scrutinizer.yml
build:
    nodes:
        php56:
            environment:
                php: 5.6

            tests:
                override:
                    -
                        command: vendor/bin/phpunit

        php71:
            environment:
                php: 7.1

            tests:
                override:
                    -
                        command: vendor/bin/phpunit

This configuration will execute each test section with its own settings, each test section will also be run in separate, isolated containers.

Share Configuration in Multi-Evironment Builds

If you want to share configuration between different nodes in multi-environment builds, you can add the shared configuration under level of build:

# .scrutinizer.yml
build:
    environment:
        variables:
            FOO_PATH: 'BAR'
    tests:
        override:
            - phpunit

    nodes:
        php:
            environment:
                php: 5.6

        php71:
            environment:
                php: 7.1

This configuration is equivalent to:

# .scrutinizer.yml
build:
    nodes:
        php:
            environment:
                php: 5.6
                variables:
                    FOO_PATH: 'BAR'
            tests:
                override:
                    - phpunit
        php71:
            environment:
                php: 7.1
                variables:
                    FOO_PATH: 'BAR'
            tests:
                override:
                    - phpunit