Skip to content

Commit 5f616c3

Browse files
committed
Merge branch 'ci-for-platform-ui' into 'master'
feat: configure CI pipelines for UI and DLE See merge request postgres-ai/database-lab!425
2 parents 3f0baef + b97f130 commit 5f616c3

File tree

8 files changed

+129
-115
lines changed

8 files changed

+129
-115
lines changed

.gitlab-ci.yml

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ image: golang:1.17
22

33
include:
44
- template: Security/SAST.gitlab-ci.yml
5+
- local: 'web/.gitlab-ci.yml'
56

67
variables:
78
SAST_EXCLUDED_ANALYZERS: "semgrep-sast"
@@ -10,47 +11,60 @@ variables:
1011
stages:
1112
- test
1213
- build-binary
13-
- build-image
14+
- build
1415
- integration-test
16+
- deploy
17+
18+
## Conditions
19+
.except_web_rules:
20+
rules:
21+
- changes:
22+
- web/**/*
23+
when: never
24+
25+
.only_dle_tag_release: &only_tag_release
26+
rules:
27+
- if: $CI_COMMIT_TAG =~ /^v[0-9.]+$/
28+
29+
.only_dle_tag_rc: &only_tag_rc
30+
rules:
31+
- if: $CI_COMMIT_TAG =~ /^v[0-9.]+[\-_]*[a-zA-Z]+[a-zA-Z0-9.\-_]*[a-zA-Z0-9]+$/
32+
33+
.only_dle_master: &only_master
34+
rules:
35+
- !reference [.except_web_rules, rules]
36+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
37+
38+
.only_dle_feature: &only_feature
39+
rules:
40+
- !reference [.except_web_rules, rules]
41+
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
42+
43+
.dle: &dle
44+
rules:
45+
- !reference [.only_dle_master, rules]
46+
- !reference [.only_dle_feature, rules]
47+
- !reference [.only_dle_tag_release, rules]
48+
- !reference [.only_dle_tag_rc, rules]
1549

1650
test:
51+
<<: *dle
1752
stage: test
1853
script:
1954
- make test
2055

2156
lint:
57+
rules:
58+
- !reference [.dle, rules]
2259
stage: test
2360
script:
2461
- make lint
2562

26-
.only_var_template: &only_tag_release
27-
only:
28-
variables:
29-
- $CI_COMMIT_TAG =~ /^v[0-9.]+$/
30-
31-
.only_var_template: &only_tag_rc
32-
only:
33-
variables:
34-
- $CI_COMMIT_TAG =~ /^v[0-9.]+[\-_]*[a-zA-Z]+[a-zA-Z0-9.\-_]*[a-zA-Z0-9]+$/
35-
36-
.only_var_template: &only_master
37-
only:
38-
- master
39-
40-
.only_var_template: &only_feature
41-
only:
42-
refs:
43-
- branches
44-
variables:
45-
- $CI_COMMIT_REF_SLUG != "master"
46-
63+
### Build binary.
4764
build-binary-alpine:
65+
<<: *dle
4866
image: golang:1.17-alpine
4967
stage: build-binary
50-
only:
51-
refs:
52-
- branches
53-
- tags
5468
artifacts:
5569
paths:
5670
- bin
@@ -125,7 +139,7 @@ build-binary-client-rc:
125139

126140
.job_template: &build_image_definition
127141
image: docker:19
128-
stage: build-image
142+
stage: build
129143
artifacts:
130144
paths:
131145
- bin
@@ -341,20 +355,20 @@ build-image-swagger-latest:
341355
stage: integration-test
342356
variables:
343357
IMAGE_TAG: "${CI_COMMIT_REF_SLUG}"
344-
only:
345-
refs:
346-
- branches
347-
variables:
348-
- $CI_COMMIT_REF_SLUG != "master"
349-
changes:
350-
- cmd/**/*
351-
- configs/**/*
352-
- internal/**/*
353-
- pkg/**/*
354-
- test/**/*
355-
- Dockerfile.*
356-
- go.*
357-
- .gitlab-ci.yml
358+
rules:
359+
- changes:
360+
- web/**/*
361+
when: never
362+
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
363+
changes:
364+
- cmd/**/*
365+
- configs/**/*
366+
- internal/**/*
367+
- pkg/**/*
368+
- test/**/*
369+
- Dockerfile.*
370+
- go.*
371+
- .gitlab-ci.yml
358372
script:
359373
- bash test/1.synthetic.sh
360374
- bash test/2.logical_generic.sh

web/.gitlab-ci.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
stages:
2-
- test
3-
- build
4-
- deploy
1+
.only_web: &only_web
2+
rules:
3+
- changes:
4+
- web/**/*
55

