Skip to content

Commit 870c579

Browse files
committed
CI impl
1 parent c5c3cb7 commit 870c579

File tree

4 files changed

+239
-0
lines changed

4 files changed

+239
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: "Prepare test environment with Tarantool EE"
2+
description: "Prepares test environment with Tarantool EE"
3+
4+
inputs:
5+
sdk-version:
6+
required: true
7+
type: string
8+
sdk-build:
9+
required: false
10+
type: string
11+
default: release
12+
sdk-gc:
13+
required: false
14+
type: string
15+
default: gc64
16+
sdk-download-token:
17+
required: true
18+
type: string
19+
skip-etcd-install:
20+
description: Whether to skip etcd installation
21+
type: boolean
22+
required: false
23+
default: false
24+
25+
env:
26+
# Note: Use exactly match version of tool, to avoid unexpected issues with test on CI.
27+
GO_VERSION: '1.23.8'
28+
29+
runs:
30+
using: "composite"
31+
steps:
32+
- name: Setup Go
33+
uses: actions/setup-go@v4
34+
with:
35+
go-version: '${{ env.GO_VERSION }}'
36+
37+
- name: Setup python
38+
uses: actions/setup-python@v4
39+
with:
40+
python-version: '${{ env.PYTHON_VERSION }}'
41+
42+
- name: Setup Mage
43+
run: |
44+
git clone https://github.com/magefile/mage
45+
cd mage
46+
go run bootstrap.go
47+
shell: bash
48+
49+
- name: Install build requirements
50+
run: |
51+
sudo apt -y update
52+
sudo apt -y install git gcc make cmake unzip zip fish zsh
53+
shell: bash
54+
55+
- name: Cache Tarantool SDK
56+
id: cache-sdk
57+
uses: actions/cache@v3
58+
with:
59+
path: tarantool-enterprise
60+
key: ${{ matrix.sdk-version }}
61+
62+
- name: Download Tarantool SDK
63+
run: |
64+
ARCHIVE_NAME=tarantool-enterprise-sdk-${{ inputs.sdk-gc }}-${{ inputs.sdk-version }}.tar.gz
65+
ARCHIVE_PATH=$(echo ${{ inputs.sdk-version }} | sed -rn \
66+
's/^([0-9]+)\.([0-9]+)\.([0-9]+-){2}([a-z0-9]+-)?r[0-9]+\.([a-z]+)\.([a-z0-9_]+)$/${{ inputs.sdk-build }}\/\5\/\6\/\1\.\2/p')
67+
curl -O -L \
68+
https://tarantool:${{ inputs.sdk-download-token }}@download.tarantool.io/enterprise/${ARCHIVE_PATH}/${ARCHIVE_NAME}
69+
tar -xzf ${ARCHIVE_NAME}
70+
rm -f ${ARCHIVE_NAME}
71+
source tarantool-enterprise/env.sh
72+
shell: bash
73+
74+
- name: Install tarantool headers
75+
run: |
76+
INCLUDE_DIR=$(./tarantool-enterprise/tarantool --version | gawk \
77+
'/DCMAKE_INSTALL_PREFIX/ {dir=gensub(/.*-DCMAKE_INSTALL_PREFIX=(\/.*) .*/, "\\1", "g", $0); print dir}')
78+
sudo mkdir -p ${INCLUDE_DIR}/include
79+
sudo cp -r tarantool-enterprise/include/tarantool ${INCLUDE_DIR}/include
80+
shell: bash
81+
82+
- name: Add SDK to PATH and set TARANTOOL_SDK_PATH variable
83+
run: |
84+
SDK_PATH="$(realpath tarantool-enterprise)"
85+
echo "${SDK_PATH}" >> ${GITHUB_PATH}
86+
echo "TARANTOOL_SDK_PATH=${SDK_PATH}" >> ${GITHUB_ENV}
87+
shell: bash
88+
89+
- name: Install etcd
90+
uses: ./.github/actions/setup-etcd
91+
if: ${{ inputs.skip-etcd-install == 'false' }}
92+
93+
- name: Build tt
94+
env:
95+
TT_CLI_BUILD_SSL: 'static'
96+
run: mage build
97+
shell: bash
98+
99+
- name: Install test requirements
100+
run: |
101+
sudo apt -y install gdb
102+
pip3 install -r test/requirements.txt
103+
shell: bash
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: 'Setup etcd'
2+
description: 'Download and extract etcd release archive'
3+
inputs:
4+
etcd-version:
5+
description: 'Release name from https://github.com/etcd-io/etcd/releases'
6+
required: false
7+
default: v3.5.9
8+
install-prefix:
9+
description: 'Where to extract the archive'
10+
default: ${{ github.workspace }}/.etcd/bin/
11+
runs:
12+
using: 'composite'
13+
steps:
14+
- shell: bash
15+
env:
16+
BASE_URL: "https://github.com/etcd-io/etcd/releases/download"
17+
ETCD_VER: ${{ inputs.etcd-version }}
18+
INSTALL_PREFIX: ${{ inputs.install-prefix }}
19+
run: |
20+
set -eux
21+
rm -rf ${INSTALL_PREFIX} && mkdir -p ${INSTALL_PREFIX}
22+
23+
OS_NAME="$(uname | tr '[:upper:]' '[:lower:]')"
24+
ARCH=$(uname -m | awk '{print ($0 == "x86_64")?"amd64":"arm64"}')
25+
FILENAME="etcd-${ETCD_VER}-${OS_NAME}-${ARCH}"
26+
if [ "${OS_NAME}" == "linux" ]; then
27+
curl -L "${BASE_URL}/${ETCD_VER}/${FILENAME}.tar.gz" -o "${INSTALL_PREFIX}/${FILENAME}.tar.gz"
28+
tar xvzf "${INSTALL_PREFIX}/${FILENAME}.tar.gz" -C ${INSTALL_PREFIX} --strip-components=1
29+
elif [[ "${OS_NAME}" == "darwin" ]]; then
30+
curl -L "${BASE_URL}/${ETCD_VER}/${FILENAME}.zip" -o "${INSTALL_PREFIX}/${FILENAME}.zip"
31+
unzip "${INSTALL_PREFIX}/${FILENAME}.zip" -d ${INSTALL_PREFIX}
32+
ln -s ${INSTALL_PREFIX}/${FILENAME}/etcd ${INSTALL_PREFIX}/etcd
33+
ln -s ${INSTALL_PREFIX}/${FILENAME}/etcdctl ${INSTALL_PREFIX}/etcdctl
34+
else
35+
echo "Unsupported OS: ${OS_NAME}"
36+
exit 1
37+
fi
38+
39+
- shell: bash
40+
env:
41+
INSTALL_PREFIX: ${{ inputs.install-prefix }}
42+
run: |
43+
set -eux
44+
${INSTALL_PREFIX}/etcd --version
45+
${INSTALL_PREFIX}/etcdctl version 2>/dev/null || ${INSTALL_PREFIX}/etcdctl --version
46+
echo "ETCD_PATH=$(echo $INSTALL_PREFIX)" >> "$GITHUB_ENV"
47+
echo "${INSTALL_PREFIX}" >> "$GITHUB_PATH"

