This repository was archived by the owner on Jun 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
75 lines (69 loc) · 2.2 KB
/
.gitlab-ci.yml
File metadata and controls
75 lines (69 loc) · 2.2 KB
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
image: docker:stable
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
build:
stage: build
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker pull $CONTAINER_TEST_IMAGE || true
- docker pull $CI_REGISTRY_IMAGE:master || true
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --cache-from $CONTAINER_TEST_IMAGE --cache-from $CI_REGISTRY_IMAGE:master -t $CONTAINER_TEST_IMAGE -t $CI_REGISTRY_IMAGE:latest .
- docker push $CONTAINER_TEST_IMAGE
- docker push $CI_REGISTRY_IMAGE:latest
smoke-test:
stage: test
image: $CONTAINER_TEST_IMAGE
services:
- postgres:9.6-alpine
variables:
DATABASE_URL: postgres://postgres:postgres@postgres/postgres
SECRET_KEY: test
GIT_STRATEGY: none
before_script:
- echo "overriding docker login"
script:
- cd /app
- pipenv run python manage.py migrate
- LOAD_NLP="True" pipenv run gunicorn fake_news_detector_api.wsgi -b 0.0.0.0:8000 -t 600 -k gthread --threads 4 --log-file - &
- sleep 15 && pipenv run python smoke_test.py
tests:
stage: test
image: $CONTAINER_TEST_IMAGE
services:
- postgres:9.6-alpine
variables:
DATABASE_URL: postgres://postgres:postgres@postgres/postgres
SECRET_KEY: test
GIT_STRATEGY: none
before_script:
- echo "overriding docker login"
script:
- cd /app
- pipenv run python manage.py migrate
- pipenv run coverage run --source='.' manage.py test
- pipenv run coverage report
deploy:
stage: deploy
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
GIT_STRATEGY: none
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $DOCKER_HUB_IMAGE
- docker login --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD
- docker push $DOCKER_HUB_IMAGE
- apk add --update --no-cache curl
- curl -X GET "$WEBHOOK_URL"
environment:
name: production
url: https://api.checkfake.info/api/ping
only:
- master