66
check_code_style:
7+
<<: *only_web
78
stage: test
89
image: node:16.13.0
910
script:
10-
- npm ci -ws
11-
- npm run lint -w packages/ce
12-
- npm run lint -w packages/platform
11+
- npm --prefix web/ ci -ws
12+
- npm --prefix web/ run lint -w packages/ce
13+
- npm --prefix web/ run lint -w packages/platform
1314

1415
include:
15-
- local: '/packages/ce/.gitlab-ci.yml'
16-
- local: '/packages/platform/.gitlab-ci.yml'
16+
- local: 'web/packages/ce/.gitlab-ci.yml'
17+
- local: 'web/packages/platform/.gitlab-ci.yml'

web/packages/ce/.gitlab-ci.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
stages:
2-
- build
3-
41
# Conditions.
5-
.only_var_template: &only_tag_release
6-
only:
7-
variables:
8-
- $CI_COMMIT_TAG =~ /^[0-9.]+$/
2+
.only_web_feature: &only_web_feature
3+
rules:
4+
- changes:
5+
- web/**/*
6+
if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
97

10-
.only_var_template: &only_feature
11-
only:
12-
refs:
13-
- branches
8+
.only_web_tag_release: &only_web_tag_release
9+
rules:
10+
- if: $CI_COMMIT_TAG =~ /^web\/[0-9.]+$/
1411

1512
# Jobs templates.
16-
.job_template: &build_definition
13+
.build_definition: &build_definition
14+
image: docker:20.10.12
1715
stage: build
1816
services:
1917
- docker:dind
2018
script:
2119
- apk add --no-cache bash
22-
- bash ./packages/ce/ci_docker_build_push.sh
20+
- bash ./web/packages/ce/ci_docker_build_push.sh
2321

2422
# Jobs.
2523
build_basic_image_release:
2624
<<: *build_definition
27-
<<: *only_tag_release
25+
<<: *only_web_tag_release
2826
variables:
2927
REGISTRY_USER: "${DH_CI_REGISTRY_USER}"
3028
REGISTRY_PASSWORD: "${DH_CI_REGISTRY_PASSWORD}"
3129
REGISTRY: "${DH_CI_REGISTRY}"
3230
DOCKER_NAME: "postgresai/ce-ui"
33-
TAGS: "${DOCKER_NAME}:${CI_COMMIT_TAG},${DOCKER_NAME}:latest"
31+
before_script:
32+
- export WEB_VERSION=$(echo ${CI_COMMIT_TAG#"web/"})
33+
- export TAGS="${DOCKER_NAME}:${WEB_VERSION},${DOCKER_NAME}:latest"
3434

3535
build_basic_image_dev:
3636
<<: *build_definition
37-
<<: *only_feature
37+
<<: *only_web_feature
3838
variables:
3939
REGISTRY_USER: "${CI_REGISTRY_USER}"
4040
REGISTRY_PASSWORD: "${CI_REGISTRY_PASSWORD}"
4141
REGISTRY: "${CI_REGISTRY}"
42-
DOCKER_NAME: "registry.gitlab.com/postgres-ai/platform-web/ce-ui"
42+
DOCKER_NAME: "registry.gitlab.com/postgres-ai/database-lab/ce-ui"
4343
TAGS: "${DOCKER_NAME}:${CI_COMMIT_REF_SLUG}"
4444
when: manual

web/packages/ce/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM node:16.13.0-alpine as build
33

44
WORKDIR /app
55

6-
COPY . .
6+
COPY ./web/ .
77

88
RUN npm ci -ws
99

@@ -16,8 +16,8 @@ RUN npm run build -w @postgres.ai/ce
1616
FROM nginx:1.20.1-alpine as run
1717

1818
COPY --from=build /app/packages/ce/build /srv/ce
19-
COPY ./packages/ce/nginx.conf /etc/nginx/conf.d/ce.conf.template
20-
COPY ./packages/ce/docker-entrypoint.sh /
19+
COPY ./web/packages/ce/nginx.conf /etc/nginx/conf.d/ce.conf.template
20+
COPY ./web/packages/ce/docker-entrypoint.sh /
2121

2222
RUN rm -f /etc/nginx/conf.d/default.conf && chmod +x /docker-entrypoint.sh
2323

web/packages/ce/ci_docker_build_push.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ for tag in "${ADDR[@]}"; do
2424
done
2525

2626
set -x
27-
docker build --build-arg API_URL_PREFIX=/api $tags_build --file ./packages/ce/Dockerfile .
27+
docker build --build-arg API_URL_PREFIX=/api $tags_build --file ./web/packages/ce/Dockerfile .
2828
set +x
2929

3030
echo -e "$tags_push" | while read -r tag; do

0 commit comments

Comments
 (0)