Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Commit 59b17c8

Browse files
committed
refactor gitlab-ci.yml, add guards for jobs
1 parent 8ac2161 commit 59b17c8

File tree

1 file changed

+41
-33
lines changed

1 file changed

+41
-33
lines changed

.gitlab-ci.yml

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ Build Documentation:
2222
artifacts:
2323
paths:
2424
- public
25+
only:
26+
changes:
27+
- documentation/**/*
2528

26-
.Pytest:
29+
Pytest:
2730
image: python:3.7
2831
stage: test
2932
services:
@@ -33,8 +36,8 @@ Build Documentation:
3336
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/postgres"
3437
DJANGO_SETTINGS_MODULE: "backend.settings.gitlab-ci"
3538
SECRET_KEY: "secret"
36-
STACK_NAME: 'my-stack'
37-
DEBUG: ""
39+
STACK_NAME: 'placeholder'
40+
DEBUG: "True"
3841
before_script:
3942
- cd backend
4043
- pip install -r requirements/test.txt
@@ -45,8 +48,11 @@ Build Documentation:
4548
after_script:
4649
- echo "Pytest tests complete"
4750
coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
51+
only:
52+
changes:
53+
- backend/**/*
4854

49-
.Jest:
55+
Jest:
5056
image: node:8
5157
stage: test
5258
before_script:
@@ -58,28 +64,9 @@ Build Documentation:
5864
after_script:
5965
- echo "Jest tests complete"
6066
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
61-
62-
.Build nginx for e2e:
63-
stage: build
64-
image: docker:stable
65-
variables:
66-
DOCKER_HOST: tcp://docker:2375
67-
DOCKER_DRIVER: overlay2
68-
services:
69-
- docker:dind
70-
before_script:
71-
- |
72-
docker login \
73-
-u $CI_REGISTRY_USER \
74-
-p $CI_REGISTRY_PASSWORD \
75-
$CI_REGISTRY
76-
script:
77-
- |
78-
docker build \
79-
--build-arg BASE_URL=http://backend:8000 \
80-
-t $CI_REGISTRY_IMAGE/frontend:latest \
81-
-f nginx/ci/Dockerfile .
82-
- docker push $CI_REGISTRY_IMAGE/frontend:latest
67+
only:
68+
changes:
69+
- quasar/**/*
8370

8471
Build backend:
8572
stage: build
@@ -136,7 +123,8 @@ e2e: &cypress
136123
paths:
137124
- backend/cypress/videos/
138125
- backend/cypress/screenshots/
139-
expire_in: 7 days
126+
expire_in: 2 days
127+
retry: 2
140128

141129
# use this test with gitlab-runner locally
142130
.e2e-local:
@@ -180,13 +168,22 @@ Release backend:
180168
- apk add --no-cache curl jq python py-pip
181169
- pip install awscli
182170
script:
183-
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
171+
- |
172+
docker login \
173+
-u $CI_REGISTRY_USER \
174+
-p $CI_REGISTRY_PASSWORD \
175+
$CI_REGISTRY
184176
- docker pull $CI_REGISTRY_IMAGE:latest || true
185-
- docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $REPOSITORY_URL:${GitSHA} -f scripts/prod/Dockerfile .
177+
- |
178+
docker build \
179+
--cache-from $CI_REGISTRY_IMAGE:latest \
180+
--target production \
181+
--tag $REPOSITORY_URL:${GitSHA} \
182+
--file scripts/prod/Dockerfile .
186183
- $(aws ecr get-login --no-include-email --region us-east-1)
187184
- docker push $REPOSITORY_URL:${GitSHA}
188185
after_script:
189-
- echo "Release backend complete"
186+
- echo "The production image has been released from the GitLab to ECR"
190187

191188
Sync Quasar PWA Assets:
192189
image: python:3.7
@@ -200,9 +197,20 @@ Sync Quasar PWA Assets:
200197
- pip install awscli
201198
- aws iam get-user
202199
script:
203-
- aws s3 sync --delete --exclude index.html --exclude service-worker.js ./dist/pwa/ s3://${AppUrl}/
204-
- aws s3 cp --cache-control 'max-age=0' ./dist/pwa/index.html s3://${AppUrl}/
205-
- aws s3 cp --cache-control 'max-age=0' ./dist/pwa/service-worker.js s3://${AppUrl}/
200+
- |
201+
aws s3 sync \
202+
--delete \
203+
--exclude index.html \
204+
--exclude service-worker.js \
205+
./dist/pwa/ s3://${AppUrl}/
206+
- |
207+
aws s3 cp \
208+
--cache-control 'max-age=0'
209+
./dist/pwa/index.html s3://${AppUrl}/
210+
- |
211+
aws s3 cp \
212+
--cache-control 'max-age=0' \
213+
./dist/pwa/service-worker.js s3://${AppUrl}/
206214
after_script:
207215
- echo "Deploy frontend complete"
208216

0 commit comments

Comments
 (0)