Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Using re-usable CI #42

Merged
merged 2 commits into from
Aug 25, 2023
Merged
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
91 changes: 2 additions & 89 deletions .github/workflows/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,93 +9,6 @@ on:
- v*
pull_request:

defaults:
run:
shell: bash

jobs:
deps:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: Check dependencies
run: |
go version
test -z "$(go mod tidy && git status --porcelain)"
go mod verify

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run k6 golangci-lint CI
uses: grafana/k6/.github/actions/lint@master

test-go-versions:
strategy:
fail-fast: false
matrix:
go-version: [1.19.x, 1.20.x, tip]
platform: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go ${{ matrix.go-version }}
if: matrix.go-version != 'tip'
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Install Go stable
if: matrix.go-version == 'tip'
uses: actions/setup-go@v3
with:
go-version: 1.x
- name: Install Go tip
shell: bash
if: matrix.go-version == 'tip'
run: |
go install golang.org/dl/gotip@latest
gotip download
echo "GOROOT=$HOME/sdk/gotip" >> "$GITHUB_ENV"
echo "GOPATH=$HOME/go" >> "$GITHUB_ENV"
echo "$HOME/go/bin" >> "$GITHUB_PATH"
echo "$HOME/sdk/gotip/bin" >> "$GITHUB_PATH"
- name: Run tests
run: |
which go
go version
go mod vendor
go test -race -timeout 60s ./...

test-build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: Check build
run: |
go version
pwd && ls -l

go install go.k6.io/xk6/cmd/xk6@master
MODULE_NAME=`go list -m`

GOPRIVATE="go.k6.io/k6" xk6 build \
--output ./k6ext \
--with $MODULE_NAME="."
./k6ext version
checks:
uses: grafana/k6-ci/.github/workflows/all.yml@main
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ grpc-server-run:

## test: Executes any tests.
test:
test -s vendor || (echo "No vendored dependencies, but they required for tests, running 'go mod vendor'..." && go mod vendor)
echo "Running tests..."
go test -race -timeout 30s ./...

Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ We don't expect every contributor to do that and are happy to do that for you, b

To run the test you can use the `make test` target.

> [!IMPORTANT]
> Our tests uses some proto definition files from the vendor folder. The first of the `make test` will check if the folder exists and if not try to download it. If you want to do that manually you can run `go mod vendor`.

### Linting

