This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
135 lines (125 loc) · 4.81 KB
/
.gitlab-ci.yml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: python:3.10
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
GITLAB: gitlab.devops.telekom.de
key: "${CI_COMMIT_REF_SLUG}"
DARWIN_AMD64_BINARY: "netplanner-darwin-amd64-${CI_COMMIT_TAG}"
LINUX_AMD64_BINARY: "netplanner-linux-amd64-${CI_COMMIT_TAG}"
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/netplanner/${CI_COMMIT_TAG}/"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
stages:
- build
- test
- upload
- dist
build:
tags:
- otc_run_docker_k8s
stage: build
image: python:3.10
before_script:
- python -V # Print out python version for debugging
- pip install poetry
- poetry config virtualenvs.in-project true
- poetry --version
- poetry install
script:
- poetry build
- poetry run pyoxidizer build --release
# an alternative approach is to install and run:
- pip install dist/*.whl
# run the command here
- netplanner --help
- mkdir -p bin/
- cp build/x86_64-unknown-linux-gnu/release/install/netplanner "bin/${LINUX_AMD64_BINARY}"
- chmod 0644 "bin/${LINUX_AMD64_BINARY}"
- strip "bin/${LINUX_AMD64_BINARY}"
artifacts:
expire_in: 30 days
paths:
- bin/*
- dist/*.whl
- dist/*.tar.gz
test:
stage: test
image: ubuntu:20.04
tags:
- otc_run_docker_k8s
script:
- chmod +x bin/${LINUX_AMD64_BINARY}
- bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/worker-config-old.yaml --output /run/systemd/networkd/worker-old configure
- bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/worker-config-new.yaml --output /run/systemd/networkd/worker-new configure
- bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/master-config-old.yaml --output /run/systemd/networkd/master-old configure
- bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/master-config-new.yaml --output /run/systemd/networkd/master-new configure
- bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/veth-trial.yaml --output /run/systemd/networkd/veth-trial configure
- bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/5g-worker --output /run/systemd/networkd/folder/5g-worker configure
- bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/5g-worker.yaml --output /run/systemd/networkd/5g-worker configure
# enable the netplan apply command
- bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/vm-config --output /run/systemd/networkd/folder/vm-config apply
- bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/vm-config.yaml --output /run/systemd/networkd/vm-config apply
# this should fail
- bin/${LINUX_AMD64_BINARY} --debug --local --only-networkd --config examples/empty --output /run/systemd/networkd/empty configure || true
artifacts:
expire_in: 30 days
paths:
- run/systemd/networkd/*
upload:
tags:
- otc_run_docker_k8s
stage: upload
image: curlimages/curl:latest
script:
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/${LINUX_AMD64_BINARY} ${PACKAGE_REGISTRY_URL}
only:
- tags
dist:
tags:
- otc_run_docker_k8s
stage: dist
image: python:3.10
before_script:
- python -V # Print out python version for debugging
- pip install poetry
- poetry config virtualenvs.in-project true
- poetry install
- poetry --version
- poetry config repositories.gitlab ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi
- poetry config http-basic.gitlab gitlab-ci-token ${CI_JOB_TOKEN}
script:
- poetry build
- poetry publish -r gitlab
only:
- tags
release:
tags:
- otc_run_docker_k8s
stage: dist
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- |
echo "Release: $CI_COMMIT_TAG"
release:
tag_name: $CI_COMMIT_TAG
description: "Release: $CI_COMMIT_TAG"
assets:
links:
- name: "${LINUX_AMD64_BINARY}"
url: "${PACKAGE_REGISTRY_URL}${LINUX_AMD64_BINARY}"
only:
- tags