Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Go actions to use go.mod for versioning and adjust depth #6930

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions .github/workflows/go-cover.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Go test with coverage
run: |-
# Build list of packages to include in coverage, excluding generated code in 'proto/gen'
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
Expand Down
14 changes: 4 additions & 10 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Go fmt
run: test -z $(gofmt -l .)
- name: Go test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rill-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
fetch-tags: true

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.23

Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/web-test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,6 @@ jobs:
with:
go-version: 1.23

- name: go build cache
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('./go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Build and embed static UI
if: matrix.name == 'web-local'
run: PLAYWRIGHT_TEST=true make cli
Expand Down
1 change: 1 addition & 0 deletions admin/server/rbac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ func TestRBAC(t *testing.T) {
Domain: "whitelist-projs.test",
Role: database.ProjectRoleNameAdmin,
})
require.NoError(t, err)

// Check we can't whitelist the same domain on the same project again
_, err = c1.CreateProjectWhitelistedDomain(ctx, &adminv1.CreateProjectWhitelistedDomainRequest{
Expand Down
1 change: 0 additions & 1 deletion admin/server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func newTestServer(t *testing.T) *Server {

// Sender
sender := email.NewTestSender()
require.NoError(t, err)
emailClient := email.New(sender)

// Application-managed column encryption keyring
Expand Down
3 changes: 3 additions & 0 deletions runtime/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ func (r *Runtime) Catalog(ctx context.Context, instanceID string) (drivers.Catal
}

func (r *Runtime) ConnectorConfig(ctx context.Context, instanceID, name string) (*ConnectorConfig, error) {
r.instanceMu.RLock()
defer r.instanceMu.RUnlock()

inst, err := r.Instance(ctx, instanceID)
if err != nil {
return nil, err
Expand Down
33 changes: 25 additions & 8 deletions runtime/pkg/graceful/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@ package graceful

import (
"context"
"errors"
"fmt"
"net"
"strings"
"time"

"google.golang.org/grpc"
)

const grpcShutdownTimeout = 15 * time.Second

// ServeGRPC serves a GRPC server and performs a graceful shutdown if/when ctx is cancelled.
func ServeGRPC(ctx context.Context, server *grpc.Server, port int) error {
var lis net.Listener
var err error

// Calling net.Listen("tcp", ...) will succeed if the port is blocked on IPv4 but not on IPv6.
// This workaround ensures we get the port on IPv4 (and most likely also on IPv6).
lis, err := net.Listen("tcp4", fmt.Sprintf(":%d", port))
lis, err = net.Listen("tcp4", fmt.Sprintf(":%d", port))
if err == nil {
lis.Close()
lis, err = net.Listen("tcp", fmt.Sprintf(":%d", port))
Expand All @@ -25,17 +32,27 @@ func ServeGRPC(ctx context.Context, server *grpc.Server, port int) error {
return err
}

cctx, cancel := context.WithCancel(ctx)
var serveErr error
// Channel to signal server has stopped
serveErrCh := make(chan error)
go func() {
serveErr = server.Serve(lis)
cancel()
err := server.Serve(lis)
serveErrCh <- err
}()

<-cctx.Done()
if serveErr == nil {
// Wait for context to be cancelled or failure to serve
select {
case err := <-serveErrCh:
return err
case <-ctx.Done():
server.GracefulStop()
}

return serveErr
// Wait for graceful shutdown
select {
case err := <-serveErrCh:
return err
case <-time.After(grpcShutdownTimeout):
server.Stop()
return errors.New("grpc graceful shutdown timed out")
}
}
43 changes: 29 additions & 14 deletions runtime/pkg/graceful/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type ServeOptions struct {

// ServeHTTP serves a HTTP server and performs a graceful shutdown if/when ctx is cancelled.
func ServeHTTP(ctx context.Context, server *http.Server, options ServeOptions) error {
var err error

// Calling net.Listen("tcp", ...) will succeed if the port is blocked on IPv4 but not on IPv6.
// This workaround ensures we get the port on IPv4 (and most likely also on IPv6).
lis, err := net.Listen("tcp4", fmt.Sprintf(":%d", options.Port))
Expand All @@ -33,26 +35,39 @@ func ServeHTTP(ctx context.Context, server *http.Server, options ServeOptions) e
return err
}

cctx, cancel := context.WithCancel(ctx)
var serveErr error
// Channel to signal server has stopped
serveErrCh := make(chan error)
// Start server in a goroutine
go func() {
if options.CertPath != "" && options.KeyPath != "" {
serveErr = server.ServeTLS(lis, options.CertPath, options.KeyPath)
// Use HTTPS if cert and key are provided
err = server.ServeTLS(lis, options.CertPath, options.KeyPath)
serveErrCh <- err
} else {
serveErr = server.Serve(lis)
// Otherwise use HTTP
err = server.Serve(lis)
serveErrCh <- err
}

cancel()
}()

<-cctx.Done()
if serveErr == nil {
// server.Serve always returns a non-nil err, so this must be a cancel on the parent ctx.
// We perform a graceful shutdown.
ctx, cancel := context.WithTimeout(context.Background(), httpShutdownTimeout)
defer cancel()
serveErr = server.Shutdown(ctx)
// Wait for context cancellation or server stopped
select {
case err := <-serveErrCh:
return err
case <-ctx.Done():
if err := server.Close(); err != nil {
return err
}
}

return serveErr
// Wait for graceful shutdown
select {
case err := <-serveErrCh:
return err
case <-time.After(httpShutdownTimeout):
if err := server.Close(); err != nil {
return err
}
return fmt.Errorf("http graceful shutdown timed out")
}
}
5 changes: 5 additions & 0 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"sync"
"time"

runtimev1 "github.com/rilldata/rill/proto/gen/rill/runtime/v1"
Expand Down Expand Up @@ -42,6 +43,7 @@ type Runtime struct {
connCache conncache.Cache
queryCache *queryCache
securityEngine *securityEngine
instanceMu sync.RWMutex
}

func New(ctx context.Context, opts *Options, logger *zap.Logger, st *storage.Client, ac *activity.Client, emailClient *email.Client) (*Runtime, error) {
Expand Down Expand Up @@ -177,6 +179,9 @@ func (r *Runtime) UpdateInstanceWithRillYAML(ctx context.Context, instanceID str
// UpdateInstanceConnector upserts or removes a connector from an instance
// If connector is nil, the connector is removed; otherwise, it is upserted
func (r *Runtime) UpdateInstanceConnector(ctx context.Context, instanceID, name string, connector *runtimev1.ConnectorSpec) error {
r.instanceMu.Lock()
defer r.instanceMu.Unlock()

inst, err := r.Instance(ctx, instanceID)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion runtime/server/queries_metrics_comparison_toplist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ func TestServer_MetricsViewComparison_inline_measures(t *testing.T) {
}

func TestServer_MetricsViewComparison_nulls(t *testing.T) {
t.Parallel()
// NOTE: Unstable due to sleep. Commenting until we support configuring settings at instance create time.
t.Skip()

t.Parallel()
server, instanceId := getMetricsTestServer(t, "ad_bids_2rows")

// TODO: Support configuring at create time
Expand Down
Loading