summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: ec53804c3ef9496f46ec10022663605f11c20c96 (plain)
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
stages:
  - lint
  - build
  - push
  - test
  - publish

variables:
  ESLINT_PATHS: js plugins
  REGISTRY_PROJECT: cthulhoo
  IMAGE_TAR_FPM: image-fpm.tar
  IMAGE_TAR_WEB: image-web.tar

include:
  - project: 'ci/ci-templates'
    ref: master
    file: .ci-build-docker-kaniko.yml
  - project: 'ci/ci-templates'
    ref: master
    file: .ci-registry-push.yml
  - project: 'ci/ci-templates'
    ref: master
    file: .ci-lint-common.yml
  - project: 'ci/ci-templates'
    ref: master
    file: .ci-integration-test.yml
  - project: 'ci/ci-templates'
    ref: master
    file: .ci-update-helm-imagetag.yml

phpunit:
  extends: .phpunit
  variables:
    PHPUNIT_ARGS: --exclude integration --coverage-filter classes --coverage-filter include

eslint:
  extends: .eslint

phpstan:
  extends: .phpstan

ttrss-fpm-pgsql-static:build:
  extends: .build-docker-kaniko-no-push
  variables:
    DOCKERFILE: ${CI_PROJECT_DIR}/.docker/app/Dockerfile
    IMAGE_TAR: ${IMAGE_TAR_FPM}

ttrss-fpm-pgsql-static:push-master-commit-only:
  extends: .crane-image-registry-push-master-commit-only
  variables:
    IMAGE_TAR: ${IMAGE_TAR_FPM}
  needs:
    - job: ttrss-fpm-pgsql-static:build

ttrss-fpm-pgsql-static:push-branch:
  extends: .crane-image-registry-push-branch
  variables:
    IMAGE_TAR: ${IMAGE_TAR_FPM}
  needs:
    - job: ttrss-fpm-pgsql-static:build

ttrss-web-nginx:build:
  extends: .build-docker-kaniko-no-push
  variables:
    DOCKERFILE: ${CI_PROJECT_DIR}/.docker/web-nginx/Dockerfile
    IMAGE_TAR: ${IMAGE_TAR_WEB}

ttrss-web-nginx:push-master-commit-only:
  extends: .crane-image-registry-push-master-commit-only
  variables:
    IMAGE_TAR: ${IMAGE_TAR_WEB}
  needs:
    - job: ttrss-web-nginx:build

ttrss-web-nginx:push-branch:
  extends: .crane-image-registry-push-branch
  variables:
    IMAGE_TAR: ${IMAGE_TAR_WEB}
  needs:
    - job: ttrss-web-nginx:build

phpdoc:
  image: ${PHP_IMAGE}
  stage: publish
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $PHPDOC_DEPLOY_SSH_KEY != null
  script:
    - php83 /phpDocumentor.phar -d classes -d include -t phpdoc --visibility=public
    - mkdir -p ~/.ssh &&
        cp ${PHPDOC_DEPLOY_SSH_KEY} ~/.ssh/id_ed25519 &&
        chmod 0600 ~/.ssh/id_ed25519
    - rsync -av -e 'ssh -o StrictHostKeyChecking=no' phpdoc/ ${PHPDOC_DEPLOY_HOST}:phpdoc/

