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

Embeded gleam into k6 extension #3

Open
wants to merge 5 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
3 changes: 1 addition & 2 deletions examples/basic_k6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ This example demonstrate how to run `k6_gleam`.
## How to run

```
$ gleam run -m k6/build
$ k6 run --vu <vu> --duration <duration> runner.mjs
$ k6 run --vu <vu> --duration <duration> ./src/hello_runner.gleam
```
10 changes: 0 additions & 10 deletions examples/basic_k6/gleam.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
name = "basic_k6"
version = "1.0.0"

# Fill out these fields if you intend to generate HTML documentation or publish
# your project to the Hex package manager.
#
# description = ""
# licences = ["Apache-2.0"]
# repository = { type = "github", user = "username", repo = "project" }
# links = [{ title = "Website", href = "https://gleam.run" }]
#
# For a full reference of all the available options, you can have a look at
# https://gleam.run/writing-gleam/gleam-toml/.
target = "javascript"

[dependencies]
Expand Down
4 changes: 0 additions & 4 deletions examples/basic_k6/hello_runner.js

This file was deleted.

3 changes: 1 addition & 2 deletions examples/basic_k6/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "esgleam", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "simplifile"], otp_app = "esgleam", source = "hex", outer_checksum = "571D149ACFB7C7A81CF8C7A70ECFDA5A084ADBF706962353C0DA85787CB4DD24" },
{ name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" },
{ name = "gleam_stdlib", version = "0.37.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5398BD6C2ABA17338F676F42F404B9B7BABE1C8DC7380031ACB05BBE1BCF3742" },
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
{ name = "k6_gleam", version = "1.0.0", build_tools = ["gleam"], requirements = ["argv", "esgleam", "gleam_stdlib", "simplifile"], source = "local", path = "../.." },
{ name = "k6_gleam", version = "1.0.0", build_tools = ["gleam"], requirements = ["argv", "gleam_stdlib", "simplifile"], source = "local", path = "../.." },
{ name = "simplifile", version = "1.7.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "1D5DFA3A2F9319EC85825F6ED88B8E449F381B0D55A62F5E61424E748E7DDEB0" },
]

Expand Down
1 change: 0 additions & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ target = "javascript"

[dependencies]
gleam_stdlib = "~> 0.34 or ~> 1.0"
esgleam = "~> 0.6"
simplifile = ">= 1.7.0 and < 2.0.0"
argv = ">= 1.0.2 and < 2.0.0"

Expand Down
2 changes: 0 additions & 2 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "esgleam", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "simplifile"], otp_app = "esgleam", source = "hex", outer_checksum = "571D149ACFB7C7A81CF8C7A70ECFDA5A084ADBF706962353C0DA85787CB4DD24" },
{ name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" },
{ name = "gleam_stdlib", version = "0.36.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "C0D14D807FEC6F8A08A7C9EF8DFDE6AE5C10E40E21325B2B29365965D82EB3D4" },
{ name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" },
Expand All @@ -12,7 +11,6 @@ packages = [

[requirements]
argv = { version = ">= 1.0.2 and < 2.0.0" }
esgleam = { version = "~> 0.6" }
gleam_stdlib = { version = "~> 0.34 or ~> 1.0" }
gleeunit = { version = "~> 1.0" }
simplifile = { version = ">= 1.7.0 and < 2.0.0" }
15 changes: 0 additions & 15 deletions src/k6/build.gleam

This file was deleted.

5 changes: 0 additions & 5 deletions src/k6/internal.gleam

This file was deleted.

21 changes: 3 additions & 18 deletions src/k6/new.gleam
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import argv
import gleam/io
import gleam/string
import k6/internal
import simplifile

fn runner_js(name: String) -> String {
"import { main } from './dist/static/{{ name }}.js'

export default main
"
|> string.replace(each: "{{ name }}", with: name)
}

fn runner_gleam() -> String {
// TODO(wingyplus): modify this source to a working k6 example.
"
Expand All @@ -28,17 +19,11 @@ pub fn main() {
pub fn main() {
let assert [name] = argv.load().arguments
let assert Ok(cwd) = simplifile.current_directory()
let #(name, js_name, gleam_name) = internal.build_runner_name(name)

io.println("-- Write " <> js_name)

let assert Ok(Nil) =
string.join([cwd, js_name], with: "/")
|> simplifile.write(runner_js(name))
let runner_name = name <> "_runner"

io.println("-- Write " <> gleam_name)
io.println("-- Write " <> runner_name)

let assert Ok(Nil) =
string.join([cwd, "src", gleam_name], with: "/")
string.join([cwd, "src", runner_name <> ".gleam"], with: "/")
|> simplifile.write(runner_gleam())
}
1 change: 1 addition & 0 deletions xk6-gleam/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/k6
52 changes: 52 additions & 0 deletions xk6-gleam/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module github.com/tsloughter/k6_gleam/xk6-gleam

go 1.22.2

require (
github.com/BurntSushi/toml v1.3.2
github.com/grafana/k6pack v0.1.5
go.k6.io/k6 v0.51.0
)

require (
github.com/evanw/esbuild v0.20.2 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.33.1 // indirect
)

require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/dlclark/regexp2 v1.9.0 // indirect
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect
github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e // indirect
github.com/sirupsen/logrus v1.9.3
github.com/spf13/afero v1.1.2 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/guregu/null.v3 v3.3.0 // indirect
)
Loading
Loading