-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
182 lines (168 loc) · 6.12 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
178
179
180
181
182
include:
- project: "docker/process-webhooks"
file: "/gitlab/deploy.yml"
variables:
PROJECT_TO_BE_DEPLOYED: "docker/pccd"
stages:
- build
- deploy
- update
build:
image: docker:latest
services:
- docker:dind
before_script:
- export DATETAG=$(date +%Y%m%d-%H%M%S)
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
stage: build
script:
- DOCKER_IMAGE=${CI_REGISTRY_IMAGE}/pccd-web
- docker build -f .docker/web-alpine.prod.Dockerfile --cache-from $DOCKER_IMAGE:latest --tag $DOCKER_IMAGE:$CI_COMMIT_SHA --tag $DOCKER_IMAGE:$DATETAG --tag $DOCKER_IMAGE:latest --build-arg ARG_MYSQL_DB=$MYSQL_DB --build-arg ARG_MYSQL_USER=$MYSQL_USER --build-arg ARG_MYSQL_PWD=$MYSQL_PWD --build-arg ARG_WEB_ADMIN_PWD=$WEB_ADMIN_PWD .
- docker push $DOCKER_IMAGE:$CI_COMMIT_SHA
- docker push $DOCKER_IMAGE:$DATETAG
- docker push $DOCKER_IMAGE:latest
- DOCKER_IMAGE=${CI_REGISTRY_IMAGE}/pccd-sql
- docker build -f .docker/sql.prod.Dockerfile --cache-from $DOCKER_IMAGE:latest --tag $DOCKER_IMAGE:$CI_COMMIT_SHA --tag $DOCKER_IMAGE:$DATETAG --tag $DOCKER_IMAGE:latest --build-arg ARG_MYSQL_ROOT_PWD=$MYSQL_ROOT_PWD --build-arg ARG_MYSQL_DB=$MYSQL_DB --build-arg ARG_MYSQL_USER=$MYSQL_USER --build-arg ARG_MYSQL_PWD=$MYSQL_PWD .
- docker push $DOCKER_IMAGE:$CI_COMMIT_SHA
- docker push $DOCKER_IMAGE:$DATETAG
- docker push $DOCKER_IMAGE:latest
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
.setup:
before_script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update && apt-get upgrade -y && xargs apt-get install --no-install-recommends -y < apt_packages.txt
- npm ci --ignore-scripts
- php -d memory_limit=256M tools/phive install --force-accept-unsigned --trust-gpg-keys 12CE0F1D262429A5,CBB3D576F2A0946F,C00543248C87FB13,E82B2FB314E9906E,A978220305CD5C32,4AA394086372C20A || echo "Failed to import keys"
- tools/composer.phar install
.php_lint_template:
stage: build
script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update && apt-get upgrade -y && apt-get install --no-install-recommends -y git unzip gpg wget
- curl -L https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions > /usr/local/bin/install-php-extensions
- chmod +x /usr/local/bin/install-php-extensions
- install-php-extensions gd intl pdo_mysql
- php -d memory_limit=256M tools/phive install --force-accept-unsigned --trust-gpg-keys 12CE0F1D262429A5,CBB3D576F2A0946F,C00543248C87FB13,E82B2FB314E9906E,A978220305CD5C32,4AA394086372C20A || echo "Failed to import keys"
- php tools/composer.phar install
- php tools/composer.phar run parallel-lint
- php tools/composer.phar run composer-normalize-lint
- php tools/composer.phar run phpcs
- |
if [[ "${PHP_VERSION}" == "8.4-rc" ]]; then
export PHP_CS_FIXER_IGNORE_ENV=1
fi
- php tools/composer.phar run php-cs-fixer-lint
- php tools/composer.phar run phpstan
- php tools/composer.phar run rector-lint
- |
if [[ "${PHP_VERSION}" != "8.4-rc" ]]; then
php tools/composer.phar run psalm
fi
- php tools/composer.phar run phpunit
allow_failure: true
php_lint:
extends: .php_lint_template
parallel:
matrix:
- PHP_VERSION: "8.2"
- PHP_VERSION: "8.3"
- PHP_VERSION: "8.4-rc"
image: php:${PHP_VERSION}
before_script:
- echo "Running in PHP version ${PHP_VERSION}"
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
.npm_lint_template:
stage: build
script:
- npm ci --ignore-scripts
- npm run lint:eslint
- npm run lint:ls
- npm run lint:markdown
- npm run lint:stylelint
- npm run lint:prettier
allow_failure: true
npm_lint:
extends: .npm_lint_template
parallel:
matrix:
- NODE_VERSION: 20
- NODE_VERSION: 22
image: node:${NODE_VERSION}
before_script:
- echo "Running in Node.js version ${NODE_VERSION}"
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
.check_code_template:
extends: .setup
stage: build
script:
- tools/composer.phar run parallel-lint
- npm run check:size
- npm run lint
- npm run analysis
- npm run test:phpunit
allow_failure: true
check_code_ubuntu:
extends: .check_code_template
image: ubuntu:rolling
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
check_code_debian:
extends: .check_code_template
image: debian:testing
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
nightly_update:
extends: .setup
image: debian:testing
stage: update
script:
- npm run update
- |
if [ -n "$(git status --porcelain)" ]; then
git config --global user.email "[email protected]"
git config --global user.name "PCCD Bot"
git remote set-url origin https://oauth2:[email protected]/pere/pccd.git
git branch -D nightly-update || true
git checkout -b nightly-update
git add .
HUSKY=0 git commit -m "chore(deps): update dependencies"
git push origin nightly-update --force
MR_EXISTS=$(curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gitlab.softcatala.org/api/v4/projects/14/merge_requests?state=opened&source_branch=nightly-update")
if [ "$MR_EXISTS" == "[]" ]; then
curl --request POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
--data "title=chore(deps): update dependencies&source_branch=nightly-update&target_branch=master" \
"https://gitlab.softcatala.org/api/v4/projects/14/merge_requests"
else
echo "Merge request already exists"
fi
else
echo "No changes to commit"
exit 0
fi
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
- when: manual
needs: []
deploy:
stage: deploy
when: manual
extends:
- .default-deploy
reset:
stage: deploy
when: manual
extends:
- .reset