Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/git-lib.bass
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

(defn main []
(run
(from gh:cli
(from gh:image
($ gh --version)
($ ls git:github/vito/bass/ref/main/))))
6 changes: 1 addition & 5 deletions docs/go/bass.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"image/color"
"io"
"os"
"os/signal"
"path"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -978,16 +977,13 @@ func newTerm() *vt100.VT100 {
}

func withProgress(ctx context.Context, name string, f func(context.Context) (bass.Value, error)) (bass.Value, *vt100.VT100) {
ctx, stop := signal.NotifyContext(ctx, os.Interrupt)
defer stop()

statuses, progW := progrock.Pipe()

recorder := progrock.NewRecorder(progW)
ctx = progrock.RecorderToContext(ctx, recorder)

vterm := newTerm()
model := ui.NewModel(stop, vterm, cli.ProgressUI, false)
model := ui.NewModel(func() {}, vterm, cli.ProgressUI, false)
model.SetWindowSize(200, 100)

wg := new(sync.WaitGroup)
Expand Down
2 changes: 1 addition & 1 deletion hack/with-creds
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

op run --env-file $(dirname $0)/../creds.env "$@"
op run --no-masking --env-file $(dirname $0)/../creds.env "$@"
2 changes: 1 addition & 1 deletion pkg/bass/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (value *Scope) eachShadow(top *Scope, f func(Symbol, Value) error, called m

err := f(k, v)
if err != nil {
return fmt.Errorf("%s: %w", k, err)
return fmt.Errorf("scope each: %s: %w", k, err)
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/hl/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ func bassRules() Rules {
words[i] = string(class.Bindings[i])
}

if len(words) == 0 {
// none; prevent zero-length match
continue
}

tokenType, found := class2chroma[class.Class]
if !found {
panic(fmt.Sprintf("unknown chroma token type for class: %s", class))
Expand Down
17 changes: 0 additions & 17 deletions pkg/runtimes/bass.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,6 @@ func (runtime *Bass) Run(ctx context.Context, w io.Writer, thunk bass.Thunk) err
return nil
}

func (runtime *Bass) Response(ctx context.Context, w io.Writer, thunk bass.Thunk) error {
_, response, err := runtime.run(ctx, thunk, true)
if err != nil {
return err
}

// XXX: this is a little strange since the other end just unmarshals it,
// but let's roll with it for now so we don't have to rehash the runtime
// interface
//
// the runtime interface just takes an io.Writer in case someday we want to
// handle direct responses (not JSON streams) - worth reconsidering at some
// point so this can just return an InMemorySource
_, err = w.Write(response)
return err
}

func (runtime *Bass) Load(ctx context.Context, thunk bass.Thunk) (*bass.Scope, error) {
module, _, err := runtime.run(ctx, thunk, false)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/cache-paths.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def test-cache-path
(subpath /test/counter/ (string->fs-path (str (now 0)))))

Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/dir.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(next (read (-> (./cat 42)
(with-dir /bin/)
(with-image (linux/alpine)))
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/env.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(next (read (-> ($ sh -c "echo $FOO")
(with-env {:FOO "42"})
(with-image (linux/alpine)))
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/fs-paths.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def fs
(mkfs ./foo "1\n"
./bar/baz "2\n"
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/host-paths-sparse.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def cat-files
(from (linux/alpine)
($ cat
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/host-paths.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def thunk-arg
(from (linux/alpine)
($ cat *dir*/host-paths/one)))
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/many-layers-workdir.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def many-layers
(from (linux/alpine)
($ sh -c "echo 1 > a")
Expand Down
32 changes: 32 additions & 0 deletions pkg/runtimes/testdata/memos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"memo": {
"LR-ZTgqORmWVgYzlV0Tt74kKbUXf6h0bIph_heb-wHQ=:resolve": [
{
"input": [
{
"platform": {
"os": "linux"
},
"repository": "alpine",
"tag": "latest"
}
],
"output": {
"digest": "sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454",
"platform": {
"os": "linux"
},
"repository": "alpine",
"tag": "latest"
}
}
]
},
"thunks": {
"LR-ZTgqORmWVgYzlV0Tt74kKbUXf6h0bIph_heb-wHQ=": {
"cmd": {
"command": "run"
}
}
}
}
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/mount-run-dir.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def created
(from (linux/alpine)
($ mkdir ./some-dir/)
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/mount.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def created
(from (linux/alpine)
($ mkdir ./some-dir/)
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/multi-env.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(let [echo-envs (-> ($ sh -c "echo $FOO $BAR")
(with-env {:FOO "42" :BAR "21"})
(with-image (linux/alpine)))
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/oci-archive-image.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def hello
(subpath
(from (linux/alpine)
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/read-path.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(defn echo [content]
(-> ($ sh -c "echo \"$1\" > file" sh $content)
(with-image (linux/alpine))
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/recursive.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def create
(from (linux/alpine)
($ sh -c "echo 42 > hello")))
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/remount-workdir-subdir.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def initial
(subpath
(from (linux/alpine)
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/remount-workdir.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def initial
(-> ($ touch ./foo)
(with-image (linux/alpine))
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/response-file.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def values
[null false true 42 "hello" [] [0 "one" -2] {} {:foo "bar"}])

Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/response-stdout.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def values
[null false true 42 "hello" [] [0 "one" -2] {} {:foo "bar"}])

Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/run-thunk-path.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def hello
(from (linux/alpine)
($ sh -c "echo \"#!/bin/sh\n\necho 42\n\" > some-script")
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/secrets.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def bruce-banner
(mask *env*:SECRET :bruce-banner))

Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/sleep.bass
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
(def *memos* *dir*/memos.json)

(run (-> ($ sleep "999") (with-label :now (now 1)) (with-image (linux/alpine))))
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/succeeds.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

[(succeeds?
(from (linux/alpine)
($ sh -c "exit 1")))
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/thunk-path-dir-thunk-path-inputs.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def create-dir
"mkdir some-dir; echo 1 > some-dir/some-file")

Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/thunk-path-dir.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def created
(from (linux/alpine)
($ mkdir ./some-dir/)
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/thunk-path-env.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def created
(from (linux/alpine)
($ sh -c "echo \"#!/bin/sh\n\necho 42\n\" > some-script")
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/thunk-path-image.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def test
(from (linux/alpine)
($ sh -c "echo 42 > foo")
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/thunk-paths.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def create-files
"echo 42 > foo; mkdir some-dir; echo '\"hello\"' > some-dir/some-file")

Expand Down
2 changes: 2 additions & 0 deletions pkg/runtimes/testdata/timestamps.bass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(def *memos* *dir*/memos.json)

(def touch
(from (linux/alpine)
($ touch ./foo)
Expand Down
3 changes: 2 additions & 1 deletion project.bass
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
(defn zip [src zipname dir & files]
(-> ($ zip (../ zipname) & $files)
(with-image (deps+go src))
(with-dir dir)
(with-mount dir ./content/)
(with-dir ./content/)
(subpath zipname)))

; runs a quick sanity check
Expand Down