Skip to content

Commit

Permalink
Refactor and test the compiler (livebud#93)
Browse files Browse the repository at this point in the history
* add initial compiler test
* test CI against a linked V8
* wip compiler refactor
* starting to consolidate
* more consolidation
* working on new test runner
* finalize testing apis
* migrating tests
* improve testcli http response handling and started refactoring controller tests
* refactor controller, view and public tests
* revert error formatting, will do it top-level instead. refactor remaining tests
* extract out file descriptor passing. work on remaining tests
* fix remaining failed tests
* update test script to install bud binary into $PATH
* use go to install bud
* fix public test for CI
* fix public tests
* add hot client for testing the hot server. trying to reproduce view error locally
* add custom flag parsing support
* add dockerfile for development and fix failing ubuntu tests
* update timeout
* remove unused go modules
* delete unused files
* replace matryer/is with internal/is.
* fix formatting
* fix hot reload and scaffolding new root controllers
* debug panic
* fix test
* add error check and test for panic seen in CI
* try supporting Go 1.16+
  • Loading branch information
matthewmueller authored May 29, 2022
1 parent b0992b8 commit 2dfa05a
Show file tree
Hide file tree
Showing 173 changed files with 5,279 additions and 3,471 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ jobs:
livebud/package-lock.json
package-lock.json
# Temporary fix to get the tests working until we pass the V8 client as a
# os.Pipe
- name: Install bud binary into $PATH
run: go install github.com/livebud/bud@latest

- name: Install bud node_modules
run: npm ci

Expand Down
4 changes: 1 addition & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ Check out the Hacker News [demo](https://www.youtube.com/watch?v=LoypcRqn-xA), r

Recent discussions: [Reddit](https://www.reddit.com/r/golang/comments/uoxocj/bud_the_fullstack_web_framework_for_go_developers/), [Hacker News](https://news.ycombinator.com/item?id=31371340), [Twitter](https://twitter.com/golivebud)


# How did Bud come into existence?

I started working on Bud 2 years ago after seeing how productive people could be in [Laravel](https://laravel.com/). I wanted the same for Go, so I decided to try creating Laravel for the Go ecosystem. However, my first version after 6 months needed to scaffold many files just to get started. If you are coming from [Rails](https://github.com/rails/rails) or Laravel, you may shrug and consider this as pretty normal.
Expand All @@ -117,7 +116,6 @@ The goals are now:

- Bud should compile to a single binary that contains your entire web app and can be copied to a server that doesn't even have Go installed.


# Contributing

Please refer to the [Contributing Guide](./Contributing.md) to learn how to run and test Bud locally.
Please refer to the [Contributing Guide](./contributing/Readme.md) to learn how to develop Bud locally.
27 changes: 27 additions & 0 deletions contributing/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ubuntu:18.04

ARG NODE_VERSION=8.10.0
ARG GO_VERSION=1.18.1
ARG BUD_VERSION=main

# Install basic dependencies
RUN apt-get -qq update
RUN apt-get -qq -y install curl git make gcc g++

# Install Node.js
RUN curl https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz | tar -xz -C /usr/local --strip-components 1
RUN node -v

# Install Go
RUN curl -L https://golang.org/dl/go$GO_VERSION.linux-amd64.tar.gz | tar -xz -C /usr/local --strip-components 1
RUN go version
ENV PATH "/root/go/bin:${PATH}"

# Install bud
RUN git clone https://github.com/livebud/bud /bud
WORKDIR /bud
RUN git checkout $BUD_VERSION
RUN make install
RUN go install .
RUN bud version

12 changes: 12 additions & 0 deletions Contributing.md → contributing/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Currently, Bud must be developed using WSL/WSL2 if developing on Windows. While

- Node 14
- Go 1.18
- C++ compiler in your $PATH (for cgo to compile V8)

## Setting up Bud for Development

Expand Down Expand Up @@ -41,6 +42,17 @@ After running `go run main.go`, you should see the following:

If you run into any problems, please [open an issue](https://github.com/livebud/bud/issues/new).

### Developing with Docker

We've included a [Dockerfile](./Dockerfile) that you can use to run bud within a Docker container. This can be helpful for testing Bud within a Linux environment and debugging CI issues.

To build and start a Docker container with Bud, run the following commands:

```sh
docker build -t bud:latest contributing
docker run -it --rm -v $(PWD):/bud bud /bin/bash
```

## Developing Bud with a Project

Now that you have Bud running locally, you can use the `-C, --chdir` functionality to test Bud against different projects.
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ require (
github.com/fatih/structtag v1.2.0
github.com/fsnotify/fsnotify v1.5.1
github.com/gitchander/permutation v0.0.0-20201214100618-1f3e7285f953
github.com/lithammer/dedent v1.1.0
github.com/matryer/is v1.4.0
github.com/matthewmueller/diff v0.0.0-20220104030700-cb2fe910d90c
github.com/matthewmueller/gotext v0.0.0-20210424201144-265ed61725ac
github.com/matthewmueller/text v0.0.0-20210424201111-ec1e4af8dfe8
Expand All @@ -36,6 +34,7 @@ require (
github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lithammer/dedent v1.1.0 // indirect
github.com/pointlander/compress v1.1.1-0.20190518213731-ff44bd196cc3 // indirect
github.com/pointlander/jetset v1.0.1-0.20190518214125-eee7eff80bd4 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lithammer/dedent v1.1.0 h1:VNzHMVCBNG1j0fh3OrsFRkVUwStdDArbgBWoPAffktY=
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
github.com/matthewmueller/diff v0.0.0-20220104030700-cb2fe910d90c h1:yjGBNrCIE7IghJAwrFcyDzwzwJKf0oRPeOHx60wfkmA=
github.com/matthewmueller/diff v0.0.0-20220104030700-cb2fe910d90c/go.mod h1:xIxeV0n2W+WNB3ik/j9lUkcrQAk71VrvT9ch8u4pcvM=
github.com/matthewmueller/gotext v0.0.0-20210424201144-265ed61725ac h1:SjopLdUF96kdJU8ynYmGVHoJmngpwFHRvR5p2plBXG4=
Expand Down
2 changes: 1 addition & 1 deletion internal/bail/bail.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (s *Struct) Recover2(err *error, prefix string) {
if _, ok := e.(bail); !ok {
panic(e)
}
*err = fmt.Errorf(prefix+" > %w", s.err)
*err = fmt.Errorf(prefix+" . %w", s.err)
}
}

Expand Down
144 changes: 0 additions & 144 deletions internal/bud/bud.go

This file was deleted.

10 changes: 0 additions & 10 deletions internal/bud/env.go

This file was deleted.

82 changes: 0 additions & 82 deletions internal/bud/project.go

This file was deleted.

Loading

0 comments on commit 2dfa05a

Please sign in to comment.