This repository has been archived by the owner on Mar 27, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
177 lines (153 loc) · 4.52 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
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
176
177
stages:
- build
- test
- coverage
- update
- deploy
build:website:
image: registry.gitlab.com/afonsojramos/feup-8:website-staging
stage: build
artifacts:
untracked: true
script:
- cd Website
- composer install
build:feup-8:
image: registry.gitlab.com/afonsojramos/feup-8:feup-8
stage: build
artifacts:
paths:
- ./FEUP-8/tic80_coverage
- ./FEUP-8/bin/tic80
- ./FEUP-8/release
script:
- apt-get update
- apt-get install lcov -y
- apt-get install zip -y
- cd FEUP-8
- cmake .
- make tic80_coverage
- make -j4
- sh package.sh
test:website:
services:
- name: postgres:11.1-alpine
alias: postgres-db
variables:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: $POSTGRES_PASS
image: registry.gitlab.com/afonsojramos/feup-8:website-staging
stage: test
dependencies:
- build:website
script:
- cd Website
- php artisan migrate:refresh --env=testing
- php artisan db:seed --class=TestsSeeder --env=testing
- php artisan passport:install --env=testing
- ./vendor/bin/phpunit --testdox
- rm -f ./storage/framework/views/*
- wget https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer
- php php-cs-fixer fix -v --dry-run --using-cache=no
- find . -name "*.php" -not -path "./vendor/*" | xargs --max-args=1 php -l
artifacts:
paths:
- ./Website/report
test:feup-8:
image: registry.gitlab.com/afonsojramos/feup-8:feup-8
stage: test
artifacts:
untracked: true
dependencies:
- build:feup-8
script:
- cd FEUP-8/bin
- ./tic80 -test
coverage:pages:
stage: coverage
dependencies:
- test:website
- build:feup-8
script:
- cd ./Website/report
- mv index.html coverage_website.html
- cd ../..
- cd ./FEUP-8/tic80_coverage
- mv index.html coverage_feup8.html
- cp -r . ../../Website/report
- cd ../..
- cp index.html ./Website/report
- mv ./Website/report/ public/
artifacts:
paths:
- public
expire_in: 30 days
only:
- development
update:update-images-development:
image: docker:stable
stage: update
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build ./Website/. -t registry.gitlab.com/afonsojramos/feup-8:website-staging
- docker push registry.gitlab.com/afonsojramos/feup-8:website-staging
only:
- development
update:update-images-master:
image: docker:stable
stage: update
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build ./FEUP-8/. -t registry.gitlab.com/afonsojramos/feup-8:feup-8
- docker push registry.gitlab.com/afonsojramos/feup-8:feup-8
- docker build ./Website/. -t registry.gitlab.com/afonsojramos/feup-8:website-prod
- docker push registry.gitlab.com/afonsojramos/feup-8:website-prod
only:
- master
deploy:website-prod:
image: alpine:latest
stage: deploy
dependencies:
- update:update-images-master
before_script:
- 'which ssh-agent || ( apk update && apk add openssh-client )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh [email protected] "/updateServer.sh prod $APP_KEY $DB_PASSWORD"
environment:
name: production
url: http://prod.feup8.tk
only:
- master
when: manual
deploy:website-staging:
image: alpine:latest
stage: deploy
dependencies:
- update:update-images-development
before_script:
- 'which ssh-agent || ( apk update && apk add openssh-client )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh [email protected] "/updateServer.sh staging $APP_KEY $DB_PASSWORD"
environment:
name: staging
url: http://staging.feup8.tk:2375
only:
- development
when: manual