Skip to content

Commit 55c8d92

Browse files
committed
feat: standardize frontend pipeline paths with FRONTEND_DIR var
Ticket: none Changelog: Refactored the frontend pipeline to use a centralized FRONTEND_DIR variable instead of hardcoded 'frontend' paths and 'cd frontend' commands Signed-off-by: Dusan Haustein <[email protected]>
1 parent d3bdfd2 commit 55c8d92

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

frontend/pipeline.yml

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ variables:
66
DOCS_VERSION: development
77
MENDER_IMAGE_GUI: ${MENDER_IMAGE_REGISTRY}/${MENDER_IMAGE_REPOSITORY}/gui:${MENDER_IMAGE_TAG}
88
FF_TIMESTAMPS: true
9+
FRONTEND_DIR: ${CI_PROJECT_DIR}/frontend
910

1011
test:frontend:lint:
1112
stage: test
@@ -18,10 +19,9 @@ test:frontend:lint:
1819
compare_to: '${RULES_CHANGES_COMPARE_TO_REF}'
1920
needs: []
2021
script:
21-
- cd frontend
22-
- npm ci --cache .npm --prefer-offline
23-
- cd tests/e2e_tests && npm ci && cd ../..
24-
- npm run lint
22+
- npm ci --prefix ${FRONTEND_DIR} --cache ${FRONTEND_DIR}/.npm --prefer-offline
23+
- npm ci --prefix ${FRONTEND_DIR}/tests/e2e_tests
24+
- npm run lint --prefix ${FRONTEND_DIR}
2525
tags:
2626
- k8s
2727

@@ -38,9 +38,9 @@ test:frontend:license-headers:
3838
before_script:
3939
- apt update && apt install git -yq
4040
script:
41-
- deno task --cwd frontend/scripts licenseCheck --rootDir $(pwd)
42-
- git diff --exit-code frontend/src
43-
- git diff --exit-code frontend/tests
41+
- deno task --cwd ${FRONTEND_DIR}/scripts licenseCheck --rootDir ${CI_PROJECT_DIR}
42+
- git diff --exit-code ${FRONTEND_DIR}/src
43+
- git diff --exit-code ${FRONTEND_DIR}/tests
4444

4545
test:frontend:licenses:
4646
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/denoland/deno:debian-2.0.2
@@ -55,13 +55,12 @@ test:frontend:licenses:
5555
- job: build:frontend:docker
5656
artifacts: true
5757
before_script:
58-
- cd frontend
5958
- apt-get update && apt-get install -yq curl
6059
- curl -fsSL https://deb.nodesource.com/setup_23.x | bash
6160
- apt-get install -yq nodejs
62-
- npm ci
61+
- npm ci --prefix ${FRONTEND_DIR}
6362
script:
64-
- deno run --allow-env --allow-read --allow-sys tests/licenses/licenseCheck.ts --rootDir $(pwd)
63+
- deno run --allow-env --allow-read --allow-sys --config ${FRONTEND_DIR}/scripts/deno.json ${FRONTEND_DIR}/tests/licenses/licenseCheck.ts --rootDir ${FRONTEND_DIR}
6564
tags:
6665
- k8s
6766

@@ -78,15 +77,14 @@ test:frontend:unit:
7877
needs: []
7978
timeout: 10 minutes
8079
script:
81-
- cd frontend
82-
- npm ci
83-
- npm run test -- --reporter=default --reporter=junit --outputFile.junit=./junit.xml --coverage
80+
- npm ci --prefix ${FRONTEND_DIR}
81+
- npm run test --prefix ${FRONTEND_DIR} -- --reporter=default --reporter=junit --outputFile.junit=${FRONTEND_DIR}/junit/junit.xml --coverage
8482
artifacts:
8583
expire_in: 2w
8684
paths:
87-
- frontend/coverage
85+
- ${FRONTEND_DIR}/coverage
8886
reports:
89-
junit: frontend/junit.xml
87+
junit: ${FRONTEND_DIR}/junit/junit.xml
9088
when: always
9189
tags:
9290
- k8s
@@ -103,9 +101,8 @@ test:frontend:docs-links:
103101
needs: []
104102
before_script:
105103
- apk add --no-cache curl
106-
- cd frontend
107104
script:
108-
- links=$(grep -r docs.mender.io src/ | grep -v snapshots | sed -e 's,\${docsVersion},'${DOCS_VERSION}'/,g' | sed -e 's,\${path},''/,g' | egrep -o 'https?://[^ `"]+' | sort | uniq)
105+
- links=$(grep -r docs.mender.io ${FRONTEND_DIR}/src/ | grep -v snapshots | sed -e 's,\${docsVersion},'${DOCS_VERSION}'/,g' | sed -e 's,\${path},''/,g' | egrep -o 'https?://[^ `"]+' | sort | uniq)
109106
- error=0
110107
- |
111108
for url in $links; do
@@ -139,11 +136,13 @@ build:frontend:docker:
139136
- if: '$CI_COMMIT_REF_PROTECTED == "true"'
140137
when: always
141138
script:
142-
- cd frontend
143-
- if test -z "${DOCKER_PLATFORM}"; then
144-
- docker context create ci;
145-
- fi
146-
- docker buildx create ${DOCKER_BUILDKITARGS} --name gui-builder --driver=docker-container ci
139+
- |
140+
if test -z "${DOCKER_PLATFORM}"; then
141+
docker context create ci;
142+
fi
143+
- docker buildx create ${DOCKER_BUILDKITARGS}
144+
--name gui-builder
145+
--driver=docker-container ci
147146
# build production target
148147
- docker build
149148
--tag ${MENDER_IMAGE_GUI}
@@ -156,13 +155,15 @@ build:frontend:docker:
156155
--platform ${DOCKER_PLATFORM:-linux/amd64}
157156
--provenance false
158157
--push
159-
.
158+
${FRONTEND_DIR}
160159
- docker context use ci
161-
- docker run --rm --entrypoint "/bin/sh" -v $(pwd):/extract ${MENDER_IMAGE_GUI} -c "cp licenses.json /extract/"
160+
- docker run --rm --entrypoint "/bin/sh"
161+
-v ${FRONTEND_DIR}:/extract ${MENDER_IMAGE_GUI}
162+
-c "cp licenses.json /extract/"
162163
artifacts:
163164
expire_in: 1w
164165
paths:
165-
- frontend/licenses.json
166+
- ${FRONTEND_DIR}/licenses.json
166167

