-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (127 loc) · 4.81 KB
/
test.yaml
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
name: Test K8S demo
on:
pull_request:
branches:
- main
- dev
env:
K8S_HOST: ${{ vars.YC_OS_K8S_HOST }}
YC_DEMO_REGISTRY_ID: ${{ vars.YC_DEMO_REGISTRY_ID }}
HELM_CHART_VERSION: ${{ vars.HELM_CHART_VERSION }}
CONTOUR: testing
jobs:
start-vm:
name: Start VM
runs-on: trampoline
outputs:
label: ${{ steps.start-yc-runner.outputs.label }}
instance-id: ${{ steps.start-yc-runner.outputs.instance-id }}
steps:
- name: Start YC runner
id: start-yc-runner
uses: yc-actions/yc-github-runner@v1
with:
mode: start
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
folder-id: ${{ vars.YC_FOLDER_ID }}
image-id: ${{ vars.YC_DEFAULT_IMAGE_ID }}
zone-id: ${{ vars.YC_ZONE_ID }}
subnet-id: ${{ vars.YC_SUBNET_ID }}
cores: 16
memory: 32GB
core-fraction: 100
disk-type: network-ssd-nonreplicated
disk-size: 93GB
checkout:
name: Checkout sources
needs: start-vm
runs-on: ${{ needs.start-vm.outputs.label }}
steps:
- name: Checkout
uses: actions/checkout@v3
check:
name: Run checks
needs:
- start-vm
- checkout
runs-on: ${{ needs.start-vm.outputs.label }}
timeout-minutes: 70
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
sudo apt-get -y install libpq-dev jq
python -m pip install --upgrade pip
pip install -r requirements.txt -r dev.requirements.txt
- name: Run tests
shell: bash
run: |
export HOME=/root
export HELM_EXPERIMENTAL_OCI=1
export PATH=/usr/local/bin:$PATH
echo '${{ secrets.YC_SA_JSON_CREDENTIALS }}' > sa.json
yc config set service-account-key sa.json
yc iam create-token > /dev/null
/usr/local/bin/yc managed-kubernetes cluster get-credentials --id catam8govqco1ladv4gv --internal --force
echo $(yc iam create-token) | helm registry login cr.yandex -u iam --password-stdin
yc container registry configure-docker
namespace=$(date +"%Y%m%d-%H%M")${INVOCATION_ID:0:2}
name_cluster="os${namespace}"
kubectl get MutatingWebhookConfiguration,ValidatingWebhookConfiguration -A
kubectl create namespace ${namespace}
kubectl delete crd chyts.cluster.ytsaurus.tech ytsaurus.cluster.ytsaurus.tech spyts.cluster.ytsaurus.tech remoteexecnodes.cluster.ytsaurus.tech remoteytsaurus.cluster.ytsaurus.tech || true
helm install -n ${namespace} ${name_cluster} oci://cr.yandex/$YC_DEMO_REGISTRY_ID/ytsaurus/helm/ytop-chart --version $HELM_CHART_VERSION
echo "IAM_TOKEN=$(yc iam create-token)" > /tmp/os-demo-env.txt
echo "NAMESPACE_NAME=${namespace}" >> /tmp/os-demo-env.txt
echo "NAMESPACE_NAME=${namespace}" >> $GITHUB_ENV
kubectl config view --raw -o json | jq -r '.clusters[0].cluster."certificate-authority-data"' | tr -d '"' | base64 --decode > /tmp/os-demo-certificate_authority
sleep 120
kubectl get services -n ${namespace}
kubectl get pods -n ${namespace}
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
pytest -rA --log-cli-level=INFO --log-level=INFO tests/*
POD_NAME=$(kubectl -n ${namespace} get pods --selector=name=jupyterlab -o=name)
kubectl -n ${namespace} exec -it $POD_NAME -- pytest /home/jovyan/test.py
clean-up:
name: Clean up
needs:
- start-vm
- check
runs-on: ${{ needs.start-vm.outputs.label }}
if: ${{ always() }}
steps:
- name: Unintall operator
shell: bash
run: |
export HOME=/root
namespace=$(cat /tmp/os-demo-env.txt | sed -n '2 p' | awk -F '=' '{print $2}')
name_cluster="os${namespace}"
helm uninstall -n ${namespace} ${name_cluster}
helm list --all-namespaces
- name: Delete namespace
shell: bash
run: |
export HOME=/root
namespace=$(cat /tmp/os-demo-env.txt | sed -n '2 p' | awk -F '=' '{print $2}')
kubectl delete namespace ${namespace}
stop-vm:
name: Stop VM
needs:
- start-vm
- check
- clean-up
runs-on: trampoline
if: ${{ always() }}
steps:
- name: Stop YC runner
uses: yc-actions/yc-github-runner@v1
with:
mode: stop
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-vm.outputs.label }}
instance-id: ${{ needs.start-vm.outputs.instance-id }}