Skip to content

Commit fcf3e67

Browse files
authored
breaking: remove assemblyscript (#1001)
* remove: assemblyscript
1 parent b77fb4c commit fcf3e67

12 files changed

Lines changed: 64 additions & 383 deletions

File tree

.goreleaser.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,9 @@ archives:
7272
<<: *archive_defaults
7373
wrap_in_directory: false
7474
format: zip
75-
7675
# https://goreleaser.com/customization/aur/
7776
aurs:
78-
-
79-
homepage: "https://github.com/fastly/cli"
77+
- homepage: "https://github.com/fastly/cli"
8078
description: "A CLI for interacting with the Fastly platform"
8179
maintainers:
8280
- 'oss@fastly.com'
@@ -182,6 +180,6 @@ changelog:
182180
# - --label=created={{ time "2006-01-02T15:04:05Z07:00" }}
183181
# - --label=revision={{ .FullCommit }}
184182
# - --label=licenses=Apache-2.0
185-
# dockerfile: Dockerfile-assemblyscript
183+
# dockerfile: Dockerfile-node
186184
# - <<: *build_opts
187185
# dockerfile: Dockerfile-rust

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
[#1419](https://github.com/fastly/cli/pull/1419)
1111
- breaking(language.rust): Switch Rust builds to wasm32-wasip1 instead of wasm32-wasi [#1382](https://github.com/fastly/cli/pull/1382)
1212

13+
- breaking(language.assemblyscript): Remove support for AssemblyScript [#1001](https://github.com/fastly/cli/pull/1001/files)
14+
1315
**Enhancements:**
1416

1517
- fix(compute/init): Updates for renamed TypeScript default starter kit

TESTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ Some integration tests aren't run outside of the CI environment, to enable these
2929
The available environment variables are:
3030

3131
- `TEST_COMPUTE_INIT`: runs `TestInit`.
32-
- `TEST_COMPUTE_BUILD`: runs `TestBuildRust`, `TestBuildAssemblyScript` and `TestBuildJavaScript`.
32+
- `TEST_COMPUTE_BUILD`: runs `TestBuildRust`, `TestBuildJavaScript`, `TestBuildGo`.
3333
- `TEST_COMPUTE_BUILD_RUST`: runs `TestBuildRust`.
34-
- `TEST_COMPUTE_BUILD_ASSEMBLYSCRIPT`: runs `TestBuildAssemblyScript`.
3534
- `TEST_COMPUTE_BUILD_JAVASCRIPT`: runs `TestBuildJavaScript`.
3635
- `TEST_COMPUTE_DEPLOY`: runs `TestDeploy`.
3736

pkg/commands/compute/build.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,6 @@ func identifyToolchain(c *BuildCommand) (string, error) {
696696
func language(toolchain, manifestFilename string, c *BuildCommand, in io.Reader, out io.Writer, spinner text.Spinner) (*Language, error) {
697697
var language *Language
698698
switch toolchain {
699-
case "assemblyscript":
700-
language = NewLanguage(&LanguageOptions{
701-
Name: "assemblyscript",
702-
SourceDirectory: AsSourceDirectory,
703-
Toolchain: NewAssemblyScript(c, in, manifestFilename, out, spinner),
704-
})
705699
case "go":
706700
language = NewLanguage(&LanguageOptions{
707701
Name: "go",

pkg/commands/compute/build_test.go

Lines changed: 0 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -668,201 +668,6 @@ func TestBuildJavaScript(t *testing.T) {
668668
}
669669
}
670670

671-
func TestBuildAssemblyScript(t *testing.T) {
672-
if os.Getenv("TEST_COMPUTE_BUILD_ASSEMBLYSCRIPT") == "" && os.Getenv("TEST_COMPUTE_BUILD") == "" {
673-
t.Log("skipping test")
674-
t.Skip("Set TEST_COMPUTE_BUILD to run this test")
675-
}
676-
677-
args := testutil.SplitArgs
678-
679-
scenarios := []struct {
680-
name string
681-
args []string
682-
fastlyManifest string
683-
wantError string
684-
wantRemediationError string
685-
wantOutput []string
686-
npmInstall bool
687-
}{
688-
{
689-
name: "no fastly.toml manifest",
690-
args: args("compute build"),
691-
wantError: "error reading fastly.toml",
692-
wantRemediationError: "Run `fastly compute init` to ensure a correctly configured manifest.",
693-
},
694-
{
695-
name: "empty language",
696-
args: args("compute build"),
697-
fastlyManifest: `
698-
manifest_version = 2
699-
name = "test"`,
700-
wantError: "language cannot be empty, please provide a language",
701-
},
702-
{
703-
name: "unknown language",
704-
args: args("compute build"),
705-
fastlyManifest: `
706-
manifest_version = 2
707-
name = "test"
708-
language = "foobar"`,
709-
wantError: "unsupported language foobar",
710-
},
711-
// The following test validates that the project compiles successfully even
712-
// though the fastly.toml manifest has no build script. There should be a
713-
// default build script inserted.
714-
//
715-
// NOTE: This test passes --verbose so we can validate specific outputs.
716-
{
717-
name: "build script inserted dynamically when missing",
718-
args: args("compute build --verbose"),
719-
fastlyManifest: `
720-
manifest_version = 2
721-
name = "test"
722-
language = "assemblyscript"`,
723-
wantOutput: []string{
724-
"No [scripts.build] found in fastly.toml.", // requires --verbose
725-
"The following default build command for",
726-
"npm exec -- asc",
727-
},
728-
},
729-
{
730-
name: "build error",
731-
args: args("compute build"),
732-
fastlyManifest: `
733-
manifest_version = 2
734-
name = "test"
735-
language = "assemblyscript"
736-
737-
[scripts]
738-
build = "echo no compilation happening"`,
739-
wantRemediationError: compute.DefaultBuildErrorRemediation,
740-
},
741-
// NOTE: This test passes --verbose so we can validate specific outputs.
742-
{
743-
name: "successful build",
744-
args: args("compute build --verbose"),
745-
fastlyManifest: fmt.Sprintf(`
746-
manifest_version = 2
747-
name = "test"
748-
language = "assemblyscript"
749-
750-
[scripts]
751-
build = "%s"`, compute.AsDefaultBuildCommand),
752-
wantOutput: []string{
753-
"Creating ./bin directory (for Wasm binary)",
754-
"Built package",
755-
},
756-
npmInstall: true,
757-
},
758-
}
759-
for testcaseIdx := range scenarios {
760-
testcase := &scenarios[testcaseIdx]
761-
t.Run(testcase.name, func(t *testing.T) {
762-
// We're going to chdir to a build environment,
763-
// so save the PWD to return to, afterwards.
764-
pwd, err := os.Getwd()
765-
if err != nil {
766-
t.Fatal(err)
767-
}
768-
769-
wasmtoolsBinName := "wasm-tools"
770-
771-
// Windows was having issues when trying to move a tmpBin file (which
772-
// represents the latest binary downloaded from GitHub) to binPath (which
773-
// represents the existing binary installed on a user's machine).
774-
//
775-
// The problem was, for the sake of the tests, I just create one file
776-
// `wasmtoolsBinName` and used that for both `tmpBin` and `binPath` and
777-
// this works fine on *nix systems. But once Windows did `os.Rename()` and
778-
// move tmpBin to binPath it would no longer be able to set permissions on
779-
// the binPath because it didn't think the file existed any more. My guess
780-
// is that moving a file over itself causes Windows to remove the file.
781-
//
782-
// So to work around that issue I just create two separate files because
783-
// in reality that's what the CLI will be dealing with. I only used one
784-
// file for the sake of test case convenience (which ironically became
785-
// very INCONVENIENT when the tests started unexpectedly failing on
786-
// Windows and caused me a long time debugging).
787-
latestDownloaded := wasmtoolsBinName + "-latest-downloaded"
788-
789-
// Create test environment
790-
rootdir := testutil.NewEnv(testutil.EnvOpts{
791-
T: t,
792-
Copy: []testutil.FileIO{
793-
{Src: filepath.Join("testdata", "build", "assemblyscript", "package.json"), Dst: "package.json"},
794-
{Src: filepath.Join("testdata", "build", "assemblyscript", "assembly", "index.ts"), Dst: filepath.Join("assembly", "index.ts")},
795-
},
796-
Write: []testutil.FileIO{
797-
{Src: `#!/usr/bin/env bash
798-
echo wasm-tools 1.0.4`, Dst: wasmtoolsBinName, Executable: true},
799-
{Src: `#!/usr/bin/env bash
800-
echo wasm-tools 2.0.0`, Dst: latestDownloaded, Executable: true},
801-
{Src: testcase.fastlyManifest, Dst: manifest.Filename},
802-
},
803-
})
804-
defer os.RemoveAll(rootdir)
805-
wasmtoolsBinPath := filepath.Join(rootdir, wasmtoolsBinName)
806-
807-
// Before running the test, chdir into the build environment.
808-
// When we're done, chdir back to our original location.
809-
// This is so we can reliably copy the testdata/ fixtures.
810-
if err := os.Chdir(rootdir); err != nil {
811-
t.Fatal(err)
812-
}
813-
defer func() {
814-
_ = os.Chdir(pwd)
815-
}()
816-
817-
// NOTE: We only want to run `npm install` for the success case.
818-
if testcase.npmInstall {
819-
// gosec flagged this:
820-
// G204 (CWE-78): Subprocess launched with variable
821-
// Disabling as we control this command.
822-
// #nosec
823-
// nosemgrep
824-
c := exec.Command("npm", "install")
825-
c.Stdout = os.Stdout
826-
c.Stderr = os.Stderr
827-
828-
err = c.Run()
829-
if err != nil {
830-
t.Fatal(err)
831-
}
832-
}
833-
834-
var stdout threadsafe.Buffer
835-
app.Init = func(_ []string, _ io.Reader) (*global.Data, error) {
836-
opts := testutil.MockGlobalData(testcase.args, &stdout)
837-
opts.Versioners = global.Versioners{
838-
WasmTools: mock.AssetVersioner{
839-
AssetVersion: "1.2.3",
840-
BinaryFilename: wasmtoolsBinName,
841-
DownloadOK: true,
842-
DownloadedFile: latestDownloaded,
843-
InstallFilePath: wasmtoolsBinPath, // avoid overwriting developer's actual wasm-tools install
844-
},
845-
}
846-
return opts, nil
847-
}
848-
err = app.Run(testcase.args, nil)
849-
850-
t.Log(stdout.String())
851-
852-
testutil.AssertRemediationErrorContains(t, err, testcase.wantRemediationError)
853-
854-
// NOTE: Some errors we want to assert only the remediation.
855-
// e.g. a 'stat' error isn't the same across operating systems/platforms.
856-
if testcase.wantError != "" {
857-
testutil.AssertErrorContains(t, err, testcase.wantError)
858-
}
859-
for _, s := range testcase.wantOutput {
860-
testutil.AssertStringContains(t, stdout.String(), s)
861-
}
862-
})
863-
}
864-
}
865-
866671
// NOTE: TestBuildOther also validates the post_build settings.
867672
func TestBuildOther(t *testing.T) {
868673
args := testutil.SplitArgs

pkg/commands/compute/testdata/build/assemblyscript/assembly/index.ts

Lines changed: 0 additions & 79 deletions
This file was deleted.

pkg/commands/compute/testdata/build/assemblyscript/package.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

pkg/config/config.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,9 @@ type Profile struct {
168168

169169
// StarterKitLanguages represents language specific starter kits.
170170
type StarterKitLanguages struct {
171-
AssemblyScript []StarterKit `toml:"assemblyscript"`
172-
Go []StarterKit `toml:"go"`
173-
JavaScript []StarterKit `toml:"javascript"`
174-
Rust []StarterKit `toml:"rust"`
171+
Go []StarterKit `toml:"go"`
172+
JavaScript []StarterKit `toml:"javascript"`
173+
Rust []StarterKit `toml:"rust"`
175174
}
176175

177176
// StarterKit represents starter kit specific configuration.

0 commit comments

Comments
 (0)