-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitbucket-pipelines.yml
105 lines (99 loc) · 3.57 KB
/
bitbucket-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
image: python:3.6.8
definitions:
services:
docker:
memory: 2048
steps:
- step: &api-spec-validation
name: Validate OpenAPI spec using prance
caches:
- pip
script:
- pip install -r requirements-tests.txt
- prance validate contracts/spec.yaml
- step: &style-validation
name: Validate style using flake8
caches:
- pip
script:
- pip install -r requirements-tests.txt
- flake8 .
- step: &tests
name: Run tests
caches:
- pip
script:
- pip install -r requirements-tests.txt
- python -m pytest tests/unit_tests --cov=api --cov-report xml:test-results/cov.xml --junitxml=test-results/log.xml
- python -m pytest tests/functional_tests
artifacts:
- test-results/*
- step: &code-quality-assessment
name: Sonarcloud analyses
caches:
- pip
script:
- pipe: sonarsource/sonarcloud-scan:1.0.1
variables:
EXTRA_ARGS: -Dsonar.python.coverage.reportPaths='test-results/cov.xml' -Dsonar.sources='api' -Dsonar.coverage.exclusions='api/helpers/spiders/custom/*'
- step: &deploy
# Any pipeline that uses this step *must* also define key 'deployment:'
name: deploy
trigger: manual
caches:
- pip
script:
- export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID_PROD
- export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY_PROD
- pip install awsebcli
- pip install setuptools_rust
- pip install -r requirements.txt
- pip install -Iv botocore==1.17
- eb init 'eb-document-crawler-worker' -p 'Python-3.6' --region 'eu-west-3' -v
- eb use $DEPLOYMENT_ENVIRONMENT
- >
eb setenv
RUNNING_ENV=$RUNNING_ENV
ROLLBAR_TOKEN=$ROLLBAR_TOKEN
ADMINDOC_CRAWLER_OUTPUT_QUEUE_REGION=$ADMINDOC_CRAWLER_OUTPUT_QUEUE_REGION
ADMINDOC_CRAWLER_OUTPUT_QUEUE_URL=$ADMINDOC_CRAWLER_OUTPUT_QUEUE_URL
ADMINDOC_CRAWLER_ERROR_QUEUE_URL=$ADMINDOC_CRAWLER_ERROR_QUEUE_URL
ADMINDOC_CRAWLER_PENSIEVE_URL=$ADMINDOC_CRAWLER_PENSIEVE_URL
DURATION_CRAWLER_ALERT=$DURATION_CRAWLER_ALERT
ADMINDOC_CRAWLER_DEPTH_LIMIT=$ADMINDOC_CRAWLER_DEPTH_LIMIT
ADMINDOC_CRAWLER_RETRY_TIMES=$ADMINDOC_CRAWLER_RETRY_TIMES
ADMINDOC_CRAWLER_DOWNLOAD_TIMEOUT=$ADMINDOC_CRAWLER_DOWNLOAD_TIMEOUT
ADMINDOC_CRAWLER_CLOSESPIDER_TIMEOUT=$ADMINDOC_CRAWLER_CLOSESPIDER_TIMEOUT
ADMINDOC_CRAWLER_DOWNLOAD_DELAY=$ADMINDOC_CRAWLER_DOWNLOAD_DELAY
ADMINDOC_CRAWLER_CONCURRENT_REQUESTS=$ADMINDOC_CRAWLER_CONCURRENT_REQUESTS
ADMINDOC_CRAWLER_S3_CONFIG=$ADMINDOC_CRAWLER_S3_CONFIG
- eb deploy --timeout 20 --label $(git rev-parse HEAD) -v
pipelines:
pull-requests:
'**':
- step:
script:
- echo "This PR has mergeable code :)"
- parallel:
- step: *api-spec-validation
- step: *style-validation
- step: *tests
default:
- parallel:
- step: *api-spec-validation
- step: *style-validation
- step: *tests
- step: *code-quality-assessment
- step:
<<: *deploy
deployment: Staging
branches:
master:
- parallel:
- step: *api-spec-validation
- step: *style-validation
- step: *tests
- step: *code-quality-assessment
- step:
<<: *deploy
deployment: Production