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

Move not public parts of the k6 API in internal package #4133

Merged
merged 2 commits into from
Jan 22, 2025
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/tc39.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ jobs:
- name: Run tests
run: |
set -x
cd js/tc39
cd internal/js/tc39
sh checkout.sh
go test -timeout 1h
4 changes: 2 additions & 2 deletions .github/workflows/wpt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
- name: Run Streams Tests
run: |
set -x
cd js/modules/k6/experimental/streams/tests
cd internal/js/modules/k6/experimental/streams/tests
sh checkout.sh
go test ../... -tags=wpt
- name: Run Webcrypto Tests
run: |
set -x
cd js/modules/k6/webcrypto/tests
cd internal/js/modules/k6/webcrypto/tests
sh checkout.sh
go test ./... -tags=wpt
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/k6.exe
/dist
/pkg-build
/js/tc39/TestTC39
/js/modules/k6/experimental/streams/tests/wpt
/internal/js/tc39/TestTC39
/internal/js/modules/k6/experimental/streams/tests/wpt

.vscode
*.sublime-workspace
Expand Down Expand Up @@ -36,4 +36,4 @@ script.js
/packaging/*.gpg

# web platform tests
js/modules/k6/webcrypto/tests/wpt/
/internal/js/modules/k6/webcrypto/tests/wpt/
4 changes: 2 additions & 2 deletions api/v1/control_surface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package v1
import (
"context"

"go.k6.io/k6/execution"
"go.k6.io/k6/internal/execution"
"go.k6.io/k6/internal/metrics/engine"
"go.k6.io/k6/lib"
"go.k6.io/k6/metrics"
"go.k6.io/k6/metrics/engine"
)

// ControlSurface includes the methods the REST API can use to control and
Expand Down
12 changes: 6 additions & 6 deletions api/v1/group_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.k6.io/k6/execution"
"go.k6.io/k6/execution/local"
"go.k6.io/k6/internal/execution"
"go.k6.io/k6/internal/execution/local"
"go.k6.io/k6/internal/lib/testutils"
"go.k6.io/k6/internal/lib/testutils/minirunner"
"go.k6.io/k6/internal/metrics/engine"
"go.k6.io/k6/internal/usage"
"go.k6.io/k6/lib"
"go.k6.io/k6/lib/testutils"
"go.k6.io/k6/lib/testutils/minirunner"
"go.k6.io/k6/metrics"
"go.k6.io/k6/metrics/engine"
"go.k6.io/k6/usage"
)

func getTestPreInitState(tb testing.TB) *lib.TestPreInitState {
Expand Down
2 changes: 1 addition & 1 deletion api/v1/metric_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v3"

"go.k6.io/k6/internal/lib/testutils/minirunner"
"go.k6.io/k6/lib"
"go.k6.io/k6/lib/testutils/minirunner"
"go.k6.io/k6/metrics"
)

Expand Down
10 changes: 5 additions & 5 deletions api/v1/setup_teardown_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import (
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v3"

"go.k6.io/k6/execution"
"go.k6.io/k6/execution/local"
"go.k6.io/k6/js"
"go.k6.io/k6/internal/execution"
"go.k6.io/k6/internal/execution/local"
"go.k6.io/k6/internal/js"
"go.k6.io/k6/internal/loader"
"go.k6.io/k6/internal/metrics/engine"
"go.k6.io/k6/lib"
"go.k6.io/k6/lib/types"
"go.k6.io/k6/loader"
"go.k6.io/k6/metrics"
"go.k6.io/k6/metrics/engine"
"go.k6.io/k6/output"
)

Expand Down
2 changes: 1 addition & 1 deletion api/v1/status_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"go.k6.io/k6/errext"
"go.k6.io/k6/errext/exitcodes"
"go.k6.io/k6/execution"
"go.k6.io/k6/internal/execution"
"go.k6.io/k6/lib/executor"
)

Expand Down
8 changes: 4 additions & 4 deletions api/v1/status_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v3"

"go.k6.io/k6/execution"
"go.k6.io/k6/execution/local"
"go.k6.io/k6/internal/execution"
"go.k6.io/k6/internal/execution/local"
"go.k6.io/k6/internal/lib/testutils/minirunner"
"go.k6.io/k6/internal/metrics/engine"
"go.k6.io/k6/lib"
"go.k6.io/k6/lib/testutils/minirunner"
"go.k6.io/k6/metrics"
"go.k6.io/k6/metrics/engine"
"go.k6.io/k6/output"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.k6.io/k6/lib/testutils"
"go.k6.io/k6/internal/lib/testutils"
"go.k6.io/k6/lib/types"
)

Expand Down
4 changes: 2 additions & 2 deletions cloudapi/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v3"

"go.k6.io/k6/lib/testutils"
"go.k6.io/k6/lib/testutils/httpmultibin"
"go.k6.io/k6/internal/lib/testutils"
"go.k6.io/k6/internal/lib/testutils/httpmultibin"
)

func TestMsgParsing(t *testing.T) {
Expand Down
10 changes: 10 additions & 0 deletions cmd/execute.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Package cmd is here to provide a way for xk6 to build a binary with added extensions
package cmd

import "go.k6.io/k6/internal/cmd"

// Execute exectues the k6 command
// It only is exported here for backwards compatibility and the ability to use xk6 to build extended k6
func Execute() {
cmd.Execute()
}
4 changes: 2 additions & 2 deletions cmd/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/mattn/go-isatty"
"github.com/sirupsen/logrus"

"go.k6.io/k6/event"
"go.k6.io/k6/internal/event"
"go.k6.io/k6/internal/ui/console"
"go.k6.io/k6/lib/fsext"
"go.k6.io/k6/ui/console"
)

const defaultConfigFileName = "config.json"
Expand Down
17 changes: 17 additions & 0 deletions cmd/tests/global_state.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Package tests contains types needed for running integration tests that run k6 commands.
package tests

import (
"testing"

"go.k6.io/k6/internal/cmd/tests"
)

// GlobalTestState is a wrapper around GlobalState for use in tests.
type GlobalTestState = tests.GlobalTestState

// NewGlobalTestState returns an initialized GlobalTestState, mocking all
// GlobalState fields for use in tests.
func NewGlobalTestState(tb testing.TB) *GlobalTestState {
return tests.NewGlobalTestState(tb)
}
4 changes: 2 additions & 2 deletions api/server.go → internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"github.com/sirupsen/logrus"

v1 "go.k6.io/k6/api/v1"
"go.k6.io/k6/execution"
"go.k6.io/k6/internal/execution"
"go.k6.io/k6/internal/metrics/engine"
"go.k6.io/k6/lib"
"go.k6.io/k6/metrics"
"go.k6.io/k6/metrics/engine"
)

func newHandler(cs *v1.ControlSurface, profilingEnabled bool) http.Handler {
Expand Down
2 changes: 1 addition & 1 deletion api/server_test.go → internal/api/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
logtest "github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"

"go.k6.io/k6/lib/testutils"
"go.k6.io/k6/internal/lib/testutils"
)

func testHTTPHandler(rw http.ResponseWriter, _ *http.Request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"

"go.k6.io/k6/cloudapi/insights/proto/v1/ingester"
"go.k6.io/k6/internal/cloudapi/insights/proto/v1/ingester"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/grpc/test/bufconn"

"go.k6.io/k6/cloudapi/insights/proto/v1/ingester"
"go.k6.io/k6/internal/cloudapi/insights/proto/v1/ingester"
)

func newMockListener(t *testing.T, ingesterServer ingester.IngesterServiceServer) *bufconn.Listener {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"errors"
"fmt"

"go.k6.io/k6/cloudapi/insights/proto/v1/ingester"
"go.k6.io/k6/cloudapi/insights/proto/v1/k6"
"go.k6.io/k6/internal/cloudapi/insights/proto/v1/ingester"
"go.k6.io/k6/internal/cloudapi/insights/proto/v1/k6"
)

func newBatchCreateRequestMetadatasRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/stretchr/testify/require"

"go.k6.io/k6/cloudapi/insights/proto/v1/ingester"
"go.k6.io/k6/cloudapi/insights/proto/v1/k6"
"go.k6.io/k6/internal/cloudapi/insights/proto/v1/ingester"
"go.k6.io/k6/internal/cloudapi/insights/proto/v1/k6"
)

func Test_newBatchCreateRequestMetadatasRequest_CorrectlyMapsDomainTypeToProtoDefinition(t *testing.T) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
4 changes: 2 additions & 2 deletions cmd/archive_test.go → internal/cmd/archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"testing"

"github.com/stretchr/testify/require"
"go.k6.io/k6/cmd/tests"
"go.k6.io/k6/errext/exitcodes"
"go.k6.io/k6/internal/cmd/tests"
"go.k6.io/k6/internal/lib/testutils"
"go.k6.io/k6/lib/fsext"
"go.k6.io/k6/lib/testutils"
)

func TestArchiveThresholds(t *testing.T) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/cloud.go → internal/cmd/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"go.k6.io/k6/cmd/state"
"go.k6.io/k6/errext"
"go.k6.io/k6/errext/exitcodes"
"go.k6.io/k6/internal/ui/pb"
"go.k6.io/k6/lib"
"go.k6.io/k6/lib/consts"
"go.k6.io/k6/ui/pb"

"github.com/fatih/color"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion cmd/cloud_login.go → internal/cmd/cloud_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

"go.k6.io/k6/cloudapi"
"go.k6.io/k6/cmd/state"
"go.k6.io/k6/internal/ui"
"go.k6.io/k6/lib/consts"
"go.k6.io/k6/ui"
)

const cloudLoginCommandName = "login"
Expand Down
4 changes: 2 additions & 2 deletions cmd/cloud_run.go → internal/cmd/cloud_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"go.k6.io/k6/execution"
"go.k6.io/k6/execution/local"
"go.k6.io/k6/internal/execution"
"go.k6.io/k6/internal/execution/local"
)

const cloudRunCommandName string = "run"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"gopkg.in/guregu/null.v3"

"go.k6.io/k6/cmd/state"
"go.k6.io/k6/cmd/tests"
"go.k6.io/k6/internal/cmd/tests"
"go.k6.io/k6/lib"
"go.k6.io/k6/lib/executor"
"go.k6.io/k6/lib/fsext"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/login_cloud.go → internal/cmd/login_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

"go.k6.io/k6/cloudapi"
"go.k6.io/k6/cmd/state"
"go.k6.io/k6/internal/ui"
"go.k6.io/k6/lib/consts"
"go.k6.io/k6/ui"
)

//nolint:funlen,gocognit
Expand Down
4 changes: 2 additions & 2 deletions cmd/login_influxdb.go → internal/cmd/login_influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"gopkg.in/guregu/null.v3"

"go.k6.io/k6/cmd/state"
"go.k6.io/k6/output/influxdb"
"go.k6.io/k6/ui"
"go.k6.io/k6/internal/output/influxdb"
"go.k6.io/k6/internal/ui"
)

//nolint:funlen
Expand Down
2 changes: 1 addition & 1 deletion cmd/new.go → internal/cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"go.k6.io/k6/cmd/state"
"go.k6.io/k6/cmd/templates"
"go.k6.io/k6/internal/cmd/templates"
"go.k6.io/k6/lib/fsext"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/new_test.go → internal/cmd/new_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.k6.io/k6/cmd/tests"
"go.k6.io/k6/internal/cmd/tests"
"go.k6.io/k6/lib/fsext"
)

Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions cmd/outputs.go → internal/cmd/outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

"go.k6.io/k6/cmd/state"
"go.k6.io/k6/ext"
"go.k6.io/k6/internal/output/cloud"
"go.k6.io/k6/internal/output/influxdb"
"go.k6.io/k6/internal/output/json"
"go.k6.io/k6/lib"
"go.k6.io/k6/output"
"go.k6.io/k6/output/cloud"
"go.k6.io/k6/output/csv"
"go.k6.io/k6/output/influxdb"
"go.k6.io/k6/output/json"

"github.com/grafana/xk6-dashboard/dashboard"
"github.com/grafana/xk6-output-opentelemetry/pkg/opentelemetry"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions cmd/report.go → internal/cmd/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"runtime"
"strconv"

"go.k6.io/k6/execution"
"go.k6.io/k6/internal/execution"
"go.k6.io/k6/internal/usage"
"go.k6.io/k6/lib/consts"
"go.k6.io/k6/usage"
)

func createReport(u *usage.Usage, execScheduler *execution.Scheduler) map[string]any {
Expand Down
Loading
Loading