Skip to content

Commit 2c49fd6

Browse files
authored
Merge branch 'main' into move-connection-variables
2 parents a2f5fe0 + c0781a7 commit 2c49fd6

File tree

8 files changed

+197
-3
lines changed

8 files changed

+197
-3
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
on:
2+
workflow_dispatch:
3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
name: Build and Release Google.Cloud.SpannerLib.Native
7+
jobs:
8+
build-linux-x64:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Install Go
12+
uses: actions/setup-go@v5
13+
with:
14+
go-version: 1.24
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Build shared library
18+
working-directory: spannerlib
19+
run: go build -o spannerlib.so -buildmode=c-shared shared_lib.go
20+
- name: Build gRPC server
21+
working-directory: spannerlib
22+
run: go build grpc_server.go
23+
- name: Upload linux-x64 shared lib
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: spannerlib-linux-x64
27+
path: spannerlib/spannerlib.so
28+
- name: Upload linux-x64 gRPC server
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: spannerlib-server-linux-x64
32+
path: spannerlib/grpc_server
33+
build-osx-arm64:
34+
runs-on: macos-latest
35+
steps:
36+
- name: Install Go
37+
uses: actions/setup-go@v5
38+
with:
39+
go-version: 1.24
40+
- name: Checkout code
41+
uses: actions/checkout@v4
42+
- name: Build shared library
43+
working-directory: spannerlib
44+
run: go build -o spannerlib.dylib -buildmode=c-shared shared_lib.go
45+
- name: Build gRPC server
46+
working-directory: spannerlib
47+
run: go build grpc_server.go
48+
- name: Upload osx-arm64 shared lib
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: spannerlib-osx-arm64
52+
path: spannerlib/spannerlib.dylib
53+
- name: Upload osx-arm64 gRPC server
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: spannerlib-server-osx-arm64
57+
path: spannerlib/grpc_server
58+
build-and-package:
59+
needs: [build-linux-x64, build-osx-arm64]
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Checkout code
63+
uses: actions/checkout@v4
64+
- name: Download and copy linux-x64 shared lib
65+
uses: actions/download-artifact@v4
66+
with:
67+
name: spannerlib-linux-x64
68+
path: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native/libraries/linux-x64/
69+
- name: Download and copy linux-x64 gRPC server
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: spannerlib-server-linux-x64
73+
path: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc/binaries/linux-x64/
74+
- name: Add execute permission to linux-x64 gRPC server
75+
run: chmod +x spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc/binaries/linux-x64/grpc_server
76+
- name: Download and copy osx-arm64
77+
uses: actions/download-artifact@v4
78+
with:
79+
name: spannerlib-osx-arm64
80+
path: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native/libraries/osx-arm64/
81+
- name: Download and copy osx-arm64 gRPC server
82+
uses: actions/download-artifact@v4
83+
with:
84+
name: spannerlib-server-osx-arm64
85+
path: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc/binaries/osx-arm64/
86+
- name: Add execute permission to osx-arm64 gRPC server
87+
run: chmod +x spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc/binaries/osx-arm64/grpc_server
88+
- name: Install dotnet
89+
uses: actions/setup-dotnet@v4
90+
with:
91+
dotnet-version: '9.0.x'
92+
- name: dotnet version
93+
run: dotnet --version
94+
- name: Build native library package
95+
run: dotnet pack
96+
working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native
97+
- name: Build gRPC server package
98+
run: dotnet pack
99+
working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc
100+
- name: Add package source for native library
101+
run: dotnet nuget add source "$PWD"/bin/Release --name local
102+
working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native
103+
- name: Restore dependencies
104+
run: dotnet restore
105+
working-directory: spannerlib/dotnet-spannerlib
106+
- name: Build
107+
run: dotnet build --no-restore
108+
working-directory: spannerlib/dotnet-spannerlib
109+
- name: Publish SpannerLib.Native to nuget
110+
run: dotnet nuget push bin/Release/Experimental.SpannerLib.Native.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
111+
working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native
112+
- name: Publish SpannerLib.Grpc to nuget
113+
run: dotnet nuget push bin/Release/Experimental.SpannerLib.Grpc.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
114+
working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Grpc
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
on:
2+
workflow_dispatch:
3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
name: Build and Release Google.Cloud.SpannerLib
7+
jobs:
8+
build-and-package:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
- name: Install dotnet
14+
uses: actions/setup-dotnet@v4
15+
with:
16+
dotnet-version: '9.0.x'
17+
- name: dotnet version
18+
run: dotnet --version
19+
- name: Restore dependencies
20+
run: dotnet restore
21+
working-directory: spannerlib/dotnet-spannerlib
22+
- name: Build
23+
run: dotnet build --no-restore
24+
working-directory: spannerlib/dotnet-spannerlib
25+
- name: Unit Tests
26+
working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Tests
27+
run: dotnet test --no-build --verbosity normal
28+
- name: Pack SpannerLib
29+
run: dotnet pack
30+
working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib
31+
- name: Publish SpannerLib to nuget
32+
run: dotnet nuget push bin/Release/Experimental.SpannerLib.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
33+
working-directory: spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib

