-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
60 lines (55 loc) · 1.57 KB
/
.gitlab-ci.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
stages:
- fetch
- linter
- test
- build
- deploy
fetch_branch:
image: python:3.7
stage: fetch
script:
- git fetch --all
- git checkout $CI_COMMIT_REF_NAME
- git reset --hard origin/$CI_COMMIT_REF_NAME
only:
- branches
fetch_tag:
image: python:3.7
stage: fetch
script:
- git fetch --all
- git checkout $CI_COMMIT_REF_NAME
- git reset --hard $CI_COMMIT_REF_NAME
only:
- tags
linter_code:
image: cambalab/python3-uno
stage: linter
before_script:
- pip3 install black
- pip3 install flake8 mccabe pycodestyle pyflakes
script:
- python3 -m flake8 --config=.flake8 --statistics --count .
- black --config ./pyproject.toml --check .
run_tests:
image: cambalab/python3-uno
stage: test
script:
- pip install -r requirements/testing.txt -i https://pypi.python.org/simple
- python manage.py test --settings=ia2.settings.test --noinput --exclude-tag="skip" --pattern=test*.py
staging_deploy:
image: cambalab/python3-uno
stage: deploy
script:
- export APP_NAME=$([[ $CI_COMMIT_REF_NAME == "develop" ]] && echo "" || echo "-$(echo $CI_COMMIT_REF_NAME | cut -d "-" -f 2)")
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan -H "${DEPLOYMENT_STAGING_HOST}" >> ~/.ssh/known_hosts
- git filter-branch -f -- --all
- git push -f "${DEPLOYMENT_STAGING_USER}@${DEPLOYMENT_STAGING_HOST}:${DEPLOYMENT_STAGING_BASE_APP_NAME}${APP_NAME}" "${CI_COMMIT_REF_NAME}:master"
only:
refs:
- develop
- demo
- /^demo-.*$/