Skip to content

Commit

Permalink
remove: assemblyscript
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Nov 8, 2023
1 parent 1c9e13a commit 3a6e651
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 386 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:
- '[email protected]'
Expand Down Expand Up @@ -183,6 +181,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
6 changes: 0 additions & 6 deletions pkg/commands/compute/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,6 @@ func identifyToolchain(c *BuildCommand) (string, error) {
func language(toolchain, manifestFilename 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, in, manifestFilename, out, spinner),
})
case "go":
language = NewLanguage(&LanguageOptions{
Name: "go",
Expand Down
193 changes: 0 additions & 193 deletions pkg/commands/compute/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,199 +623,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)
}

wasmtoolsBinName := "wasm-tools"

// Windows was having issues when trying to move a tmpBin file (which
// represents the latest binary downloaded from GitHub) to binPath (which
// represents the existing binary installed on a user's machine).
//
// The problem was, for the sake of the tests, I just create one file
// `wasmtoolsBinName` and used that for both `tmpBin` and `binPath` and
// this works fine on *nix systems. But once Windows did `os.Rename()` and
// move tmpBin to binPath it would no longer be able to set permissions on
// the binPath because it didn't think the file existed any more. My guess
// is that moving a file over itself causes Windows to remove the file.
//
// So to work around that issue I just create two separate files because
// in reality that's what the CLI will be dealing with. I only used one
// file for the sake of test case convenience (which ironically became
// very INCONVENIENT when the tests started unexpectedly failing on
// Windows and caused me a long time debugging).
latestDownloaded := wasmtoolsBinName + "-latest-downloaded"

// 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: `#!/usr/bin/env bash
echo wasm-tools 1.0.4`, Dst: wasmtoolsBinName, Executable: true},
{Src: `#!/usr/bin/env bash
echo wasm-tools 2.0.0`, Dst: latestDownloaded, Executable: true},
{Src: testcase.fastlyManifest, Dst: manifest.Filename},
},
})
defer os.RemoveAll(rootdir)
wasmtoolsBinPath := filepath.Join(rootdir, wasmtoolsBinName)

// 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 func() {
_ = 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)
opts.Versioners = app.Versioners{
WasmTools: mock.AssetVersioner{
AssetVersion: "1.2.3",
BinaryFilename: wasmtoolsBinName,
DownloadOK: true,
DownloadedFile: latestDownloaded,
InstallFilePath: wasmtoolsBinPath, // avoid overwriting developer's actual wasm-tools install
},
}

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

This file was deleted.

23 changes: 0 additions & 23 deletions pkg/commands/compute/testdata/build/assemblyscript/package.json

This file was deleted.

7 changes: 3 additions & 4 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ type Profile struct {

// StarterKitLanguages represents language specific starter kits.
type StarterKitLanguages struct {
AssemblyScript []StarterKit `toml:"assemblyscript"`
Go []StarterKit `toml:"go"`
JavaScript []StarterKit `toml:"javascript"`
Rust []StarterKit `toml:"rust"`
Go []StarterKit `toml:"go"`
JavaScript []StarterKit `toml:"javascript"`
Rust []StarterKit `toml:"rust"`
}

// StarterKit represents starter kit specific configuration.
Expand Down
25 changes: 10 additions & 15 deletions pkg/config/testdata/config-incompatible-config-version.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,18 @@ last_checked = "2021-06-18T15:13:34+01:00"
version = "0.0.1"

[language]
[language.rust]
# we're missing the 'toolchain_constraint' property
wasm_wasi_target = "wasm32-wasi"
[language.rust]
# we're missing the 'toolchain_constraint' property
wasm_wasi_target = "wasm32-wasi"

[starter-kits]
[[starter-kits.assemblyscript]]
name = "Default"
path = "https://github.com/fastly/compute-starter-kit-assemblyscript-default"
tag = "v0.2.1"
[[starter-kits.rust]]
name = "Default"
path = "https://github.com/fastly/compute-starter-kit-rust-default.git"
branch = "0.7"
name = "Default"
path = "https://github.com/fastly/compute-starter-kit-rust-default.git"
branch = "0.7"
[[starter-kits.rust]]
name = "Beacon"
path = "https://github.com/fastly/compute-starter-kit-rust-beacon-termination.git"
name = "Beacon"
path = "https://github.com/fastly/compute-starter-kit-rust-beacon-termination.git"
[[starter-kits.rust]]
name = "Static"
path = "https://github.com/fastly/compute-starter-kit-rust-static-content.git"

name = "Static"
path = "https://github.com/fastly/compute-starter-kit-rust-static-content.git"
Loading

0 comments on commit 3a6e651

Please sign in to comment.