-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (107 loc) · 3.93 KB
/
test.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
name: Test Build
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-24.04
runs-on: ${{ matrix.os }}
steps:
- name: Install cbdinocluster
shell: python
run: |
import os
import platform
import urllib.request
home_bin_path = os.path.expanduser("~/bin")
os.makedirs(home_bin_path, exist_ok=True)
cbdinocluster_filename = "cbdinocluster-windows-amd64.exe" if platform.system() == "Windows" else "cbdinocluster-linux-amd64"
cbdinocluster_url = f"https://github.com/couchbaselabs/cbdinocluster/releases/download/v0.0.46/{cbdinocluster_filename}"
cbdinocluster_path = os.path.join(home_bin_path, 'cbdinocluster')
urllib.request.urlretrieve(cbdinocluster_url, cbdinocluster_path)
if platform.system() != "Windows":
os.chmod(cbdinocluster_path, 0o755)
github_path = os.getenv("GITHUB_PATH")
if github_path:
with open(github_path, "a") as f:
f.write(f"{home_bin_path}\n")
- name: Initialize cbdinocluster
shell: python
run: |
import os
import platform
import subprocess
subprocess.run(['cbdinocluster', '-v', 'init', '--auto', '--disable-aws', '--disable-azure', '--disable-capella', '--disable-k8s'])
- name: Start Couchbase Cluster
shell: python
run: |
import os
import platform
import subprocess
def capture_output(command):
result = subprocess.run(command, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
return result.stdout.strip()
cluster_config = """\
nodes:
- count: 2
version: 7.6.1
services:
- kv
- n1ql
- index
- count: 1
version: 7.6.1
services:
- kv
- fts
- cbas
- eventing
docker:
kv-memory: 1600
"""
with open("cluster.yaml", "w") as f:
f.write(cluster_config)
subprocess.run(['cbdinocluster', '-v', 'allocate', '--def-file', 'cluster.yaml'])
cluster_id = capture_output(['cbdinocluster', '-v', 'allocate', '--def-file', 'cluster.yaml'])
connection_string = capture_output(['cbdinocluster', '-v', 'connstr', cluster_id])
subprocess.run(['cbdinocluster', '-v', 'buckets', 'add', cluster_id, 'default', '--ram-quota-mb=100', '--flush-enabled=true'])
subprocess.run(['cbdinocluster', '-v', 'buckets', 'load-sample', cluster_id, 'travel-sample'])
github_env = os.getenv("GITHUB_ENV")
if github_env:
with open(github_env, "a") as f:
f.write(f"CLUSTER_ID={cluster_id}\n")
f.write(f"CONNECTION_STRING={connection_string}\n")
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build
timeout-minutes: 60
shell: python
run: |
import os
import subprocess
os.mkdir('build')
print("##[group]CMake Configure")
subprocess.run(['cmake', '-S', '.', '-B', 'build'])
print("##[endgroup]")
print("##[group]CMake Build")
subprocess.run(['cmake', '--build', 'build'])
- name: Run
timeout-minutes: 60
shell: python
run: |
import os
import subprocess
for root, _, files in os.walk('build'):
for file in files:
filepath = os.path.join(root, file)
if os.access(filepath, os.X_OK) or filepath.endswith('.exe'):
print(f"##[group]{filepath}")
subprocess.run(filepath)
print("##[endgroup]")