167168
.template:test:frontend:acceptance:
168169
stage: test
@@ -199,20 +200,20 @@ build:frontend:docker:
199200
artifacts:
200201
expire_in: 2w
201202
paths:
202-
- frontend/coverage
203-
- frontend/screenshots
204-
- frontend/junit
203+
- ${FRONTEND_DIR}/coverage
204+
- ${FRONTEND_DIR}/screenshots
205+
- ${FRONTEND_DIR}/junit
205206
reports:
206207
junit:
207-
- frontend/junit/results.xml
208+
- ${FRONTEND_DIR}/junit/results.xml
208209
when: always
209210
tags:
210211
- hetzner-amd-ax42
211212

212213
test:frontend:acceptance:
213214
extends: .template:test:frontend:acceptance
214215
script:
215-
- ./frontend/tests/e2e_tests/run
216+
- ${FRONTEND_DIR}/tests/e2e_tests/run
216217

217218
test:frontend:acceptance:enterprise:
218219
extends: .template:test:frontend:acceptance
@@ -225,7 +226,7 @@ test:frontend:acceptance:enterprise:
225226
- unset MENDER_IMAGE_REGISTRY MENDER_IMAGE_REPOSITORY
226227
- export MENDER_IMAGE_TAG=main
227228
- docker login -u $REGISTRY_MENDER_IO_USERNAME -p $REGISTRY_MENDER_IO_PASSWORD registry.mender.io
228-
- ./frontend/tests/e2e_tests/run --enterprise
229+
- ${FRONTEND_DIR}/tests/e2e_tests/run --enterprise
229230

230231
.template:publish:frontend:tests:
231232
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/${NODE_IMAGE}
@@ -256,7 +257,7 @@ publish:frontend:tests:
256257
script:
257258
- export COVERALLS_SERVICE_JOB_NUMBER=frontend-unit
258259
- export COVERALLS_FLAG_NAME=frontend-unit
259-
- coveralls < frontend/coverage/lcov.info
260+
- coveralls < ${FRONTEND_DIR}/coverage/lcov.info
260261

261262
publish:frontend:e2e-tests:
262263
extends: .template:publish:frontend:tests
@@ -275,8 +276,8 @@ publish:frontend:e2e-tests:
275276
COVERALLS_SERVICE_JOB_NUMBER: frontend-e2e
276277
COVERALLS_FLAG_NAME: frontend-e2e
277278
script:
278-
- sed -i -re 's/(^[SF:]+[../]+)(.*)$/SF:\2/' frontend/coverage/lcov.info
279-
- coveralls < frontend/coverage/lcov.info
279+
- sed -i -re 's/(^[SF:]+[../]+)(.*)$/SF:\2/' ${FRONTEND_DIR}/coverage/lcov.info
280+
- coveralls < ${FRONTEND_DIR}/coverage/lcov.info
280281

281282
publish:frontend:e2e-tests:enterprise:
282283
extends: publish:frontend:e2e-tests
@@ -346,12 +347,12 @@ publish:frontend:licenses:
346347
- job: build:frontend:docker
347348
artifacts: true
348349
script:
349-
- deno task --cwd frontend/scripts licenseFormatting --rootDir $(pwd)
350+
- deno task --cwd ${FRONTEND_DIR}/scripts licenseFormatting --rootDir ${CI_PROJECT_DIR}
350351
artifacts:
351352
when: on_success
352353
expire_in: 1w
353354
paths:
354-
- frontend/licenses.md
355+
- ${FRONTEND_DIR}/licenses.md
355356

356357
publish:frontend:sentry:finalize:
357358
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/getsentry/sentry-cli

0 commit comments

Comments
 (0)