Skip to content

Commit

Permalink
remove: assemblyscript
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Aug 31, 2023
1 parent a7f9991 commit 0c3d47c
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 550 deletions.
6 changes: 2 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ archives:
<<: *archive_defaults
wrap_in_directory: false
format: zip

# https://goreleaser.com/customization/aur/
aurs:
-
homepage: "https://github.com/fastly/cli"
- homepage: "https://github.com/fastly/cli"
description: "A CLI for interacting with the Fastly platform"
maintainers:
- 'oss@fastly.com'
Expand Down Expand Up @@ -178,6 +176,6 @@ changelog:
# - --label=created={{ time "2006-01-02T15:04:05Z07:00" }}
# - --label=revision={{ .FullCommit }}
# - --label=licenses=Apache-2.0
# dockerfile: Dockerfile-assemblyscript
# dockerfile: Dockerfile-node
# - <<: *build_opts
# dockerfile: Dockerfile-rust
3 changes: 1 addition & 2 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ Some integration tests aren't run outside of the CI environment, to enable these
The available environment variables are:

- `TEST_COMPUTE_INIT`: runs `TestInit`.
- `TEST_COMPUTE_BUILD`: runs `TestBuildRust`, `TestBuildAssemblyScript` and `TestBuildJavaScript`.
- `TEST_COMPUTE_BUILD`: runs `TestBuildRust`, `TestBuildJavaScript`, `TestBuildGo`.
- `TEST_COMPUTE_BUILD_RUST`: runs `TestBuildRust`.
- `TEST_COMPUTE_BUILD_ASSEMBLYSCRIPT`: runs `TestBuildAssemblyScript`.
- `TEST_COMPUTE_BUILD_JAVASCRIPT`: runs `TestBuildJavaScript`.
- `TEST_COMPUTE_DEPLOY`: runs `TestDeploy`.

