This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
215 lines (179 loc) · 5.45 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
image: golang:1.20
stages:
- build
- test
- lint
- release
- integration
default:
tags:
- linux
cache:
paths:
- .cache
before_script:
- mkdir -p .cache
- export GOPATH=${CI_PROJECT_DIR}/.cache
test:
stage: test
script:
- make test
staticcheck:
stage: lint
allow_failure: true
before_script:
- go install honnef.co/go/tools/cmd/staticcheck@latest
script:
- make staticcheck
vet:
stage: lint
allow_failure: true
script:
- make vet
oinit:
stage: build
script:
- make oinit
oinit-ca:
stage: build
script:
- make oinit-ca
oinit-shell:
stage: build
script:
- make oinit-shell
oinit-switch:
stage: build
script:
- make oinit-switch
prerelease:
stage: release
image:
name: docker:stable
services:
- docker:dind
only:
refs:
- tags
- prerelease
tags:
- linux
variables:
GIT_STRATEGY: clone
GIT_DEPTH: 0
REPO_HOST: repo.data.kit.edu
REPO_USER: cicd
script:
- if [ -z "$CI_COMMIT_TAG" ]; then docker run --rm -v $PWD:/tmp/oinit -w /tmp/oinit bitnami/git .gitlab-ci-scripts/set-prerel-version.sh; fi;
- .gitlab-ci-scripts/goreleaser.sh && .gitlab-ci-scripts/upload.sh
# after_script:
# - docker run --rm curlimages/curl -d "repo=github.com/lbrocke/oinit" https://goreportcard.com/checks
.setup-repo-deb: &setup-repo-deb
- |
echo "Installing packages..."
apt update
apt install -y curl gpg python3-pip
PIP_BREAK_SYSTEM_PACKAGES=1 pip3 install contextualise-ssh-server
# release
curl https://repo.data.kit.edu/repo-data-kit-edu-key.gpg | gpg --dearmor > /etc/apt/trusted.gpg.d/kitrepo-archive.gpg
echo "deb [signed-by=/etc/apt/trusted.gpg.d/kitrepo-archive.gpg] https://repo.data.kit.edu/${DISTRO}/${RELEASE} ./" > /etc/apt/sources.list.d/kit-repo.list
apt update
apt install -y mytoken oidc-agent motley-cue
# prerel (overwrite release repo because no Suite name is set, therefore targeting repo with 'apt -t' not possible)
curl https://repo.data.kit.edu/devel/automatic-repo-data-kit-edu-key.gpg | gpg --dearmor > /etc/apt/trusted.gpg.d/auto-kitrepo-archive.gpg
echo "deb [signed-by=/etc/apt/trusted.gpg.d/auto-kitrepo-archive.gpg] https://repo.data.kit.edu/prerel/${DISTRO}/${RELEASE} ./" > /etc/apt/sources.list.d/kit-repo.list
apt update
apt install -y oinit oinit-openssh oinit-ca
.setup-repo-rpm: &setup-repo-rpm
- |
echo "Installing packages..."
yum -y install wget python3-pip
pip3 install contextualise-ssh-server
# release
(cd /etc/yum.repos.d; wget https://repo.data.kit.edu/data-kit-edu-${DISTRO}${RELEASE}.repo)
yum makecache
yum -y install oidc-agent motley-cue
# prerel (overwrite release repo because they have the same name, therefore targeting repo with 'yum --enablerepo' not possible)
(cd /etc/yum.repos.d; rm -rf data-kit-edu-*.repo; wget https://repo.data.kit.edu/prerel/data-kit-edu-${DISTRO}${RELEASE}.repo)
yum makecache
yum -y install oinit oinit-openssh oinit-ca mytoken
.run-integration: &run-integration
- |
echo "Getting access token..."
export OIDC=`mytoken AT --MT $MYTOKEN || echo no-token-obtained`
if [ "${OIDC}" = "no-token-obtained" ]; then
echo "Could not obtain OIDC access token."
exit 1
fi
echo "Configuring motley_cue..."
(cd /etc/motley_cue; contextualise_ssh_server $OIDC)
for i in `cat /etc/motley_cue/motley_cue.env`; do export $i; done
/usr/lib/motley-cue/bin/gunicorn motley_cue.api:api -k "uvicorn.workers.UvicornWorker" --config /usr/lib/motley-cue/etc/gunicorn/gunicorn.conf.py > /dev/null &
echo "Configuring sshd..."
echo -e 'y\n' | ssh-keygen -t ed25519 -f /etc/ssh/host-key -N "" > /dev/null
echo -e 'y\n' | ssh-keygen -s /etc/oinit-ca/host-ca -I localhost -h -n localhost /etc/ssh/host-key > /dev/null
echo "
HostKey /etc/ssh/host-key
HostCertificate /etc/ssh/host-key-cert.pub
TrustedUserCAKeys /etc/oinit-ca/user-ca.pub" >> /etc/ssh/sshd_config
sed -i '1s;^;auth [success=ignore default=1] pam_succeed_if.so use_uid user = oinit\nauth sufficient pam_succeed_if.so uid ne 0\n\n;' /etc/pam.d/su
mkdir -p -m0755 /var/run/sshd # https://askubuntu.com/a/1110843
/usr/sbin/sshd > /dev/null &
echo "Configuring oinit-ca..."
echo "
[localhost]
localhost = http://localhost:8080" >> /etc/oinit-ca/config.ini
/usr/sbin/oinit-ca 127.0.0.1:8081 /etc/oinit-ca/config.ini > /dev/null &
echo "Starting ssh-agent..."
eval `ssh-agent`
mkdir -p ~/.ssh/
echo "Waiting for services to start..."
sleep 10
echo "Configuring oinit..."
oinit add localhost http://localhost:8081
echo "Running ssh..."
if [ "$(ssh localhost 'echo -n success')" == "success" ]; then
echo "ssh command succeeded."
else
echo "ssh command failed."
exit 1
fi
debian-bookworm:
stage: integration
only:
refs:
- tags
- prerelease
script:
- *setup-repo-deb
- *run-integration
variables:
DISTRO: debian
RELEASE: bookworm
image: debian:bookworm-slim
ubuntu-jammy:
stage: integration
only:
refs:
- tags
- prerelease
script:
- *setup-repo-deb
- *run-integration
variables:
DISTRO: ubuntu
RELEASE: jammy
image: ubuntu:jammy
fedora-38:
stage: integration
only:
refs:
- tags
- prerelease
script:
- *setup-repo-rpm
- *run-integration
variables:
DISTRO: fedora
RELEASE: 38
image: fedora:38