-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
107 lines (100 loc) · 3.91 KB
/
.gitlab-ci.yml
File metadata and controls
107 lines (100 loc) · 3.91 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
stages:
- build
- test
- release
include:
- component: "$CI_SERVER_FQDN/ees/rdp/generic-components/rdp-cicd-components/kaniko@main"
inputs:
stage-test-image: test
build-args: --build-arg MODBUS_GIT_USER --build-arg MODBUS_GIT_PASSWORD --build-arg TOKEN_PYRDP_COMMONS
# =============================================================================
# Perform the unit test
# =============================================================================
test_python_3_10:
stage: test
needs: [] # no dependencies to precious pipelines stages
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/eclipse-mosquitto:2.1-alpine
alias: mosquitto
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/redis
alias: redis
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/influxdb:2
alias: influxdb
variables:
DOCKER_INFLUXDB_INIT_MODE: "setup"
DOCKER_INFLUXDB_INIT_USERNAME: ${DATA_CRAWLER_INFLUX_USER}
DOCKER_INFLUXDB_INIT_PASSWORD: ${DATA_CRAWLER_INFLUX_PASSWORD}
DOCKER_INFLUXDB_INIT_ORG: "ait"
DOCKER_INFLUXDB_INIT_BUCKET: "ait-bucket"
tags:
- docker
- x86_64
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/python:3.10
variables:
DATA_CRAWLER_MQTT_HOST: "mosquitto"
DATA_CRAWLER_MQTT_PORT: "1883"
DATA_CRAWLER_REDIS_HOST: "redis"
DATA_CRAWLER_REDIS_PORT: "6379"
DATA_CRAWLER_REDIS_DB: 0
# InfluxDB connection settings for the InfluxDB source tests.
DATA_CRAWLER_INFLUX_URL: "http://influxdb:8086"
DATA_CRAWLER_INFLUX_ORG: "ait"
DATA_CRAWLER_INFLUX_USER: ${DATA_CRAWLER_INFLUX_USER}
DATA_CRAWLER_INFLUX_PASSWORD: ${DATA_CRAWLER_INFLUX_PASSWORD}
script:
- pip install --no-cache-dir -r requirements-dev.txt
# Authenticate the third-party dependencies
- poetry config repositories.gitlab-intern-ees-lachs-modbus-crawler https://gitlab-intern.ait.ac.at/ees-lachs/modbus-crawler
- poetry config http-basic.gitlab-intern-ees-lachs-modbus-crawler gitlab-ci-token ${CI_JOB_TOKEN}
- poetry config http-basic.gitlab-pyrdp-commons gitlab-ci-token ${CI_JOB_TOKEN}
# Install the dependencies
- poetry install --with dev --all-extras
# Test the code
- PYTHONPATH="${PYTHONPATH}:.:test" poetry run pytest --cov --cov-report term --cov-report xml:coverage.xml --junitxml=report.xml --log-cli-level=INFO test
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts: # Collect test results
when: always
paths:
- report.xml
reports:
junit: report.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
# =============================================================================
# Build the installable package
# =============================================================================
.build-package:
stage: release
tags:
- docker
- x86_64
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/python:3.10
variables:
VERSION_FORMAT: "{base}.post{distance}.dev+{commit}"
script:
- pip install -r requirements-dev.txt
# Guess the version number (no versioneer needed)
- DST_VERSION=$(dunamai from git --format "${VERSION_FORMAT}")
- echo Write destination version $DST_VERSION
- poetry version "$DST_VERSION"
# Build the project
- poetry build
# Push the package
- poetry config repositories.gitlab-intern ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi
- poetry config http-basic.gitlab-intern gitlab-ci-token ${CI_JOB_TOKEN}
- poetry publish --repository gitlab-intern
build-package-main:
extends: .build-package
variables:
VERSION_FORMAT: "{base}.post{distance}+{commit}"
only:
- main
- master
build-package-development:
extends: .build-package
variables:
VERSION_FORMAT: "{base}.post{distance}.dev+{commit}"
only:
- development
- 44-provide-python-packages-for-project-extension