#17 from vend/srv-service1-test-condition…
mda-testing Merge pull requestSrv service1 test conditions
AMD64
no language set
Git
conditions: v1
language: go
go: 1.10.x
install: skip
# Branch prefixes:
# - lib-* Work related to a specific single library eg lib-unicorn-feature-a
# - srv-* Work related to a specific microservice eg srv-rider-bugfix-b
# - multi-* Work related to multiple services or libraries eg multi-switch-to-new-error-tracker
# Limitations:
# - Currently, the way check_modified_single.sh works relies on component names no having dashes or there could be mismatches
# - Also check_modified_single.sh expects that components of different types may not share the same name
# - All tests are expected to be dockerised to avoid any dependencies installed in travis file
jobs:
include:
# Pre-flight checks
- stage: check
env: CHECK="Branch name"
if: NOT branch = master AND NOT branch =~ ^multi- AND NOT branch =~ ^lib- AND NOT branch =~ ^srv-
script:
- echo -e "\n\nILLEGAL BRANCH NAME $TRAVIS_BRANCH\nMust begin with either srv- or lib- or multi-" && exit 1
- stage: check
env: CHECK="Modified files in multiple components"
if: branch =~ ^multi-
script:
- ./ci/check_modified_multi.sh
- stage: check
env: CHECK="Modified files in a single component"
if: branch =~ ^lib- OR branch =~ ^srv-
script:
- ./ci/check_modified_single.sh
# Test libraries
- &lib-test-stage
stage: test libraries
script:
- COMPONENT_TYPE=lib ./ci/check_modified.sh || travis_terminate
- COMPONENT_TYPE=lib ./ci/test.sh
if: branch = master OR branch =~ ^multi- OR branch =~ concat(^lib-,env(COMPONENT_NAME),-)
env: COMPONENT_NAME=library1 TEST_SUITE=functional
- <<: *lib-test-stage
env: COMPONENT_NAME=library2 TEST_SUITE=unit
# Test services
- &srv-test-stage
stage: test services
script:
- COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate
- BUILD_ENV=test COMPONENT_TYPE=srv ./ci/test.sh
if: branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)
env: COMPONENT_NAME=service1 TEST_SUITE=unit
- <<: *srv-test-stage
env: COMPONENT_NAME=service1 TEST_SUITE=functional
- <<: *srv-test-stage
env: COMPONENT_NAME=service2
- <<: *srv-test-stage
env: COMPONENT_NAME=service3 SOME_OTHER_VAR=whatever
- <<: *srv-test-stage
env: COMPONENT_NAME=service4 AA=1
- <<: *srv-test-stage
env: COMPONENT_NAME=service4 BB=1
# Dev image to be used for nobob and QA
- &dev-deploy-stage
stage: deploy
script:
- COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate
- BUILD_ENV=dev ./ci/deploy.sh
if: branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)
env: COMPONENT_NAME=service1
- <<: *dev-deploy-stage
env: COMPONENT_NAME=service2
- <<: *dev-deploy-stage
env: COMPONENT_NAME=service3
- <<: *dev-deploy-stage
env: COMPONENT_NAME=service4
# Prod image
- &prod-deploy-stage
stage: deploy
script:
- COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate
- BUILD_ENV=prod ./ci/deploy.sh
if: branch = master
env: COMPONENT_NAME=service1
- <<: *prod-deploy-stage
env: COMPONENT_NAME=service2
- <<: *prod-deploy-stage
env: COMPONENT_NAME=service3
- <<: *prod-deploy-stage
env: COMPONENT_NAME=service4
Build Config
{
"go": "1.10.x",
"jobs": {
"include": [
{
"if": "NOT branch = master AND NOT branch =~ ^multi- AND NOT branch =~ ^lib- AND NOT branch =~ ^srv-",
"env": "CHECK=\"Branch name\"",
"stage": "check",
"script": [
"echo -e \"\\n\\nILLEGAL BRANCH NAME $TRAVIS_BRANCH\\nMust begin with either srv- or lib- or multi-\" && exit 1"
]
},
{
"if": "branch =~ ^multi-",
"env": "CHECK=\"Modified files in multiple components\"",
"stage": "check",
"script": [
"./ci/check_modified_multi.sh"
]
},
{
"if": "branch =~ ^lib- OR branch =~ ^srv-",
"env": "CHECK=\"Modified files in a single component\"",
"stage": "check",
"script": [
"./ci/check_modified_single.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^lib-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=library1 TEST_SUITE=functional",
"stage": "test libraries",
"script": [
"COMPONENT_TYPE=lib ./ci/check_modified.sh || travis_terminate",
"COMPONENT_TYPE=lib ./ci/test.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^lib-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=library2 TEST_SUITE=unit",
"stage": "test libraries",
"script": [
"COMPONENT_TYPE=lib ./ci/check_modified.sh || travis_terminate",
"COMPONENT_TYPE=lib ./ci/test.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=service1 TEST_SUITE=unit",
"stage": "test services",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=test COMPONENT_TYPE=srv ./ci/test.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=service1 TEST_SUITE=functional",
"stage": "test services",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=test COMPONENT_TYPE=srv ./ci/test.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=service2",
"stage": "test services",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=test COMPONENT_TYPE=srv ./ci/test.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=service3 SOME_OTHER_VAR=whatever",
"stage": "test services",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=test COMPONENT_TYPE=srv ./ci/test.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=service4 AA=1",
"stage": "test services",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=test COMPONENT_TYPE=srv ./ci/test.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=service4 BB=1",
"stage": "test services",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=test COMPONENT_TYPE=srv ./ci/test.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=service1",
"stage": "deploy",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=dev ./ci/deploy.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=service2",
"stage": "deploy",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=dev ./ci/deploy.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=service3",
"stage": "deploy",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=dev ./ci/deploy.sh"
]
},
{
"if": "branch = master OR branch =~ ^multi- OR branch =~ concat(^srv-,env(COMPONENT_NAME),-)",
"env": "COMPONENT_NAME=service4",
"stage": "deploy",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=dev ./ci/deploy.sh"
]
},
{
"if": "branch = master",
"env": "COMPONENT_NAME=service1",
"stage": "deploy",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=prod ./ci/deploy.sh"
]
},
{
"if": "branch = master",
"env": "COMPONENT_NAME=service2",
"stage": "deploy",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=prod ./ci/deploy.sh"
]
},
{
"if": "branch = master",
"env": "COMPONENT_NAME=service3",
"stage": "deploy",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=prod ./ci/deploy.sh"
]
},
{
"if": "branch = master",
"env": "COMPONENT_NAME=service4",
"stage": "deploy",
"script": [
"COMPONENT_TYPE=srv ./ci/check_modified.sh || travis_terminate",
"BUILD_ENV=prod ./ci/deploy.sh"
]
}
]
},
"install": "skip",
"language": "go",
"conditions": "v1"
}