Skip to content

Commit 40d6e53

Browse files
committed
Initial commit
Publish code, cicd, documents and Makefile
1 parent 8618445 commit 40d6e53

30 files changed

Lines changed: 3626 additions & 1 deletion

.github/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- "cicd"
5+
authors:
6+
- dependabot
7+
categories:
8+
- title: "⚠️ Breaking changes"
9+
labels:
10+
- "breaking"
11+
- title: "🚀 New features"
12+
labels:
13+
- "enhancement"
14+
- title: "📖 Documentation"
15+
labels:
16+
- "documentation"
17+
- title: "🐛 Bug fixes"
18+
labels:
19+
- "bug"
20+
- title: Other Changes
21+
labels:
22+
- "*"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Add New Issues to Drivers-Team Project
2+
3+
on:
4+
issues:
5+
types: [opened,transferred]
6+
7+
workflow_dispatch:
8+
inputs:
9+
issue-id:
10+
type: number
11+
required: true
12+
description: Issue ID
13+
14+
jobs:
15+
add-issue-to-drivers-team:
16+
runs-on: ubuntu-latest
17+
if: ${{ inputs.issue-id == '' }}
18+
uses: scylladb/scylla-drivers/.github/workflows/add-issue-to-driver-team-project.yml@master
19+
with:
20+
issue-id: ${{ github.event.issue.number }}
21+
secrets:
22+
token: ${{ secrets.GIT_PROJECT_TOKEN }}
23+
24+
add-custom-issue-to-drivers-team:
25+
runs-on: ubuntu-latest
26+
if: ${{ inputs.issue-id != '' }}
27+
uses: scylladb/scylla-drivers/.github/workflows/add-issue-to-driver-team-project.yml@master
28+
with:
29+
issue-id: ${{ inputs.issue-id }}
30+
secrets:
31+
token: ${{ secrets.GIT_PROJECT_TOKEN }}

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish Release Notes
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+\.[0-9]+\.[0-9]+*' # Triggers on version tags like v1.0.0
7+
workflow_dispatch:
8+
inputs:
9+
target-tag:
10+
required: true
11+
type: string
12+
description: Target tag to run on
13+
14+
permissions:
15+
contents: write # Required to create release
16+
17+
jobs:
18+
release:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Checkout target tag
26+
if: ${{ inputs.target-tag != '' }}
27+
uses: actions/checkout@v4
28+
with:
29+
ref: ${{ inputs.target-tag }}
30+
31+
- name: Create GitHub Release for ${{ inputs.target-tag }}
32+
if: ${{ inputs.target-tag != '' }}
33+
run: |
34+
gh release create "${{ inputs.target-tag }}" \
35+
--generate-notes \
36+
--title "${{ inputs.target-tag }}"
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Create GitHub Release
41+
if: ${{ inputs.target-tag == '' }}
42+
run: |
43+
gh release create "$GITHUB_REF_NAME" \
44+
--generate-notes \
45+
--title "$GITHUB_REF_NAME"
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: 'Run tests'
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
defaults:
11+
run:
12+
working-directory: ./
13+
14+
jobs:
15+
test:
16+
name: GoLang tests for V1
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 10
19+
20+
steps:
21+
- name: Checkout source
22+
uses: actions/checkout@v4
23+
24+
- name: Install GoLang
25+
uses: actions/setup-go@v4
26+
with:
27+
go-version: "1.24"
28+
go-version-file: "go.work"
29+
30+
- name: Run build
31+
run: |
32+
make build
33+
34+
- name: Run linters
35+
run: |
36+
make check
37+
38+
- name: Run unit tests
39+
run: |
40+
make test-unit
41+
42+
- name: Run integration tests
43+
run: |
44+
make test-integration

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea/
2+
bin/
3+
test/scylla/db.crt
4+
test/scylla/db.key

