-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
88 lines (74 loc) · 3.05 KB
/
Copy pathtasks.py
File metadata and controls
88 lines (74 loc) · 3.05 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
76
77
78
79
80
81
82
83
84
85
86
87
88
from invoke import task
import os
proper_shell = os.getenv("SHELL")
# updates dependencies file
@task
def createDependencies(c):
c.config.run.shell = proper_shell
c.run("pip3 freeze > requirements.txt")
# updates dependencies in the system
@task
def installDependencies(c):
c.config.run.shell = proper_shell
c.run("pip3 install --upgrade pip")
c.run("pip3 install -r requirements.txt")
# runs tests and check coverage
@task
def test(c):
c.config.run.shell = proper_shell
c.run("coverage run --source=events_microservice,notifications_microservice -m py.test")
# create coverage report and uploads it to codecov
@task
def coverage(c):
c.config.run.shell = proper_shell
c.run("coverage xml")
c.run("codecov")
# installs docker-compose
@task
def installDockerCompose(c):
c.config.run.shell = proper_shell
c.run("curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` -o docker-compose")
c.run("chmod +x docker-compose")
# tests that the containers have been created
@task
def testContainers(c):
c.config.run.shell = proper_shell
c.run("docker images | grep 'events_container'")
c.run("docker images | grep 'notifications_container'")
# builds and the images with the microservices
@task
def buildContainers(c):
c.config.run.shell = proper_shell
c.run("docker build -f Events.dockerfile -t events_container .")
c.run("docker build -f Notifications.dockerfile -t notifications_container .")
# runs in bg the containers with the microservices
@task
def runContainers(c):
c.config.run.shell = proper_shell
c.run("docker run --rm -dit -p 8000:8080 events_container")
c.run("docker run --rm -dit -p 8001:8080 notifications_container")
# uploads the docker images created to Github repository registry
@task
def uploadImageToGithub(c):
c.config.run.shell = proper_shell
c.run("docker login docker.pkg.github.com -u $GITHUB_USER -p $GITHUB_ACCESS_TOKEN")
c.run("docker tag `docker images events_container -q` docker.pkg.github.com/carlos-el/eventpost-ccproject/events_container:latest")
c.run("docker tag `docker images notifications_container -q` docker.pkg.github.com/carlos-el/eventpost-ccproject/notifications_container:latest")
c.run("docker push docker.pkg.github.com/$GITHUB_USER/events_container:latest")
c.run("docker push docker.pkg.github.com/$GITHUB_USER/notifications_container:latest")
# starts the server with the specified parameters
@task
def startServer(c, host, port, service):
c.config.run.shell = proper_shell
c.run("gunicorn -b %s:%s %s &" %(host, port, service))
@task
def populateHerokuEventsApp(c):
c.run("python3 fixtures.py https://eventpost.herokuapp.com/events events")
# runs ansible for creating and provisioning instances in AWS
@task
def reloadAnsibleAWSCredentials(c):
c.run("env EDITOR=nano ansible-vault edit provision/group_vars/all/pass.yml")
# runs ansible for creating and provisioning instances in AWS
@task
def runAWS(c):
c.run("ansible-playbook ./provision/provision.yml --ask-vault-pass")