Skip to content

Commit 0e7f67c

Browse files
authored
Merge branch 'main' into go/tjz-credentials
2 parents 3094a87 + 0092c03 commit 0e7f67c

File tree

12 files changed

+97
-37
lines changed

12 files changed

+97
-37
lines changed

.github/workflows/go-cd.yml

+23-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Go - Continuous Deployment
22

33
on:
4+
push:
5+
tags:
6+
- "v*.*"
47
workflow_dispatch:
58
inputs:
69
version:
@@ -21,6 +24,7 @@ permissions:
2124

2225
jobs:
2326
load-platform-matrix:
27+
if: github.repository_owner == 'valkey-io'
2428
runs-on: ubuntu-latest
2529
environment: AWS_ACTIONS
2630
outputs:
@@ -46,39 +50,45 @@ jobs:
4650
echo "PLATFORM_MATRIX=${PLATFORM_MATRIX}" >> $GITHUB_OUTPUT
4751
4852
validate-release-version:
49-
if: ${{ github.event.inputs.pkg_go_dev_publish }}
53+
if: ${{ github.event_name == 'push' || inputs.pkg_go_dev_publish }}
5054
runs-on: ubuntu-latest
5155
outputs:
5256
RELEASE_VERSION: ${{ steps.release-tag.outputs.RELEASE_VERSION }}
5357
env:
5458
INPUT_VERSION: ${{ github.event.inputs.version }}
59+
TAG_VERSION: ${{ github.ref_name }}
5560
steps:
56-
- name: Validate Version Against RegEx
57-
run: |
58-
echo "input version is: ${{ env.INPUT_VERSION }}"
59-
if ! echo "${{ env.INPUT_VERSION }}" | grep -Pq '^v\d+\.\d+\.\d+(-rc\d+)?$'; then
60-
echo "Version is not valid, must be v*.*.* or v*.*.*-rc*"
61-
exit 1
62-
fi
63-
6461
- name: Checkout for tag check
62+
if: ${{ github.event_name == 'workflow_dispatch' }}
6563
uses: actions/checkout@v4
6664

6765
- name: Validate version agaisnt tags
66+
if: ${{ github.event_name == 'workflow_dispatch' }}
6867
run: |
6968
git fetch --tags
7069
if git tag | grep -q "^go/${{ env.INPUT_VERSION }}$"; then
7170
echo "Version ${{ env.INPUT_VERSION }} already exists."
7271
exit 1
7372
fi
74-
- name: Output release tag
73+
74+
- name: Validate Version Against RegEx and output
7575
id: release-tag
7676
run: |
77-
echo "RELEASE_VERSION=${{ env.INPUT_VERSION }}" >> $GITHUB_OUTPUT
77+
if ${{ github.event_name == 'workflow_dispatch' }}; then
78+
R_VERSION="${{ env.INPUT_VERSION }}"
79+
else
80+
R_VERSION="${{ env.TAG_VERSION }}"
81+
fi
82+
echo "Releassing version is: ${R_VERSION}"
83+
if ! echo "${R_VERSION}" | grep -Pq '^v\d+\.\d+\.\d+(-rc\d+)?$'; then
84+
echo "Version is not valid, must be v*.*.* or v*.*.*-rc*"
85+
exit 1
86+
fi
87+
echo "RELEASE_VERSION=${R_VERSION}" >> $GITHUB_OUTPUT
7888
7989
create-binaries:
8090
needs: [load-platform-matrix]
81-
if: success() && github.repository_owner == 'valkey-io'
91+
if: success()
8292
strategy:
8393
fail-fast: false
8494
matrix:
@@ -123,7 +133,7 @@ jobs:
123133
go/protobuf/
124134
125135
commit-auto-gen-files-with-tag:
126-
if: ${{ github.event.inputs.pkg_go_dev_publish }}
136+
if: ${{ github.event_name == 'push' || inputs.pkg_go_dev_publish }}
127137
needs: [validate-release-version, create-binaries]
128138
runs-on: ubuntu-latest
129139
permissions:

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ utils/TestUtils.js
5252

5353
# java compiled files.
5454
*.class
55+
56+
# generaged files (e.g. protobuf)
57+
generated/

glide-core/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ serde = { version = "1", features = ["derive"] }
4444
versions = "6.3"
4545

4646
[features]
47+
proto = ["protobuf"]
4748
socket-layer = [
49+
"proto",
4850
"directories",
4951
"integer-encoding",
5052
"num_cpus",
51-
"protobuf",
5253
"tokio-util",
5354
]
5455
standalone_heartbeat = []