.golangci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: 2
2+
3+
issues:
4+
# new: false
5+
# new-from-rev: origin/master
6+
# exclude-dirs:
7+
# - semver
8+
9+
linters:
10+
default: none
11+
enable:
12+
- errcheck
13+
- gocritic
14+
- goheader
15+
- govet
16+
- ineffassign
17+
- misspell
18+
- predeclared
19+
- revive
20+
- staticcheck
21+
- thelper
22+
- tparallel
23+
- unused
24+
- forbidigo
25+
- nolintlint
26+
27+
settings:
28+
govet:
29+
enable-all: true
30+
disable:
31+
- shadow
32+
- fieldalignment
33+
34+
nolintlint:
35+
allow-no-explanation: [ golines ]
36+
require-explanation: true
37+
require-specific: true
38+
39+
formatters:
40+
default: none
41+
enable:
42+
- gofumpt
43+
- goimports
44+
- golines
45+
46+
settings:
47+
gofumpt:
48+
extra-rules: true
49+
50+
goimports:
51+
local-prefixes:
52+
- github.com/scylladb/alternator-client-golang
53+
- github.com/scylladb/alternator-client-golang/shared
54+
- github.com/scylladb/alternator-client-golang/sdkv1
55+
- github.com/scylladb/alternator-client-golang/sdkv2
56+
golines:
57+
max-len: 120
58+
59+
run:
60+
deadline: 10m
61+
modules-download-mode: readonly
62+
tests: true
63+
build-tags:
64+
- integration
65+
go: 1.24.0

