Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivanshVij committed Oct 9, 2023
2 parents 2a6eee6 + 233e230 commit fbf517f
Show file tree
Hide file tree
Showing 33 changed files with 210 additions and 69 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
version: latest
args: --timeout=5m
25 changes: 22 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,25 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [v0.4.4] - 2023-08-05
## [v0.4.5] - 2023-10-09

### Features

- Environment Variables set during the scale function build command now get passed properly to the downstream commands
- The build system now allows for wasi and wasm targets depending on the user's choice

### Fixes

- Using init function for Rust plugins now properly builds and does not cause builds to break
- The Rust build step now properly verifies the build target with Cargo
- The storage manager now properly generates TypeScript signatures for both the guest and the host

### Changes

- The TypeScript manifest generator for builds and signatures now returns a pretty-printed package.json
- The signature builder now returns the tar.gz format for TypeScript signatures as well as the raw files

## [v0.4.4] - 2023-10-05

### Features

Expand All @@ -17,7 +35,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Fixed a bug where the signature generation would not generate typescript signatures

## [v0.4.3] - 2023-08-04
## [v0.4.3] - 2023-10-04

### Changes

Expand Down Expand Up @@ -281,7 +299,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Initial release of the Scale Runtime library.

[unreleased]: https://github.com/loopholelabs/scale/compare/v0.4.4...HEAD
[unreleased]: https://github.com/loopholelabs/scale/compare/v0.4.5...HEAD
[v0.4.5]: https://github.com/loopholelabs/scale/compare/v0.4.5
[v0.4.4]: https://github.com/loopholelabs/scale/compare/v0.4.4
[v0.4.3]: https://github.com/loopholelabs/scale/compare/v0.4.3
[v0.4.2]: https://github.com/loopholelabs/scale/compare/v0.4.2
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scale_rs"
version = "0.4.4"
version = "0.4.5"
edition = "2021"
description = "Scale is a framework for building high-performance plugin systems into any application, all powered by WebAssembly."
homepage = "https://scale.sh"
Expand Down
2 changes: 2 additions & 0 deletions build/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func LocalGolang(options *LocalGolangOptions) (*scalefunc.Schema, error) {
cmd.Dir = compilePath
cmd.Stdout = options.Output
cmd.Stderr = options.Output
cmd.Env = os.Environ()
err = cmd.Run()
if err != nil {
return nil, fmt.Errorf("unable to compile scale function: %w", err)
Expand All @@ -212,6 +213,7 @@ func LocalGolang(options *LocalGolangOptions) (*scalefunc.Schema, error) {
cmd.Dir = compilePath
cmd.Stdout = options.Output
cmd.Stderr = options.Output
cmd.Env = os.Environ()
err = cmd.Run()
if err != nil {
return nil, fmt.Errorf("unable to compile scale function: %w", err)
Expand Down
20 changes: 11 additions & 9 deletions build/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,6 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) {
return nil, fmt.Errorf("unable to create lib.rs file: %w", err)
}

cmd := exec.Command(options.CargoBin, "check")
cmd.Dir = compilePath
cmd.Stdout = options.Output
cmd.Stderr = options.Output
err = cmd.Run()
if err != nil {
return nil, fmt.Errorf("unable to compile scale function: %w", err)
}

var target string
switch options.Target {
case WASITarget:
Expand All @@ -179,6 +170,16 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) {
return nil, fmt.Errorf("unknown build target %d", options.Target)
}

cmd := exec.Command(options.CargoBin, "check", "--target", target)
cmd.Dir = compilePath
cmd.Stdout = options.Output
cmd.Stderr = options.Output
cmd.Env = os.Environ()
err = cmd.Run()
if err != nil {
return nil, fmt.Errorf("unable to compile scale function: %w", err)
}

buildArgs := append([]string{"build"}, options.Args...)
if options.Release {
buildArgs = append(buildArgs, "--release")
Expand All @@ -189,6 +190,7 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) {
cmd.Dir = compilePath
cmd.Stdout = options.Output
cmd.Stderr = options.Output
cmd.Env = os.Environ()
err = cmd.Run()
if err != nil {
return nil, fmt.Errorf("unable to compile scale function: %w", err)
Expand Down
2 changes: 2 additions & 0 deletions build/typescript.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func LocalTypescript(options *LocalTypescriptOptions) (*scalefunc.Schema, error)
cmd.Dir = compilePath
cmd.Stderr = options.Output
cmd.Stdout = options.Output
cmd.Env = os.Environ()
err = cmd.Run()
if err != nil {
return nil, fmt.Errorf("unable to compile scale function and update npm: %w", err)
Expand Down Expand Up @@ -266,6 +267,7 @@ func LocalTypescript(options *LocalTypescriptOptions) (*scalefunc.Schema, error)
cmd.Stdin = strings.NewReader(string(result.OutputFiles[0].Contents))
cmd.Stderr = options.Output
cmd.Stdout = options.Output
cmd.Env = os.Environ()
err = cmd.Run()
if err != nil {
return nil, fmt.Errorf("unable to compile scale function using js_builder: %w", err)
Expand Down
8 changes: 6 additions & 2 deletions compile/rust/templates/lib.rs.templ
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ pub unsafe extern "C" fn initialize() -> u64 {
{{ if .package_schema.Initialize }}
return match {{ .package_schema.Name }}::{{ .package_schema.Initialize }}() {
Ok(_) => { 0 },
Err(err) => { packUint32(signature.Error(err)) }
Err(err) => {
let (ptr, len) = signature::error(err);
pack_uint32(ptr, len)
}
};
{{ end }}
{{ else }}
0
{{ end }}
}

#[cfg_attr(target_arch = "wasm32", export_name = "run")]
Expand Down
2 changes: 1 addition & 1 deletion compile/typescript/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,5 @@ func (m *Manifest) Write() ([]byte, error) {
m.packageJSON.internal["devDependencies"] = m.packageJSON.DevDependencies
}

return json.Marshal(m.packageJSON.internal)
return json.MarshalIndent(m.packageJSON.internal, "", "\t")
}
12 changes: 5 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,27 @@ go 1.20

require (
github.com/BurntSushi/toml v1.3.2
github.com/evanw/esbuild v0.19.3
github.com/evanw/esbuild v0.19.4
github.com/google/uuid v1.3.1
github.com/hashicorp/hcl/v2 v2.18.0
github.com/hashicorp/hcl/v2 v2.18.1
github.com/loopholelabs/polyglot v1.1.3
github.com/loopholelabs/scale-signature-interfaces v0.1.7
github.com/stretchr/testify v1.8.4
github.com/tetratelabs/wazero v1.5.0
golang.org/x/mod v0.12.0
golang.org/x/mod v0.13.0
golang.org/x/text v0.13.0
)

require (
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/zclconf/go-cty v1.13.2 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
golang.org/x/sys v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
25 changes: 11 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/evanw/esbuild v0.19.3 h1:foPr0xwQM3lBWKBtscauTN9FrmJzRDVI2+EGOs82H/I=
github.com/evanw/esbuild v0.19.3/go.mod h1:iINY06rn799hi48UqEnaQvVfZWe6W9bET78LbvN8VWk=
github.com/evanw/esbuild v0.19.4 h1:Etk+6ZCjtNxZZLEgMKSqpO0/oM0k1WYKJabaPMJ39iQ=
github.com/evanw/esbuild v0.19.4/go.mod h1:iINY06rn799hi48UqEnaQvVfZWe6W9bET78LbvN8VWk=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8=
github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
github.com/hashicorp/hcl/v2 v2.18.1 h1:6nxnOJFku1EuSawSD81fuviYUV8DxFr3fp2dUi3ZYSo=
github.com/hashicorp/hcl/v2 v2.18.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
Expand All @@ -44,17 +42,16 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/tetratelabs/wazero v1.5.0 h1:Yz3fZHivfDiZFUXnWMPUoiW7s8tC1sjdBtlJn08qYa0=
github.com/tetratelabs/wazero v1.5.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A=
github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0=
github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA=
github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901 h1:0wxTF6pSjIIhNt7mo9GvjDfzyCOiWhmICgtO/Ah948s=
golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
Expand Down
2 changes: 1 addition & 1 deletion integration/golang_tests/generated/generated.go

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

2 changes: 1 addition & 1 deletion integration/golang_tests/host_signature/host.go

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

2 changes: 1 addition & 1 deletion integration/golang_tests/host_signature/types.go

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

2 changes: 1 addition & 1 deletion integration/golang_tests/signature/guest.go

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

2 changes: 1 addition & 1 deletion integration/golang_tests/signature/types.go

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

2 changes: 1 addition & 1 deletion integration/rust_tests/generated/generated.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by scale-signature 0.4.4, DO NOT EDIT.
// Code generated by scale-signature 0.4.5, DO NOT EDIT.
// output: generated

#![allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion integration/rust_tests/signature/guest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by scale-signature 0.4.4, DO NOT EDIT.
// Code generated by scale-signature 0.4.5, DO NOT EDIT.
// output: local_example_latest_guest

pub mod types;
Expand Down
2 changes: 1 addition & 1 deletion integration/rust_tests/signature/types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by scale-signature 0.4.4, DO NOT EDIT.
// Code generated by scale-signature 0.4.5, DO NOT EDIT.
// output: local_example_latest_guest

#![allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion integration/typescript_tests/generated/generated.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by scale-signature 0.4.4, DO NOT EDIT.
// Code generated by scale-signature 0.4.5, DO NOT EDIT.
// output: generated

import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot"
Expand Down
2 changes: 1 addition & 1 deletion integration/typescript_tests/generated/generated.js

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

2 changes: 1 addition & 1 deletion integration/typescript_tests/generated/generated.js.map

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

2 changes: 1 addition & 1 deletion integration/typescript_tests/host_signature/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by scale-signature 0.4.4, DO NOT EDIT.
// Code generated by scale-signature 0.4.5, DO NOT EDIT.
// output: local-example-latest-host

/* eslint no-bitwise: off */
Expand Down
2 changes: 1 addition & 1 deletion integration/typescript_tests/host_signature/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by scale-signature 0.4.4, DO NOT EDIT.
// Code generated by scale-signature 0.4.5, DO NOT EDIT.
// output: local-example-latest-host

import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot"
Expand Down
2 changes: 1 addition & 1 deletion integration/typescript_tests/signature/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by scale-signature 0.4.4, DO NOT EDIT.
// Code generated by scale-signature 0.4.5, DO NOT EDIT.
// output: local-example-latest-guest

/* eslint no-bitwise: off */
Expand Down
2 changes: 1 addition & 1 deletion integration/typescript_tests/signature/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by scale-signature 0.4.4, DO NOT EDIT.
// Code generated by scale-signature 0.4.5, DO NOT EDIT.
// output: local-example-latest-guest

import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@loopholelabs/scale",
"version": "0.4.4",
"version": "0.4.5",
"description": "Scale is a framework for building high-performance plugin systems into any application, all powered by WebAssembly.",
"source": "index.ts",
"types": "types.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion signature/converter/converter_tests/generated.go

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

Loading

0 comments on commit fbf517f

Please sign in to comment.