phpunit-integration:
  image: ${PHP_IMAGE}
  variables:
    TEST_HELM_REPO: oci://registry.fakecake.org/infra/helm-charts/tt-rss
  extends: .integration-test
  script:
    - export K8S_NAMESPACE=$(kubectl get pods -o=custom-columns=NS:.metadata.namespace | tail -1)
    - export API_URL="http://tt-rss-${CI_COMMIT_SHORT_SHA}-app.$K8S_NAMESPACE.svc.cluster.local/tt-rss/api/"
    - export TTRSS_DB_HOST=tt-rss-${CI_COMMIT_SHORT_SHA}-app.$K8S_NAMESPACE.svc.cluster.local
    - export TTRSS_DB_USER=postgres
    - export TTRSS_DB_NAME=postgres
    - export TTRSS_DB_PASS=password
    - php83 vendor/bin/phpunit --group integration --do-not-cache-result --log-junit phpunit-report.xml --coverage-cobertura phpunit-coverage.xml --coverage-text --colors=never
  artifacts:
    when: always
    reports:
      junit: phpunit-report.xml
      coverage_report:
        coverage_format: cobertura
        path: phpunit-coverage.xml
  coverage: '/^\s*Lines:\s*\d+.\d+\%/'

selenium:
  image: ${SELENIUM_IMAGE}
  variables:
    TEST_HELM_REPO: oci://registry.fakecake.org/infra/helm-charts/tt-rss
    SELENIUM_GRID_ENDPOINT: http://selenium-hub.selenium-grid.svc.cluster.local:4444/wd/hub
  extends: .integration-test
  script:
    - export K8S_NAMESPACE=$(kubectl get pods -o=custom-columns=NS:.metadata.namespace | tail -1)
    - python3 tests/integration/selenium_test.py
  needs:
    - job: phpunit-integration
  artifacts:
    when: always
    reports:
      junit: selenium-report.xml

ttrss-fpm-pgsql-static:publish:
  stage: publish
  extends: .crane-image-registry-push-master
  variables:
    IMAGE_TAR: ${IMAGE_TAR_FPM}
  needs:
    - job: ttrss-fpm-pgsql-static:build
    - job: phpunit-integration
    - job: selenium

ttrss-fpm-pgsql-static:publish-docker-hub:
  stage: publish
  extends: .crane-image-registry-push-master-docker-hub
  variables:
    IMAGE_TAR: ${IMAGE_TAR_FPM}
  needs:
    - job: ttrss-fpm-pgsql-static:build
    - job: phpunit-integration
    - job: selenium

ttrss-fpm-pgsql-static:publish-gitlab:
  stage: publish
  extends: .crane-image-registry-push-master-gitlab
  variables:
    IMAGE_TAR: ${IMAGE_TAR_FPM}
  needs:
    - job: ttrss-fpm-pgsql-static:build
    - job: phpunit-integration
    - job: selenium

ttrss-web-nginx:publish:
  stage: publish
  extends: .crane-image-registry-push-master
  variables:
    IMAGE_TAR: ${IMAGE_TAR_WEB}
  needs:
    - job: ttrss-web-nginx:build
    - job: phpunit-integration
    - job: selenium

ttrss-web-nginx:publish-docker-hub:
  stage: publish
  extends: .crane-image-registry-push-master-docker-hub
  variables:
    IMAGE_TAR: ${IMAGE_TAR_WEB}
  needs:
    - job: ttrss-web-nginx:build
    - job: phpunit-integration
    - job: selenium

ttrss-web-nginx:publish-gitlab:
  stage: publish
  extends: .crane-image-registry-push-master-gitlab
  variables:
    IMAGE_TAR: ${IMAGE_TAR_WEB}
  needs:
    - job: ttrss-web-nginx:build
    - job: phpunit-integration
    - job: selenium

update-demo:
  stage: publish
  extends: .update-helm-imagetag
  variables:
    CHART_REPO: gitlab.fakecake.org/git/helm-charts/tt-rss.git
    CHART_VALUES: values-demo.yaml
    ACCESS_TOKEN: ${DEMO_HELM_TOKEN}
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $DEMO_HELM_TOKEN != null

update-prod:
  stage: publish
  extends: .update-helm-imagetag
  variables:
    CHART_REPO: gitlab.fakecake.org/git/helm-charts/tt-rss-prod.git
    CHART_VALUES: values-prod.yaml
    ACCESS_TOKEN: ${PROD_HELM_TOKEN}
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $PROD_HELM_TOKEN != null