-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
75 lines (66 loc) · 2.25 KB
/
.gitlab-ci.yml
File metadata and controls
75 lines (66 loc) · 2.25 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
stages:
- build
- test
- publish
include:
# DOCS: https://gitlab.internal.sanger.ac.uk/team113sanger/common/cicd-template/-/blob/develop/README.md
- project: 'team113sanger/common/cicd-template'
ref: 0.3.1
file: '.gitlab-ci-components.yml'
#############
# TEMPLATES #
#############
.generic-wo-script-or-rules:
extends:
- .component-variables
- .component-before_script
- .component-tags-shared-large-runner
.specific-variables:
variables:
UNIT_TEST_MOUNT_POINT: /opt/tests
RUN_SCRIPT_MOUNT_POINT: /tmp/run.sh
# We need to set this to 1 to enable BuildKit as the Dockerfile uses BuildKit features to speed up the build
DOCKER_BUILDKIT: 1
PRE_FETCH_BASE_IMAGE: python:3.11-slim
# Incase 'docker compose' build is ever used we want to ensure the image
# does not have sudo. By default CICD jobs do not build with 'docker
# compose' but use 'docker' - so this is just a safety measure.
HAS_SUDO: 0
############
# JOBS #
############
build:
stage: build
extends:
- .generic-wo-script-or-rules
- .specific-variables
- .component-script_docker-build
- .component-rules-except-release
unit-test:
stage: test
extends:
- .generic-wo-script-or-rules
- .specific-variables
- .component-rules-except-release
script:
- echo "*** [SCRIPT] START ***"
- echo "I am a script - I run the Python unit tests in a docker container"
- echo "Unit test against CANDIDATE_IMAGE='${CANDIDATE_IMAGE:?not-set-in-before_script}'"
- docker pull "${CANDIDATE_IMAGE}"
# Test image against unit tests - it requires env vars
- docker run -e TEST_DIR="${UNIT_TEST_MOUNT_POINT}" -v "${PWD}/tests:${UNIT_TEST_MOUNT_POINT}:ro" -v "${PWD}/scripts/docker_run_unit_tests.sh:${RUN_SCRIPT_MOUNT_POINT}:ro" --rm "${CANDIDATE_IMAGE}" ${RUN_SCRIPT_MOUNT_POINT}
- echo "*** [SCRIPT] END ***"
publish-develop:
stage: publish
extends:
- .generic-wo-script-or-rules
- .specific-variables
- .component-script-publish-develop-docker-image
- .component-rules-develop-only
publish-tagged_and_latest_docker_images:
stage: publish
extends:
- .generic-wo-script-or-rules
- .specific-variables
- .component-script-publish-tagged+latest-docker-image
- .component-rules-tag-only