bitbucket-pipelines.yml
definitions:
services:
docker:
memory: 512
docker-large:
memory: 7128
type: docker
postgres:
image:
name: us.gcr.io/enroute-interne/enroute-postgresql:14-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
environment:
POSTGRES_DB: chouette
POSTGRES_USER: chouette
POSTGRES_PASSWORD: chouette
memory: 2048
datadog-agent:
image:
name: datadog/agent:latest
environment:
DD_INSIDE_CI: 'true'
DD_HOSTNAME: 'none'
DD_API_KEY: $DATADOG_KEY
caches:
bundler: ./vendor/bundle
yarn: ./node_modules
assets: ./public/assets
assets-cache: ./tmp/cache/assets
build-cache: ./cache
codacy-coverage: ./.codacy-coverage
steps:
- step: &setup
name: Setup
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
caches:
- bundler
- yarn
script:
- eval "$(build.sh bitbucket::env)"
- build.sh ci::setup
- bundle config
artifacts:
- node_modules/**
- vendor/bundle/**
- .bundle/*
- step: &build-assets
name: Build assets
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
caches:
- assets
- assets-cache
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- export RAILS_DB_ADAPTER=nulldb
- bundle exec rake ci:assets
artifacts:
- public/packs-test/**
- public/assets/**
- public/javascripts/i18n.js
- public/javascripts/translations.js
- step: &rspec-tests
name: Ruby Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
size: 2x
max-time: 30
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- bundle exec rake ci:setup ci:spec
- build.sh codacy::report::partial
caches:
- build-cache
artifacts:
- parallel_tests/*
services:
- postgres
- datadog-agent
- step: &rspec-tests-1
name: Ruby Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
size: 2x
max-time: 30
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- BITBUCKET_PARALLEL_STEP_COUNT=4 BITBUCKET_PARALLEL_STEP=0 FAIL_FAST=true bundle exec rake ci:setup ci:spec
- build.sh codacy::report::partial
caches:
- build-cache
artifacts:
- parallel_tests/*
services:
- postgres
- datadog-agent
- step: &rspec-tests-2
name: Ruby Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
size: 2x
max-time: 30
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- BITBUCKET_PARALLEL_STEP_COUNT=4 BITBUCKET_PARALLEL_STEP=1 FAIL_FAST=true bundle exec rake ci:setup ci:spec
- build.sh codacy::report::partial
caches:
- build-cache
artifacts:
- parallel_tests/*
services:
- postgres
- datadog-agent
- step: &rspec-tests-3
name: Ruby Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
size: 2x
max-time: 30
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- BITBUCKET_PARALLEL_STEP_COUNT=4 BITBUCKET_PARALLEL_STEP=2 FAIL_FAST=true bundle exec rake ci:setup ci:spec
- build.sh codacy::report::partial
caches:
- build-cache
artifacts:
- parallel_tests/*
services:
- postgres
- datadog-agent
- step: &rspec-tests-4
name: Ruby Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
size: 2x
max-time: 30
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- BITBUCKET_PARALLEL_STEP_COUNT=4 BITBUCKET_PARALLEL_STEP=3 FAIL_FAST=true bundle exec rake ci:setup ci:spec
- build.sh codacy::report::partial
caches:
- build-cache
artifacts:
- parallel_tests/*
services:
- postgres
- datadog-agent
- step: &rebuild-runtime-log
name: Rebuild runtime log
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
script:
- cat parallel_tests/runtime*.log > cache/runtime.log
- build.sh codacy::report::final
caches:
- build-cache
- step: &jest-tests
name: Javascript Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- bundle exec rake ci:jest
- build.sh codacy::report
- step: &bundle-audit
name: Bundle Audit
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- bundle exec rake ci:check_security
- step: &build-docker
name: Build Docker
size: 2x
image:
name: us.gcr.io/enroute-interne/enroute-cloud-sdk:latest
username: _json_key
password: "$GCLOUD_API_KEYFILE"
caches:
- docker
script:
- build.sh gcloud::setup
- build.sh bitbucket::docker::build
services:
- docker-large
pipelines:
custom:
gems-update: # Merge ci-master from chouette-core
- step:
name: Update gems
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
caches:
- bundler
- yarn
- assets
- assets-cache
- build-cache
script:
- eval "$(build.sh bitbucket::env)"
- build.sh ci::setup
- build.sh bummr::pull-request
services:
- postgres
default:
- step: *setup
- step: *build-assets
- parallel:
- step: *rspec-tests
- step: *rspec-tests
- step: *rspec-tests
- step: *rspec-tests
- step: *rebuild-runtime-log
- parallel:
- step: *jest-tests
- step: *bundle-audit
branches:
master:
- step: *setup
- step: *build-assets
- parallel:
fail-fast: true
steps:
- step: *build-docker
- step: *bundle-audit
- step: *jest-tests
- step: *rspec-tests-1
- step: *rspec-tests-2
- step: *rspec-tests-3
- step: *rspec-tests-4
- step: *rebuild-runtime-log
- step:
name: Tag
artifacts:
download: false
script:
- export TAG_NAME=ci-master
- git tag -afm "Build ${BITBUCKET_BUILD_NUMBER}" $TAG_NAME
- git push origin :refs/tags/$TAG_NAME
- git push origin $TAG_NAME
- step:
name: Trigger sub-projects
artifacts:
download: false
script:
- pipe: atlassian/trigger-pipeline:5.0.1
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
REPOSITORY: $TRIGGER_REPOSITORY_1
CUSTOM_PIPELINE_NAME: "merge"
- pipe: atlassian/trigger-pipeline:5.0.1
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
REPOSITORY: $TRIGGER_REPOSITORY_2
CUSTOM_PIPELINE_NAME: "merge"
- step:
name: Deploy to test
artifacts:
download: false
image:
name: eu.gcr.io/enroute-interne/enroute-cloud-sdk:latest
username: _json_key
password: "$GCLOUD_API_KEYFILE"
deployment: test
runs-on:
- self.hosted
- env.interne
script:
- git clone git@bitbucket.org:enroute-mobi/chouette-env.git env
- env/deploy-with-runner.sh
- pipe: atlassian/datadog-send-event:2.2.0
variables:
API_KEY: $DATADOG_KEY
TITLE: "Build ${BITBUCKET_BUILD_NUMBER} deployed on ${BITBUCKET_REPO_SLUG} ${BITBUCKET_DEPLOYMENT_ENVIRONMENT}"
PAYLOAD: >
{ "source_type_name": "BITBUCKET", "tags":["env:test","app:chouette-core","repository:chouette-core"] }
- step:
name: Trigger User Tests
artifacts:
download: false
script:
- pipe: atlassian/trigger-pipeline:5.0.1
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
REPOSITORY: $TRIGGER_REPOSITORY_3