conn.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ func (c *conn) ResetSession(_ context.Context) error {
667667
c.batch = nil
668668

669669
_ = c.state.Reset(connectionstate.ContextUser)
670+
670671
c.execOptions = ExecOptions{
671672
DecodeToNativeArrays: c.connector.connectorConfig.DecodeToNativeArrays,
672673
}

connection_properties.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"google.golang.org/grpc/status"
2626
)
2727

28+
2829
// connectionProperties contains all supported connection properties for Spanner.
2930
// These properties are added to all connectionstate.ConnectionState instances that are created for Spanner connections.
3031
var connectionProperties = map[string]connectionstate.ConnectionProperty{}

connectionstate/connection_property.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ func (p *TypedConnectionProperty[T]) ResetValue(state *ConnectionState, context
200200
return status.Errorf(codes.InvalidArgument, "value has wrong type: %T", resetValue)
201201
}
202202
return p.setConnectionStateValue(state, typedResetValue /*isReset=*/, true, context)
203+
203204
}
204205

205206
// SetValue sets the value of the property in the given ConnectionState.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package connectionstate
16+
17+
import (
18+
"testing"
19+
20+
"google.golang.org/grpc/codes"
21+
"google.golang.org/grpc/status"
22+
)
23+
24+
func TestCheckValidValue(t *testing.T) {
25+
type testValue int
26+
const (
27+
testValueUnspecified testValue = iota
28+
testValueTrue
29+
testValueFalse
30+
)
31+
32+
p := &TypedConnectionProperty[testValue]{validValues: []testValue{testValueTrue, testValueFalse}}
33+
if err := p.checkValidValue(testValueTrue); err != nil {
34+
t.Fatal(err)
35+
}
36+
if err := p.checkValidValue(testValueFalse); err != nil {
37+
t.Fatal(err)
38+
}
39+
if err := p.checkValidValue(testValueUnspecified); err == nil {
40+
t.Fatalf("expected error for %v", testValueUnspecified)
41+
} else {
42+
if g, w := status.Code(err), codes.InvalidArgument; g != w {
43+
t.Fatalf("error code mismatch\n Got: %v\nWant: %v", g, w)
44+
}
45+
}
46+
}

connectionstate/connection_state.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package connectionstate
1616

1717
import (
1818
"strings"
19-
2019
"google.golang.org/grpc/codes"
2120
"google.golang.org/grpc/status"
2221
)

driver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ type ConnectorConfig struct {
302302
// will be lost.
303303
// connectionstate.TypeNonTransactional means that changes to the connection
304304
// state during a transaction are persisted directly, and are always visible
305-
// after the transaction, regardless whether the transaction committed or
305+
// after the transaction, regardless whether the transaction was committed or
306306
// rolled back.
307307
ConnectionStateType connectionstate.Type
308308
// Params contains key/value pairs for commonly used configuration parameters
@@ -644,7 +644,6 @@ func openDriverConn(ctx context.Context, c *connector) (driver.Conn, error) {
644644
logger: logger,
645645
database: databaseName,
646646
state: createInitialConnectionState(connectionStateType, c.initialPropertyValues),
647-
648647
execSingleQuery: queryInSingleUse,
649648
execSingleQueryTransactional: queryInNewRWTransaction,
650649
execSingleDMLTransactional: execInNewRWTransaction,

0 commit comments

Comments
 (0)