To run the linter you can use the `make lint` target.
Expand Down
52 changes: 26 additions & 26 deletions grpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
val: []MethodInfo{{MethodInfo: grpc.MethodInfo{Name: "EmptyCall", IsClientStream: false, IsServerStream: false}, Package: "grpc.testing", Service: "TestService", FullMethod: "/grpc.testing.TestService/EmptyCall"}, {MethodInfo: grpc.MethodInfo{Name: "UnaryCall", IsClientStream: false, IsServerStream: false}, Package: "grpc.testing", Service: "TestService", FullMethod: "/grpc.testing.TestService/UnaryCall"}, {MethodInfo: grpc.MethodInfo{Name: "StreamingOutputCall", IsClientStream: false, IsServerStream: true}, Package: "grpc.testing", Service: "TestService", FullMethod: "/grpc.testing.TestService/StreamingOutputCall"}, {MethodInfo: grpc.MethodInfo{Name: "StreamingInputCall", IsClientStream: true, IsServerStream: false}, Package: "grpc.testing", Service: "TestService", FullMethod: "/grpc.testing.TestService/StreamingInputCall"}, {MethodInfo: grpc.MethodInfo{Name: "FullDuplexCall", IsClientStream: true, IsServerStream: true}, Package: "grpc.testing", Service: "TestService", FullMethod: "/grpc.testing.TestService/FullDuplexCall"}, {MethodInfo: grpc.MethodInfo{Name: "HalfDuplexCall", IsClientStream: true, IsServerStream: true}, Package: "grpc.testing", Service: "TestService", FullMethod: "/grpc.testing.TestService/HalfDuplexCall"}},
},
},
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");
client.load([], "../grpc/testdata/grpc_testing/test.proto");
client.connect();`,
err: "connecting to a gRPC server in the init context is not supported",
},
Expand All @@ -127,7 +127,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");
client.load([], "../grpc/testdata/grpc_testing/test.proto");
var err = client.invoke();
throw new Error(err)`,
err: "invoking RPC methods in the init context is not supported",
Expand All @@ -138,7 +138,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");
client.load([], "../grpc/testdata/grpc_testing/test.proto");
client.invoke("grpc.testing.TestService/EmptyCall", {})`,
err: "invoking RPC methods in the init context is not supported",
},
Expand All @@ -147,7 +147,7 @@ func TestClient(t *testing.T) {
name: "UnknownConnectParam",
initString: codeBlock{code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`},
client.load([], "../grpc/testdata/grpc_testing/test.proto");`},
vuString: codeBlock{
code: `client.connect("GRPCBIN_ADDR", { name: "k6" });`,
err: `unknown connect param: "name"`,
Expand All @@ -158,7 +158,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
},
vuString: codeBlock{
code: `client.connect("GRPCBIN_ADDR", { timeout: "k6" });`,
Expand All @@ -169,35 +169,35 @@ func TestClient(t *testing.T) {
name: "ConnectStringTimeout",
initString: codeBlock{code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`},
client.load([], "../grpc/testdata/grpc_testing/test.proto");`},
vuString: codeBlock{code: `client.connect("GRPCBIN_ADDR", { timeout: "1h3s" });`},
},
{
name: "ConnectIntegerTimeout",
initString: codeBlock{code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`},
client.load([], "../grpc/testdata/grpc_testing/test.proto");`},
vuString: codeBlock{code: `client.connect("GRPCBIN_ADDR", { timeout: 3000 });`},
},
{
name: "ConnectFloatTimeout",
initString: codeBlock{code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`},
client.load([], "../grpc/testdata/grpc_testing/test.proto");`},
vuString: codeBlock{code: `client.connect("GRPCBIN_ADDR", { timeout: 3456.3 });`},
},
{
name: "Connect",
initString: codeBlock{code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`},
client.load([], "../grpc/testdata/grpc_testing/test.proto");`},
vuString: codeBlock{code: `client.connect("GRPCBIN_ADDR");`},
},
{
name: "InvokeNotFound",
initString: codeBlock{code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`},
client.load([], "../grpc/testdata/grpc_testing/test.proto");`},
vuString: codeBlock{
code: `
client.connect("GRPCBIN_ADDR");
Expand All @@ -209,7 +209,7 @@ func TestClient(t *testing.T) {
name: "InvokeNilRequest",
initString: codeBlock{code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`},
client.load([], "../grpc/testdata/grpc_testing/test.proto");`},
vuString: codeBlock{
code: `
client.connect("GRPCBIN_ADDR");
Expand All @@ -221,7 +221,7 @@ func TestClient(t *testing.T) {
name: "Invoke",
initString: codeBlock{code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`},
client.load([], "../grpc/testdata/grpc_testing/test.proto");`},
setup: func(tb *httpmultibin.HTTPMultiBin) {
tb.GRPCStub.EmptyCallFunc = func(context.Context, *grpc_testing.Empty) (*grpc_testing.Empty, error) {
return &grpc_testing.Empty{}, nil
Expand All @@ -244,7 +244,7 @@ func TestClient(t *testing.T) {
name: "InvokeAnyProto",
initString: codeBlock{code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_any_testing/any_test.proto");`},
client.load([], "../grpc/testdata/grpc_any_testing/any_test.proto");`},
setup: func(tb *httpmultibin.HTTPMultiBin) {
tb.GRPCAnyStub.SumFunc = func(ctx context.Context, req *grpcanytesting.SumRequest) (*grpcanytesting.SumReply, error) {
var sumRequestData grpcanytesting.SumRequestData
Expand Down Expand Up @@ -293,7 +293,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
},
setup: func(tb *httpmultibin.HTTPMultiBin) {
tb.GRPCStub.UnaryCallFunc = func(_ context.Context, req *grpc_testing.SimpleRequest) (*grpc_testing.SimpleResponse, error) {
Expand All @@ -315,7 +315,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
},
setup: func(tb *httpmultibin.HTTPMultiBin) {
tb.GRPCStub.EmptyCallFunc = func(ctx context.Context, _ *grpc_testing.Empty) (*grpc_testing.Empty, error) {
Expand All @@ -340,7 +340,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
},
setup: func(tb *httpmultibin.HTTPMultiBin) {
tb.GRPCStub.UnaryCallFunc = func(context.Context, *grpc_testing.SimpleRequest) (*grpc_testing.SimpleResponse, error) {
Expand All @@ -367,7 +367,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
},
setup: func(tb *httpmultibin.HTTPMultiBin) {
tb.GRPCStub.EmptyCallFunc = func(context.Context, *grpc_testing.Empty) (*grpc_testing.Empty, error) {
Expand Down Expand Up @@ -395,7 +395,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
},
setup: func(tb *httpmultibin.HTTPMultiBin) {
tb.GRPCStub.EmptyCallFunc = func(ctx context.Context, _ *grpc_testing.Empty) (*grpc_testing.Empty, error) {
Expand Down Expand Up @@ -425,7 +425,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
},
setup: func(tb *httpmultibin.HTTPMultiBin) {
tb.GRPCStub.EmptyCallFunc = func(ctx context.Context, _ *grpc_testing.Empty) (*grpc_testing.Empty, error) {
Expand Down Expand Up @@ -462,7 +462,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
},
vuString: codeBlock{
code: `client.load()`,
Expand Down Expand Up @@ -572,7 +572,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
},
setup: func(tb *httpmultibin.HTTPMultiBin) {
tb.GRPCStub.UnaryCallFunc = func(_ context.Context, req *grpc_testing.SimpleRequest) (*grpc_testing.SimpleResponse, error) {
Expand Down Expand Up @@ -623,7 +623,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
},
setup: func(tb *httpmultibin.HTTPMultiBin) {
tb.GRPCStub.UnaryCallFunc = func(context.Context, *grpc_testing.SimpleRequest) (*grpc_testing.SimpleResponse, error) {
Expand All @@ -646,7 +646,7 @@ func TestClient(t *testing.T) {
initString: codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
},
vuString: codeBlock{
code: `
Expand Down Expand Up @@ -825,7 +825,7 @@ func TestClient_TlsParameters(t *testing.T) {
},
initString: codeBlock{code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`},
client.load([], "../grpc/testdata/grpc_testing/test.proto");`},
vuString: codeBlock{
code: fmt.Sprintf(`
client.connect("GRPCBIN_ADDR", { timeout: '5s', tls: { cacerts: ["%s"], cert: "%s", key: "%s" }});
Expand All @@ -851,7 +851,7 @@ func TestClient_TlsParameters(t *testing.T) {
},
initString: codeBlock{code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`},
client.load([], "../grpc/testdata/grpc_testing/test.proto");`},
vuString: codeBlock{
code: fmt.Sprintf(`
client.connect("GRPCBIN_ADDR", { timeout: '2s', tls: { cacerts: ["%s"], cert: "%s", key: "%s" }});
Expand Down
2 changes: 1 addition & 1 deletion grpc/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestStream_InvalidHeader(t *testing.T) {
initString := codeBlock{
code: `
var client = new grpc.Client();
client.load([], "../vendor/go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing/test.proto");`,
client.load([], "../grpc/testdata/grpc_testing/test.proto");`,
}

val, err := replace(initString.code)
Expand Down
31 changes: 31 additions & 0 deletions grpc/testdata/grpc_any_testing/any_test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


syntax = "proto3";

package grpc.any.testing;

import "google/protobuf/any.proto";

option go_package ="./grpc_any_testing";

service AnyTestService {
rpc Sum (SumRequest) returns (SumReply) {}
}

message SumRequest {
google.protobuf.Any data = 1;
}

message SumRequestData {
int64 a = 1;
int64 b = 2;
}

message SumReply {
google.protobuf.Any data = 1;
}

message SumReplyData {
int64 v = 1;
string err = 2;
}
Loading
Loading