Makefile

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
define dl_tgz
2+
@if ! $(1) 2>/dev/null 1>&2; then \
3+
[ -d "$(GOBIN)" ] || mkdir "$(GOBIN)"; \
4+
if [ ! -f "$(GOBIN)/$(1)" ]; then \
5+
echo "Downloading $(GOBIN)/$(1)"; \
6+
curl --progress-bar -L $(2) | tar zxf - --wildcards --strip 1 -C $(GOBIN) '*/$(1)'; \
7+
chmod +x "$(GOBIN)/$(1)"; \
8+
fi; \
9+
fi
10+
endef
11+
12+
define dl_bin
13+
@if ! $(1) 2>/dev/null 1>&2; then \
14+
[ -d "$(GOBIN)" ] || mkdir "$(GOBIN)"; \
15+
if [ ! -f "$(GOBIN)/$(1)" ]; then \
16+
echo "Downloading $(GOBIN)/$(1)"; \
17+
curl --progress-bar -L $(2) --output "$(GOBIN)/$(1)"; \
18+
chmod +x "$(GOBIN)/$(1)"; \
19+
fi; \
20+
fi
21+
endef
22+
23+
MAKEFILE_PATH := $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
24+
GOOS := $(shell uname | tr '[:upper:]' '[:lower:]')
25+
GOARCH := $(shell go env GOARCH)
26+
DOCKER_COMPOSE_VERSION := 2.34.0
27+
GOLANGCI_VERSION := v2.1.6
28+
29+
ifeq ($(GOARCH),arm64)
30+
DOCKER_COMPOSE_DOWNLOAD_URL := "https://github.com/docker/compose/releases/download/v$(DOCKER_COMPOSE_VERSION)/docker-compose-$(GOOS)-aarch64"
31+
GOLANGCI_DOWNLOAD_URL := "https://github.com/golangci/golangci-lint/releases/download/v$(GOLANGCI_VERSION)/golangci-lint-$(GOLANGCI_VERSION)-$(GOOS)-arm64.tar.gz"
32+
else ifeq ($(GOARCH),amd64)
33+
DOCKER_COMPOSE_DOWNLOAD_URL := "https://github.com/docker/compose/releases/download/v$(DOCKER_COMPOSE_VERSION)/docker-compose-$(GOOS)-x86_64"
34+
GOLANGCI_DOWNLOAD_URL := "https://github.com/golangci/golangci-lint/releases/download/v$(GOLANGCI_VERSION)/golangci-lint-$(GOLANGCI_VERSION)-$(GOOS)-amd64.tar.gz"
35+
else
36+
@printf 'Unknown architecture "%s"\n', "$(GOARCH)"
37+
@exit 69
38+
endif
39+
40+
41+
ifndef GOBIN
42+
export GOBIN := $(MAKEFILE_PATH)/bin
43+
endif
44+
45+
export PATH := $(GOBIN):$(PATH)
46+
47+
COMPOSE := docker-compose -f $(MAKEFILE_PATH)/test/docker-compose.yml
48+
49+
.PHONY: clean
50+
clean:
51+
$(MAKE) -C ./shared clean
52+
$(MAKE) -C ./sdkv1 clean
53+
$(MAKE) -C ./sdkv2 clean
54+
55+
.PHONY: build
56+
build:
57+
$(MAKE) -C ./shared build
58+
$(MAKE) -C ./sdkv1 build
59+
$(MAKE) -C ./sdkv2 build
60+
61+
.PHONY: clean-caches
62+
clean-caches:
63+
$(MAKE) -C ./shared clean-caches
64+
$(MAKE) -C ./sdkv1 clean-caches
65+
$(MAKE) -C ./sdkv2 clean-caches
66+
67+
.PHONY: check
68+
check: check-golangci
69+
70+
.PHONY: fix
71+
fix: fix-golangci
72+
73+
.PHONY: check-golangci
74+
check-golangci: .prepare-golangci
75+
$(MAKE) -C ./shared check-golangci
76+
$(MAKE) -C ./sdkv1 check-golangci
77+
$(MAKE) -C ./sdkv2 check-golangci
78+
79+
.PHONY: fix-golangci
80+
fix-golangci: .prepare-golangci
81+
$(MAKE) -C ./shared fix-golangci
82+
$(MAKE) -C ./sdkv1 fix-golangci
83+
$(MAKE) -C ./sdkv2 fix-golangci
84+
85+
.PHONY: test
86+
test: build check test-unit test-integration
87+
88+
.PHONY: test-unit
89+
test-unit:
90+
$(MAKE) -C ./shared test-unit
91+
$(MAKE) -C ./sdkv1 test-unit
92+
$(MAKE) -C ./sdkv2 test-unit
93+
94+
.PHONY: test-integration
95+
test-integration: scylla-start
96+
$(MAKE) -C ./shared test-integration
97+
$(MAKE) -C ./sdkv1 test-integration
98+
$(MAKE) -C ./sdkv2 test-integration
99+
100+
.PHONY: .prepare-cert
101+
.prepare-cert:
102+
@[ -f "${MAKEFILE_PATH}/test/scylla/db.key" ] || (echo "Prepare certificate" && cd ${MAKEFILE_PATH}/test/scylla/ && openssl req -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -x509 -newkey rsa:4096 -keyout db.key -out db.crt -days 3650 -nodes && chmod 644 db.key)
103+
104+
.PHONY: scylla-start
105+
scylla-start: .prepare-cert $(GOBIN)/docker-compose
106+
@sudo sysctl -w fs.aio-max-nr=10485760
107+
$(COMPOSE) up -d
108+
109+
.PHONY: scylla-stop
110+
scylla-stop: $(GOBIN)/docker-compose
111+
$(COMPOSE) down
112+
113+
.PHONY: scylla-kill
114+
scylla-kill: $(GOBIN)/docker-compose
115+
$(COMPOSE) kill
116+
117+
.PHONY: scylla-rm
118+
scylla-rm: $(GOBIN)/docker-compose
119+
$(COMPOSE) rm -f
120+
121+
.prepare-golangci:
122+
@if ! golangci-lint --version 2>/dev/null | grep ${GOLANGCI_VERSION} >/dev/null; then \
123+
echo "Installing golangci-ling ${GOLANGCI_VERSION}"; \
124+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_VERSION}; \
125+
fi
126+
127+
$(GOBIN)/docker-compose: Makefile
128+
$(call dl_bin,docker-compose,$(DOCKER_COMPOSE_DOWNLOAD_URL))

0 commit comments

Comments
 (0)