glide-core/build.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
22

3-
#[cfg(feature = "socket-layer")]
3+
#[cfg(feature = "proto")]
44
fn build_protobuf() {
55
let customization_options = protobuf_codegen::Customize::default()
66
.lite_runtime(false)
@@ -13,10 +13,11 @@ fn build_protobuf() {
1313
.input("src/protobuf/response.proto")
1414
.input("src/protobuf/connection_request.proto")
1515
.customize(customization_options)
16+
.out_dir("src/generated")
1617
.run_from_script();
1718
}
1819

1920
fn main() {
20-
#[cfg(feature = "socket-layer")]
21+
#[cfg(feature = "proto")]
2122
build_protobuf();
2223
}

glide-core/src/client/types.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use logger_core::log_warn;
66
use std::collections::HashSet;
77
use std::time::Duration;
88

9-
#[cfg(feature = "socket-layer")]
9+
#[cfg(feature = "proto")]
1010
use crate::connection_request as protobuf;
1111

1212
#[derive(Default)]
@@ -77,7 +77,7 @@ pub struct ConnectionRetryStrategy {
7777
pub number_of_retries: u32,
7878
}
7979

80-
#[cfg(feature = "socket-layer")]
80+
#[cfg(feature = "proto")]
8181
fn chars_to_string_option(chars: &::protobuf::Chars) -> Option<String> {
8282
if chars.is_empty() {
8383
None
@@ -86,7 +86,7 @@ fn chars_to_string_option(chars: &::protobuf::Chars) -> Option<String> {
8686
}
8787
}
8888

89-
#[cfg(feature = "socket-layer")]
89+
#[cfg(feature = "proto")]
9090
fn none_if_zero(value: u32) -> Option<u32> {
9191
if value == 0 {
9292
None
@@ -95,7 +95,7 @@ fn none_if_zero(value: u32) -> Option<u32> {
9595
}
9696
}
9797

98-
#[cfg(feature = "socket-layer")]
98+
#[cfg(feature = "proto")]
9999
impl From<protobuf::ConnectionRequest> for ConnectionRequest {
100100
fn from(value: protobuf::ConnectionRequest) -> Self {
101101
let read_from = value.read_from.enum_value().ok().map(|val| match val {

glide-core/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
22

3-
#[cfg(feature = "socket-layer")]
4-
include!(concat!(env!("OUT_DIR"), "/protobuf/mod.rs"));
3+
#[cfg(feature = "proto")]
4+
include!("generated/mod.rs");
55
pub mod client;
66
mod retry_strategies;
77
#[cfg(feature = "socket-layer")]

glide-core/src/request_type.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use redis::{cmd, Cmd};
44

5-
#[cfg(feature = "socket-layer")]
5+
#[cfg(feature = "proto")]
66
use crate::command_request::RequestType as ProtobufRequestType;
77

88
#[repr(C)]
@@ -431,7 +431,7 @@ fn get_two_word_command(first: &str, second: &str) -> Cmd {
431431
cmd
432432
}
433433

434-
#[cfg(feature = "socket-layer")]
434+
#[cfg(feature = "proto")]
435435
impl From<::protobuf::EnumOrUnknown<ProtobufRequestType>> for RequestType {
436436
fn from(value: ::protobuf::EnumOrUnknown<ProtobufRequestType>) -> Self {
437437
match value.enum_value_or(ProtobufRequestType::InvalidRequest) {

glide-core/src/retry_strategies.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub(crate) fn get_exponential_backoff(
5454
}
5555
}
5656

57-
#[cfg(feature = "socket-layer")]
57+
#[cfg(feature = "proto")]
5858
#[allow(dead_code)]
5959
pub(crate) fn get_fixed_interval_backoff(
6060
fixed_interval: u32,

go/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ crate-type = ["staticlib"]
1010

1111
[dependencies]
1212
redis = { path = "../glide-core/redis-rs/redis", features = ["aio", "tokio-comp", "connection-manager", "tokio-rustls-comp"] }
13-
glide-core = { path = "../glide-core", features = ["socket-layer"] }
13+
glide-core = { path = "../glide-core", features = ["proto"] }
1414
tokio = { version = "^1", features = ["rt", "macros", "rt-multi-thread", "time"] }
1515
protobuf = { version = "3.3.0", features = [] }
1616

go/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use tokio::runtime::Runtime;
4040
#[derive(Debug)]
4141
pub struct CommandResponse {
4242
response_type: ResponseType,
43-
int_value: c_long,
43+
int_value: i64,
4444
float_value: c_double,
4545
bool_value: bool,
4646

java/integTest/build.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ compileTestJava.dependsOn ':client:publishToMavenLocal'
137137

138138
tasks.withType(Test) {
139139
useJUnitPlatform()
140-
dependsOn 'beforeTests'
141-
finalizedBy 'afterTests'
140+
if (!project.gradle.startParameter.taskNames.contains(':integTest:modulesTest')) {
141+
dependsOn 'beforeTests'
142+
finalizedBy 'afterTests'
143+
}
142144

143145
doFirst {
144146
systemProperty 'test.server.standalone', standaloneHosts

java/integTest/src/test/java/glide/TestConfiguration.java

+51-8
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import glide.api.GlideClient;
1010
import glide.api.GlideClusterClient;
1111
import glide.api.logging.Logger;
12+
import org.apache.commons.lang3.tuple.Pair;
1213

1314
public final class TestConfiguration {
14-
// All servers are hosted on localhost
1515
public static final String[] STANDALONE_HOSTS =
1616
System.getProperty("test.server.standalone", "").split(",");
1717
public static final String[] CLUSTER_HOSTS =
@@ -24,21 +24,64 @@ public final class TestConfiguration {
2424
static {
2525
Logger.init(Logger.Level.OFF);
2626
Logger.setLoggerConfig(Logger.Level.OFF);
27+
28+
System.out.printf("STANDALONE_HOSTS = %s\n", System.getProperty("test.server.standalone", ""));
29+
System.out.printf("CLUSTER_HOSTS = %s\n", System.getProperty("test.server.cluster", ""));
30+
System.out.printf("AZ_CLUSTER_HOSTS = %s\n", System.getProperty("test.server.azcluster", ""));
31+
32+
var result = getVersionFromStandalone();
33+
if (result.getKey() != null) {
34+
SERVER_VERSION = result.getKey();
35+
} else {
36+
var errorStandalone = result.getValue();
37+
result = getVersionFromCluster();
38+
if (result.getKey() != null) {
39+
SERVER_VERSION = result.getKey();
40+
} else {
41+
var errorCluster = result.getValue();
42+
errorStandalone.printStackTrace(System.err);
43+
System.err.println();
44+
errorCluster.printStackTrace(System.err);
45+
throw new RuntimeException("Failed to get server version");
46+
}
47+
}
48+
System.out.printf("SERVER_VERSION = %s\n", SERVER_VERSION);
49+
}
50+
51+
private static Pair<Semver, Exception> getVersionFromStandalone() {
52+
if (STANDALONE_HOSTS[0].isEmpty()) {
53+
return Pair.of(null, new Exception("No standalone nodes given"));
54+
}
2755
try {
28-
BaseClient client =
29-
!STANDALONE_HOSTS[0].isEmpty()
30-
? GlideClient.createClient(commonClientConfig().build()).get()
31-
: GlideClusterClient.createClient(commonClusterClientConfig().build()).get();
56+
BaseClient client = GlideClient.createClient(commonClientConfig().build()).get();
3257

3358
String serverVersion = TestUtilities.getServerVersion(client);
3459
if (serverVersion != null) {
35-
SERVER_VERSION = new Semver(serverVersion);
60+
return Pair.of(new Semver(serverVersion), null);
3661
} else {
37-
throw new Exception("Failed to get server version");
62+
return Pair.of(null, new Exception("Failed to parse version"));
3863
}
64+
} catch (Exception e) {
65+
return Pair.of(null, e);
66+
}
67+
}
68+
69+
private static Pair<Semver, Exception> getVersionFromCluster() {
70+
if (CLUSTER_HOSTS[0].isEmpty()) {
71+
return Pair.of(null, new Exception("No cluster nodes given"));
72+
}
73+
try {
74+
BaseClient client =
75+
GlideClusterClient.createClient(commonClusterClientConfig().build()).get();
3976

77+
String serverVersion = TestUtilities.getServerVersion(client);
78+
if (serverVersion != null) {
79+
return Pair.of(new Semver(serverVersion), null);
80+
} else {
81+
return Pair.of(null, new Exception("Failed to parse version"));
82+
}
4083
} catch (Exception e) {
41-
throw new RuntimeException("Failed to get server version", e);
84+
return Pair.of(null, e);
4285
}
4386
}
4487
}

0 commit comments

Comments
 (0)