blob: b268400d31a772a57a3ccaa11775bd025546fb1b (
plain) (
blame)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
stages:
- lint
- test
- publish
- deploy
variables:
BASE_IMAGE_URL: registry.gitlab.com/python-discord/projects/site/django-ci
.test-template: &test-template
stage: test
services:
- postgres:11-alpine
before_script:
- python -m pip install -e .[test]
- python manage.py migrate
script:
- python manage.py test
tags:
- docker
variables:
DATABASE_URL: postgres://django:supersecret@postgres/pysite
POSTGRES_DB: pysite
POSTGRES_PASSWORD: supersecret
POSTGRES_USER: django
SECRET_KEY: supersecret
lint-python:
stage: lint
image: python:3.7-alpine
before_script:
# Extract lint dependencies from the setup script.
- >
python -m pip install $(sed -n -e "/'lint': \[/,/]/p" setup.py | tail -n +2 | head -n -1 | cut -d"'" -f2)
script:
- flake8
tags:
- docker
lint-docker:
stage: lint
image: hadolint/hadolint:latest-debian
script:
- hadolint docker/**/**/**/Dockerfile
tags:
- docker
lint-markdown:
stage: lint
image: ruby:2.5-alpine
before_script:
- gem install mdl
script:
- mdl *.md **/*.md
tags:
- docker
test-3.7-alpine:
<<: *test-template
image: python:3.7-alpine
before_script:
- apk add --no-cache-dir \
gcc \
linux-headers \
musl-dev \
postgresql-dev
- python -m pip install -e .[test]
- python manage.py migrate
script:
- coverage run --branch manage.py test
after_script:
- coverage report
artifacts:
paths:
- .coverage
test-3.6-alpine:
<<: *test-template
image: python:3.6-alpine
before_script:
- apk add --no-cache-dir \
gcc \
linux-headers \
musl-dev \
postgresql-dev
- python -m pip install -e .[test]
- python manage.py migrate
test-3.7-stretch:
<<: *test-template
image: python:3.7-stretch
test-3.6-stretch:
<<: *test-template
image: python:3.6-stretch
pages:
image: python:3.7-alpine
stage: publish
dependencies:
- test-3.7-alpine
before_script:
- pip install coverage
script:
- coverage html --directory=public
artifacts:
paths:
- public
expire_in: 30 days
tags:
- docker
push-django:
image: docker:stable-git
stage: publish
script:
- echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin
- docker build -t pythondiscord/django:latest .
- docker push pythondiscord/django:latest
only:
- master
- django
tags:
- docker
deploy:
stage: deploy
image: alpine:latest
before_script:
- apk add --no-cache openssh-client
- echo "$DJANGO_DEPLOY_SSH_PRIVATE_KEY" > id_ed25519
- chmod 400 id_ed25519
script:
- ssh -i id_ed25519 -p 583 -o "StrictHostKeyChecking=no" [email protected]
environment:
name: Django staging
url: https://pysite.jchri.st
tags:
- docker
only:
- master
- django
|