.github/workflows/tkv.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: tkv.yaml
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
types: [ synchronize, labeled ]
8+
pull_request_target:
9+
types: [ labeled ]
10+
11+
env:
12+
# Note: Use exactly match version of tool, to avoid unexpected issues with test on CI.
13+
GO_VERSION: '1.24.9'
14+
15+
16+
jobs:
17+
full-ci-ee:
18+
# Tests will run only when the pull request is labeled with `full-ci`. To
19+
# avoid security problems, the label must be reset manually for every run.
20+
#
21+
# We need to use `pull_request_target` because it has access to base
22+
# repository secrets unlike `pull_request`.
23+
if: (github.event_name == 'push') ||
24+
(github.event_name == 'pull_request_target' &&
25+
github.event.action == 'labeled' &&
26+
github.event.label.name == 'full-ci') ||
27+
(github.event_name == 'pull_request' &&
28+
github.event.action == 'synchronize' &&
29+
github.event.pull_request.head.repo.full_name == github.repository &&
30+
contains(github.event.pull_request.labels.*.name, 'full-ci'))
31+
runs-on: ubuntu-22.04
32+
strategy:
33+
matrix:
34+
sdk-version:
35+
- "3.5.0-0-r70.linux.x86_64"
36+
fail-fast: false
37+
steps:
38+
# `ref` as merge request is needed for pull_request_target because this
39+
# target runs in the context of the base commit of the pull request.
40+
- uses: actions/checkout@v4
41+
if: github.event_name == 'pull_request_target'
42+
with:
43+
fetch-depth: 0
44+
ref: ${{ github.event.pull_request.head.sha }}
45+
46+
- uses: actions/checkout@v4
47+
if: github.event_name != 'pull_request_target'
48+
with:
49+
fetch-depth: 0
50+
51+
- name: Prepare EE env
52+
uses: ./.github/actions/prepare-ee-test-env
53+
with:
54+
sdk-version: '${{ matrix.sdk-version }}'
55+
sdk-download-token: '${{ secrets.SDK_DOWNLOAD_TOKEN }}'
56+
57+
- name: Integration tests
58+
run:
59+
go test ./... -count=1 -v

driver/tkv/integration_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package tkv_test
22

33
import (
44
"context"
5+
"errors"
6+
"flag"
7+
"fmt"
58
"os"
69
"strings"
710
"testing"
@@ -11,6 +14,7 @@ import (
1114
"github.com/stretchr/testify/require"
1215
"github.com/tarantool/go-tarantool/v2"
1316
"github.com/tarantool/go-tarantool/v2/pool"
17+
tcshelper "github.com/tarantool/go-tarantool/v2/test_helpers/tcs"
1418

1519
"github.com/tarantool/go-storage/driver/tkv"
1620
"github.com/tarantool/go-storage/operation"
@@ -739,3 +743,29 @@ func getRevisionFromResponse(t *testing.T, response tx.Response, position int) i
739743

740744
return response.Results[position].Values[0].ModRevision
741745
}
746+
747+
func TestMain(m *testing.M) {
748+
flag.Parse()
749+
750+
tcs, err := tcshelper.Start(0)
751+
switch {
752+
case errors.Is(err, tcshelper.ErrNotSupported):
753+
fmt.Println("TcS is not supported:", err) //nolint:forbidigo
754+
case err != nil:
755+
fmt.Println("Failed to start TCS:", err) //nolint:forbidigo
756+
os.Exit(1)
757+
default:
758+
os.Exit(func() int {
759+
defer tcs.Stop()
760+
761+
// os.Setenv is a temporary hack to set the TARANTOOL_ADDR environment variable.
762+
err := os.Setenv("TARANTOOL_ADDR", strings.Join(tcs.Endpoints(), ","))
763+
if err != nil {
764+
fmt.Println("Failed to set TARANTOOL_ADDR:", err) //nolint:forbidigo
765+
return 1
766+
}
767+
768+
return m.Run()
769+
}())
770+
}
771+
}

0 commit comments

Comments
 (0)