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

Add abs module installer #277

Merged
merged 1 commit into from
Sep 18, 2019
Merged

Add abs module installer #277

merged 1 commit into from
Sep 18, 2019

Conversation

mingwho
Copy link
Contributor

@mingwho mingwho commented Aug 27, 2019

We can run something like get github.com/hashicorp/go-getter to install a package into ./vendor folder. This will create a JSON file alias in the current directory containing a mapping of alias and relative path

{
    "go-getter" : " ./vendor/github.com/hashicorp/go-getter"
}

In an abs script, we can use g = require("go-getter") to use the package

Update:
The current implementation uses https protocol to get a zip file from Github repository and unzips it under the /vendor directory.
The unzip file part is copied from https://golangcode.com/unzip-files-in-go/
Some parts are a bit hack-ish. We can discuss further.

Copy link
Collaborator

@odino odino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! I have a few comments (small stuff) but I also want to bring a couple things up here:

  • the binary size skyrocketed due to go-getter, and I think we should revert and try either another library or implement a small HTTP client to fetch dependencies from github only
~/projects/abs (pr-277 ✔) ᐅ du -hs ./builds/*                                              
22M	./builds/abs
15M	./builds/abs-1.8.0-darwin-386
18M	./builds/abs-1.8.0-darwin-amd64
14M	./builds/abs-1.8.0-linux-386
17M	./builds/abs-1.8.0-linux-amd64
14M	./builds/abs-1.8.0-linux-arm
16M	./builds/abs-1.8.0-linux-arm64
16M	./builds/abs-1.8.0-linux-ppc64
16M	./builds/abs-1.8.0-linux-ppc64le
14M	./builds/abs-1.8.0-windows-386.exe
17M	./builds/abs-1.8.0-windows-amd64.exe
2.2M	./builds/builds.zip
~/projects/abs (pr-277 ✔) ᐅ ck 1.8.x
Switched to branch '1.8.x'
Your branch is up-to-date with 'origin/1.8.x'.
~/projects/abs (1.8.x ✔) ᐅ make release
go build -o builds/abs main.go
./builds/abs ./scripts/release.abs
Deleting previous builds...
Running builds for version 1.8.0, confirm by typing "y"
y
Building linux 386
Building linux amd64
Building linux arm
Building linux arm64
Building linux ppc64
Building linux ppc64le
Building linux arm
Building linux arm64
Building windows amd64
Building windows 386
Building darwin amd64
Building darwin 386
Building js wasm
done
~/projects/abs (1.8.x ✘)✹ ᐅ du -hs ./builds/*
3.9M	./builds/abs
2.6M	./builds/abs-1.8.0-darwin-386
3.0M	./builds/abs-1.8.0-darwin-amd64
2.4M	./builds/abs-1.8.0-linux-386
2.8M	./builds/abs-1.8.0-linux-amd64
2.4M	./builds/abs-1.8.0-linux-arm
2.7M	./builds/abs-1.8.0-linux-arm64
2.8M	./builds/abs-1.8.0-linux-ppc64
2.8M	./builds/abs-1.8.0-linux-ppc64le
2.5M	./builds/abs-1.8.0-windows-386.exe
3.0M	./builds/abs-1.8.0-windows-amd64.exe
2.2M	./builds/builds.zip
  • tests are not passing on travis -- if you need some help lmk! It's something funny with dependencies, so I'm also not sure what's up (everything passes on my local machine)
  • could we have some installer-specific tests on travis? Just download a couple dependencies with the same "last name", and test their aliases in a simple script

main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
util/util.go Outdated Show resolved Hide resolved
@mingwho mingwho force-pushed the installer branch 2 times, most recently from a8f5bb4 to c2f2746 Compare September 13, 2019 09:40
install/install.go Outdated Show resolved Hide resolved
util/util.go Outdated Show resolved Hide resolved
return
}

err := getZip(module)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to print out the stages we're at:

  • downloading (with %)
  • unpacking
  • creating alias
  • done...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The percent part needs some discussion 😄 it seems like HEAD github zip header does not return content-length so we need to think about a work-around

➜  ~ curl https://github.com/mingwho/abs/archive/master.zip
<html><body>You are being <a href="https://codeload.github.com/mingwho/abs/zip/master">redirected</a>.</body></html>%

➜  ~ curl -I https://codeload.github.com/mingwho/abs/zip/master
HTTP/1.1 200 OK
...
Content-Type: application/zip
Content-Disposition: attachment; filename=abs-master.zip
...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's forget about this for now then -- let's just use a CLI loader like this:

package main

import (
	"fmt"
	"time"
)

func main() {
	symbols := []string{"🌑 ", "🌒 ", "🌓 ", "🌔 ", "🌕 ", "🌖 ", "🌗 ", "🌘 "}
	i := 0

	for true {
		fmt.Printf("\r" + symbols[i] + " - downloading archive")
		time.Sleep(100 * time.Millisecond)
		i++
		if i > len(symbols)-1 {
			i = 0
		}
	}
}

Later on we can figure out how to print the progress bar :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WOW THIS IS COOL 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added CLI loader for download archive!

install/install.go Show resolved Hide resolved
go.sum Outdated Show resolved Hide resolved
@mingwho mingwho force-pushed the installer branch 3 times, most recently from a958c6b to 822747c Compare September 16, 2019 17:25
@mingwho
Copy link
Contributor Author

mingwho commented Sep 16, 2019

TODO: I still need to write some tests for this 😄

@mingwho mingwho force-pushed the installer branch 5 times, most recently from 77c33fa to b7614b0 Compare September 16, 2019 17:43
Copy link
Collaborator

@odino odino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yoo-hoo, I see this is almost done!

evaluator/functions.go Outdated Show resolved Hide resolved
return
}

err := getZip(module)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's forget about this for now then -- let's just use a CLI loader like this:

package main

import (
	"fmt"
	"time"
)

func main() {
	symbols := []string{"🌑 ", "🌒 ", "🌓 ", "🌔 ", "🌕 ", "🌖 ", "🌗 ", "🌘 "}
	i := 0

	for true {
		fmt.Printf("\r" + symbols[i] + " - downloading archive")
		time.Sleep(100 * time.Millisecond)
		i++
		if i > len(symbols)-1 {
			i = 0
		}
	}
}

Later on we can figure out how to print the progress bar :)

util/util.go Outdated
@@ -40,6 +44,21 @@ func ExpandPath(path string) (string, error) {
return filepath.Join(usr.HomeDir, path[1:]), nil
}

func FindAlias(path string) (string, error) {
if len(packageAlias) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the alias file is empty will this always be true, leading to us opening the file everytime instead of memoizing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the note! I just added one memoization function. It should work smoothly now

@odino
Copy link
Collaborator

odino commented Sep 18, 2019

Planning to merge this today, and release 1.8 (might get delayed to tomm if I don't get enough time). I might make some small amends to this or later on, but great stuff! This is great!

@odino odino merged commit c5b19d3 into abs-lang:1.8.x Sep 18, 2019
@mingwho
Copy link
Contributor Author

mingwho commented Sep 18, 2019

Thanks for the update 👍! I will have a look on the amends also 😄!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants