databricks-cli/bundle/tests
Lennart Kats (databricks) 433f401c83
Add validation for Git settings in bundles (#578)
## Changes

This checks whether the Git settings are consistent with the actual Git
state of a source directory.

(This PR adds to https://github.com/databricks/cli/pull/577.) 

Previously, we would silently let users configure their Git branch to
e.g. `main` and deploy with that metadata even if they were actually on
a different branch.

With these changes, the following config would result in an error when
deployed from any other branch than `main`:

```
bundle:
  name: example

workspace:
  git:
    branch: main

environments:
  ...
```

> not on the right Git branch:
>   expected according to configuration: main
>   actual: my-feature-branch

It's not very useful to set the same branch for all environments,
though. For development, it's better to just let the CLI auto-detect the
right branch. Therefore, it's now possible to set the branch just for a
single environment:

```
bundle:
  name: example 2

environments:
  development:
    default: true

  production:
    # production can only be deployed from the 'main' branch
    git:
      branch: main
```

Adding to that, the `mode: production` option actually checks that users
explicitly set the Git branch as seen above. Setting that branch helps
avoid mistakes, where someone accidentally deploys to production from
the wrong branch. (I could see us offering an escape hatch for that in
the future.)

# Testing

Manual testing to validate the experience and error messages. Automated
unit tests.

---------

Co-authored-by: Fabian Jakobs <fabian.jakobs@databricks.com>
2023-07-30 12:44:33 +00:00
..
autoload_git Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
basic First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
bundle Auto detect Python wheel packages and infer build command (#603) 2023-07-26 10:07:26 +00:00
conflicting_resource_ids Require include glob patterns to be explicitly defined (#602) 2023-07-25 10:00:46 +02:00
environment_empty First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
environment_overrides First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
include_default Require include glob patterns to be explicitly defined (#602) 2023-07-25 10:00:46 +02:00
include_invalid First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
include_multiple Require include glob patterns to be explicitly defined (#602) 2023-07-25 10:00:46 +02:00
include_with_glob First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
interpolation First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
job_and_pipeline Extend deployment mode support (#577) 2023-07-30 07:19:49 +00:00
variables First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
yaml_anchors First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
README.md Move mutator interface to top level bundle package (#105) 2022-11-28 10:59:43 +01:00
autoload_git_test.go Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
basic_test.go Move mutator interface to top level bundle package (#105) 2022-11-28 10:59:43 +01:00
conflicting_resource_ids_test.go First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
environment_empty_test.go Check for nil environment before accessing it (#453) 2023-06-08 20:55:49 +00:00
environment_overrides_test.go Move mutator interface to top level bundle package (#105) 2022-11-28 10:59:43 +01:00
include_test.go Require include glob patterns to be explicitly defined (#602) 2023-07-25 10:00:46 +02:00
interpolation_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
job_and_pipeline_test.go First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
loader.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
variables_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
yaml_anchors_test.go Revert "Rename jobs -> workflows" (#118) 2022-12-01 22:39:15 +01:00

README.md

Bundle configuration tests

Every test here uses an example bundle configuration. Each bundle configuration is located in a dedicated subdirectory.