Expand Down
13 changes: 0 additions & 13 deletions pkg/commands/compute/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,6 @@ func toolchain(c *BuildCommand) (string, error) {
func language(toolchain string, c *BuildCommand, in io.Reader, out io.Writer, spinner text.Spinner) (*Language, error) {
var language *Language
switch toolchain {
case "assemblyscript":
language = NewLanguage(&LanguageOptions{
Name: "assemblyscript",
SourceDirectory: AsSourceDirectory,
Toolchain: NewAssemblyScript(
&c.Manifest.File,
c.Globals,
c.Flags,
in,
out,
spinner,
),
})
case "go":
language = NewLanguage(&LanguageOptions{
Name: "go",
Expand Down
153 changes: 0 additions & 153 deletions pkg/commands/compute/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,159 +501,6 @@ func TestBuildJavaScript(t *testing.T) {
}
}

func TestBuildAssemblyScript(t *testing.T) {
if os.Getenv("TEST_COMPUTE_BUILD_ASSEMBLYSCRIPT") == "" && os.Getenv("TEST_COMPUTE_BUILD") == "" {
t.Log("skipping test")
t.Skip("Set TEST_COMPUTE_BUILD to run this test")
}

args := testutil.Args

scenarios := []struct {
name string
args []string
fastlyManifest string
wantError string
wantRemediationError string
wantOutput []string
npmInstall bool
}{
{
name: "no fastly.toml manifest",
args: args("compute build"),
wantError: "error reading fastly.toml",
wantRemediationError: "Run `fastly compute init` to ensure a correctly configured manifest.",
},
{
name: "empty language",
args: args("compute build"),
fastlyManifest: `
manifest_version = 2
name = "test"`,
wantError: "language cannot be empty, please provide a language",
},
{
name: "unknown language",
args: args("compute build"),
fastlyManifest: `
manifest_version = 2
name = "test"
language = "foobar"`,
wantError: "unsupported language foobar",
},
// The following test validates that the project compiles successfully even
// though the fastly.toml manifest has no build script. There should be a
// default build script inserted.
//
// NOTE: This test passes --verbose so we can validate specific outputs.
{
name: "build script inserted dynamically when missing",
args: args("compute build --verbose"),
fastlyManifest: `
manifest_version = 2
name = "test"
language = "assemblyscript"`,
wantOutput: []string{
"No [scripts.build] found in fastly.toml.", // requires --verbose
"The following default build command for",
"npm exec -- asc",
},
},
{
name: "build error",
args: args("compute build"),
fastlyManifest: `
manifest_version = 2
name = "test"
language = "assemblyscript"
[scripts]
build = "echo no compilation happening"`,
wantRemediationError: compute.DefaultBuildErrorRemediation,
},
// NOTE: This test passes --verbose so we can validate specific outputs.
{
name: "successful build",
args: args("compute build --verbose"),
fastlyManifest: fmt.Sprintf(`
manifest_version = 2
name = "test"
language = "assemblyscript"
[scripts]
build = "%s"`, compute.AsDefaultBuildCommand),
wantOutput: []string{
"Creating ./bin directory (for Wasm binary)",
"Built package",
},
npmInstall: true,
},
}
for testcaseIdx := range scenarios {
testcase := &scenarios[testcaseIdx]
t.Run(testcase.name, func(t *testing.T) {
// We're going to chdir to a build environment,
// so save the PWD to return to, afterwards.
pwd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}

// Create test environment
rootdir := testutil.NewEnv(testutil.EnvOpts{
T: t,
Copy: []testutil.FileIO{
{Src: filepath.Join("testdata", "build", "assemblyscript", "package.json"), Dst: "package.json"},
{Src: filepath.Join("testdata", "build", "assemblyscript", "assembly", "index.ts"), Dst: filepath.Join("assembly", "index.ts")},
},
Write: []testutil.FileIO{
{Src: testcase.fastlyManifest, Dst: manifest.Filename},
},
})
defer os.RemoveAll(rootdir)

// Before running the test, chdir into the build environment.
// When we're done, chdir back to our original location.
// This is so we can reliably copy the testdata/ fixtures.
if err := os.Chdir(rootdir); err != nil {
t.Fatal(err)
}
defer os.Chdir(pwd)

// NOTE: We only want to run `npm install` for the success case.
if testcase.npmInstall {
// gosec flagged this:
// G204 (CWE-78): Subprocess launched with variable
// Disabling as we control this command.
// #nosec
// nosemgrep
cmd := exec.Command("npm", "install")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

err = cmd.Run()
if err != nil {
t.Fatal(err)
}
}

var stdout threadsafe.Buffer
opts := testutil.NewRunOpts(testcase.args, &stdout)
err = app.Run(opts)
t.Log(stdout.String())
testutil.AssertRemediationErrorContains(t, err, testcase.wantRemediationError)
// NOTE: Some errors we want to assert only the remediation.
// e.g. a 'stat' error isn't the same across operating systems/platforms.
if testcase.wantError != "" {
testutil.AssertErrorContains(t, err, testcase.wantError)
}
for _, s := range testcase.wantOutput {
testutil.AssertStringContains(t, stdout.String(), s)
}
})
}
}

// NOTE: TestBuildOther also validates the post_build settings.
func TestBuildOther(t *testing.T) {
args := testutil.Args
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/compute/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type InitCommand struct {
}

// Languages is a list of supported language options.
var Languages = []string{"rust", "javascript", "go", "assemblyscript", "other"}
var Languages = []string{"rust", "javascript", "go", "other"}

// NewInitCommand returns a usable command registered under the parent.
func NewInitCommand(parent cmd.Registerer, g *global.Data, m manifest.Data) *InitCommand {
Expand Down
17 changes: 0 additions & 17 deletions pkg/commands/compute/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ func TestInit(t *testing.T) {
Branch: "main",
},
}
skAS := []config.StarterKit{
{
Name: "Default",
Path: "https://github.com/fastly/compute-starter-kit-assemblyscript-default",
Branch: "main",
},
}

scenarios := []struct {
name string
Expand Down Expand Up @@ -328,16 +321,6 @@ func TestInit(t *testing.T) {
manifestPath: "foo",
manifestIncludes: `name = "foo`,
},
{
name: "with AssemblyScript language",
args: args("compute init --language assemblyscript"),
configFile: config.File{
StarterKits: config.StarterKitLanguages{
AssemblyScript: skAS,
},
},
manifestIncludes: `name = "fastly-temp`,
},
{
name: "with JavaScript language",
args: args("compute init --language javascript"),
Expand Down
5 changes: 0 additions & 5 deletions pkg/commands/compute/language.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ func NewLanguages(kits config.StarterKitLanguages) []*Language {
DisplayName: "Go",
StarterKits: kits.Go,
}),
NewLanguage(&LanguageOptions{
Name: "assemblyscript",
DisplayName: "AssemblyScript",
StarterKits: kits.AssemblyScript,
}),
NewLanguage(&LanguageOptions{
Name: "other",
DisplayName: "Other ('bring your own' Wasm binary)",
Expand Down
Loading

0 comments on commit 0c3d47c

Please sign in to comment.