-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
79 lines (72 loc) · 2.85 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
79 lines (72 loc) · 2.85 KB
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
stages:
- lint
- test
- image
# - package
variables:
GIT_STRATEGY: clone
IMAGE_NAME: ${NDIP_DOCKER_REPOSITORY}/${CI_PROJECT_PATH}
before_script:
- curl https://code.ornl.gov/rse-deployment/rse-sharables/raw/master/rse-bash-modules.sh -O
- docker login -u $NDIP_DOCKER_USER -p $NDIP_DOCKER_PASSWORD $NDIP_DOCKER_REPOSITORY
- source rse-bash-modules.sh
- func_rse_docker_cleanup
after_script:
- curl https://code.ornl.gov/rse-deployment/rse-sharables/raw/master/rse-bash-modules.sh -O
- source rse-bash-modules.sh
- func_rse_docker_cleanup
lint-check:
stage: lint
script:
- docker build -f dockerfiles/Dockerfile --target source -t image .
- docker run -u `id -u`:`id -g` image ruff check
- docker run -u `id -u`:`id -g` image ruff format --check
- docker run -u `id -u`:`id -g` image mypy .
- docker run -u `id -u`:`id -g` -w /opt/run/vue image pnpm exec prettier --check .
- docker run -u `id -u`:`id -g` -w /opt/run/vue image pnpm exec eslint .
- docker tag image ${IMAGE_NAME}:src-${CI_COMMIT_SHA}
- docker push ${IMAGE_NAME}:src-${CI_COMMIT_SHA}
tags:
- rse-multi-builder
unit-tests:
stage: test
script:
- mkdir reports
- docker pull ${IMAGE_NAME}:src-${CI_COMMIT_SHA}
- docker run -u `id -u`:`id -g` -v `pwd`/reports:/opt/run/django/reports ${IMAGE_NAME}:src-${CI_COMMIT_SHA} coverage run
- docker run -u `id -u`:`id -g` -v `pwd`/reports:/opt/run/django/reports ${IMAGE_NAME}:src-${CI_COMMIT_SHA} coverage report
- docker run -u `id -u`:`id -g` -v `pwd`/reports:/opt/run/django/reports ${IMAGE_NAME}:src-${CI_COMMIT_SHA} coverage xml -o reports/coverage.xml
- sed -i "s:<source>/src:<source>${CI_BUILDS_DIR}/${CI_PROJECT_PATH}:" reports/coverage.xml
coverage: '/TOTAL.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
when: always
reports:
junit: reports/junit.xml
coverage_report:
coverage_format: cobertura
path: reports/coverage.xml
tags:
- rse-multi-builder
build-image:
stage: image
variables:
OVERWRITE_IMAGE: "false"
when: manual
script:
- docker pull ${IMAGE_NAME}:src-${CI_COMMIT_SHA}
- docker build -f dockerfiles/Dockerfile -t image .
- docker tag image ${IMAGE_NAME}:bin-${CI_COMMIT_SHA}
- docker push ${IMAGE_NAME}:bin-${CI_COMMIT_SHA}
- docker tag image ${IMAGE_NAME}:latest
- docker push ${IMAGE_NAME}:latest
- VERSION=$(cat pyproject.toml | grep "version =" | awk '{ print $3 }' | tr -d '"')
- >
if ! docker pull ${IMAGE_NAME}:${VERSION} || [ "$OVERWRITE_IMAGE" == "true" ]; then
docker tag image ${IMAGE_NAME}:${VERSION}
docker push ${IMAGE_NAME}:${VERSION}
else
echo tag ${VERSION} already exists in ${NDIP_DOCKER_REPOSITORY}. Use OVERWRITE_IMAGE="true", delete image in the repository or change the tag
exit 1
fi
tags:
- rse-multi-builder