-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
175 lines (159 loc) · 4.4 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
175 lines (159 loc) · 4.4 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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
stages:
- preparation
- testing
- checking
- security
- javascript
- deploy
# Variables
variables:
POSTGRES_DB: asanato_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: nxRN5q8AJxadtGvX
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --data-checksums"
APP_HOST_NAME: asanpay.local
API_HOST_NAME: api.asanpay.local
DB_HOST: postgres
image: edbizarro/gitlab-ci-pipeline-php:7.4
.init_ssh: &init_ssh |
eval $(ssh-agent -s)
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh
chmod 700 ~/.ssh
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
# Replace the last line with the following lines if you'd rather
# leave StrictHostKeyChecking enabled (replace yourdomain.com):
#
# ssh-keyscan yourdomain.com >> ~/.ssh/known_hosts
# chmod 644 ~/.ssh/known_hosts
.change_file_permissions: &change_file_permissions |
find . -type f -not -path "./vendor/*" -exec chmod 664 {} \;
find . -type d -not -path "./vendor/*" -exec chmod 775 {} \;
cache:
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
composer:
stage: preparation
allow_failure: true
script:
- php -v
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- cp .env.travis .env
- php artisan key:generate --env=testing
- php artisan apiato
artifacts:
paths:
- vendor/
- .env
expire_in: 1 days
cache:
paths:
- vendor/
when: always
yarn:
stage: javascript
script:
- yarn --version
- yarn install --pure-lockfile
- yarn run production --progress false
artifacts:
paths:
- node_modules/
expire_in: 1 days
cache:
paths:
- public/css/
- public/js/
- public/fonts/
- public/mix-manifest.json
when: on_success
phpunit:
stage: testing
services:
- name: aboozar/postgres:latest
alias: postgres
dependencies:
- composer
allow_failure: true
script:
- php artisan migrate:fresh --no-interaction --env=testing
- php artisan apiato:seed-deploy --no-interaction --env=testing
- php artisan apiato:seed-test --no-interaction --env=testing
- php artisan passport:keys
- sudo -- sh -c -e "echo '127.0.0.1 $APP_HOST_NAME' >> /etc/hosts"
- sudo -- sh -c -e "echo '127.0.0.1 $API_HOST_NAME' >> /etc/hosts"
- sudo php artisan serve --host=$API_HOST_NAME --port=80 &
- sleep 2
- curl http://$API_HOST_NAME ; echo;
- php vendor/bin/phpunit -v --no-coverage --colors=never --stderr --debug
artifacts:
paths:
- ./storage/logs # for debugging
expire_in: 1 days
when: on_success
syntax-check:
stage: checking
dependencies:
- composer
- phpunit
script:
- php vendor/bin/phplint
when: on_success
codestyle:
stage: checking
dependencies:
- composer
- phpunit
script:
- php vendor/bin/phpcs
when: on_success
phpcpd:
stage: checking
script:
- test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
- php phpcpd.phar --exclude app/Ship/core app
dependencies:
- composer
- phpunit
cache:
paths:
- phpcpd.phar
when: on_success
sensiolabs:
stage: security
script:
- test -d security-checker || git clone https://github.com/sensiolabs/security-checker.git
- cd security-checker
- composer install
- php security-checker security:check ../composer.lock
dependencies:
- composer
cache:
paths:
- security-checker/
when: on_success
staging:
stage: deploy
script:
- *init_ssh
- *change_file_permissions
- php artisan deploy asanato.ir -s upload
environment:
name: staging
url: https://api.asanato.ir
only:
- staging
when: manual
production:
stage: deploy
script:
- *init_ssh
- *change_file_permissions
- php artisan deploy asanpay.com -s upload
environment:
name: production
url: https://api.asanpay.com
when: manual
only:
- master
- production