Skip to content

Commit

Permalink
zbpack refactoring: move tests to GitHub (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuaanlin authored Oct 23, 2024
2 parents 1d9ea28 + 51e730c commit 667b75e
Show file tree
Hide file tree
Showing 304 changed files with 1,166 additions and 10,145 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Real Project Test

on:
push:
tags:
- v*
branches:
- main
workflow_dispatch:

permissions:
contents: read

jobs:
e2e-test:
name: e2e-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run tests
run: go test -v ./tests
env:
GITHUB_PAT: ${{ github.token }}
- name: Check if the snapshot is different
run: |
git diff --exit-code
if [ $? -eq 1 ]; then
echo "The snapshot is different"
exit 1
fi
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
Expand Down
24 changes: 9 additions & 15 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
[submodule "tests/python-pip-fastapi"]
path = tests/python-pip-fastapi
url = https://github.com/zeabur/fastapi-template
[submodule "tests/python-pip-flask"]
path = tests/python-pip-flask
url = https://github.com/zeabur/flask-template
[submodule "tests/python-flask-static-send"]
path = tests/python-flask-static-send
url = https://github.com/rtdtwo/flask-static-tutorial.git
[submodule "tests/python-django-static-whitenoise"]
path = tests/python-django-static-whitenoise
url = https://github.com/testdrivenio/django-static-media-files.git
[submodule "tests/django-hello-world"]
path = tests/python-django-hello-world
url = https://github.com/django-ve/django-helloworld.git
[submodule "tests/elixir-cases/elixir"]
path = tests/elixir-cases/elixir
url = https://github.com/zeabur/elixir-phoenix-template
[submodule "tests/elixir-cases/elixir_ecto"]
path = tests/elixir-cases/elixir_ecto
url = https://github.com/zeabur/elixir-ecto-template
[submodule "tests/dotnet-samples/dotnetapp"]
path = tests/dotnet-samples/dotnetapp
url = https://github.com/zeabur/dotnet-cli-template
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You should see the `build plan` block and the subsequent `build log` block. The
Use `-i` or `--info` to show the build plan only.

```bash
$ ./zbpack --info ./tests/node-corepack
$ ./zbpack --info corepack-project

╔══════════════════════════ Build Plan ═════════════════════════╗
║ provider │ nodejs ║
Expand Down
2 changes: 1 addition & 1 deletion cmd/zbpack/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestCLI(t *testing.T) {
t.Run("only show info when give --info flag", func(t *testing.T) {
path, _ := os.Getwd()
path = filepath.Join(path, "../../")
testFilePath := filepath.Join(path, "/tests/node-corepack")
testFilePath := filepath.Join(path, "/tests/nodejs-a-lot-of-dependencies")
cmd := exec.Command(binName, "--info", testFilePath)
out, err := cmd.CombinedOutput()
if err != nil {
Expand Down
11 changes: 5 additions & 6 deletions internal/bun/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type GetMetaOptions nodejs.GetMetaOptions

// GetMeta gets the metadata of the Node.js project.
func GetMeta(opt GetMetaOptions) types.PlanMeta {
ctx := CreateBunContext(GetMetaOptions(opt))
ctx := CreateBunContext(opt)

meta := types.PlanMeta{}

Expand All @@ -43,6 +43,10 @@ func GetMeta(opt GetMetaOptions) types.PlanMeta {
return meta
}

if framework != types.BunFrameworkNone {
opt.BunFramework = optional.Some(framework)
}

meta = nodejs.GetMeta(nodejs.GetMetaOptions(opt))
return meta
}
Expand Down Expand Up @@ -70,11 +74,6 @@ func DetermineFramework(ctx *PlanContext) types.BunFramework {
return framework
}

if _, isElysia := packageJSON.Dependencies["elysia"]; isElysia {
*fw = optional.Some(types.BunFrameworkElysia)
return fw.Unwrap()
}

if _, isBaojs := packageJSON.Dependencies["baojs"]; isBaojs {
*fw = optional.Some(types.BunFrameworkBaojs)
return fw.Unwrap()
Expand Down
8 changes: 7 additions & 1 deletion internal/nodejs/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,8 @@ type GetMetaOptions struct {
Src afero.Fs
Config plan.ImmutableProjectConfiguration

Bun bool
Bun bool
BunFramework optional.Option[types.BunFramework]
}

// GetMeta gets the metadata of the Node.js project.
Expand All @@ -965,6 +966,11 @@ func GetMeta(opt GetMetaOptions) types.PlanMeta {
Bun: opt.Bun,
}

if bunFramework, err := opt.BunFramework.Take(); err == nil {
// Bun and Node is interchangeable.
ctx.Framework = optional.Some(types.NodeProjectFramework(bunFramework))
}

meta := types.PlanMeta{
"bun": strconv.FormatBool(opt.Bun),
}
Expand Down
42 changes: 0 additions & 42 deletions tests/bun-elysia/.gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions tests/bun-elysia/README.md

This file was deleted.

Binary file removed tests/bun-elysia/bun.lockb
Binary file not shown.
15 changes: 0 additions & 15 deletions tests/bun-elysia/package.json

This file was deleted.

7 changes: 0 additions & 7 deletions tests/bun-elysia/src/index.ts

This file was deleted.

103 changes: 0 additions & 103 deletions tests/bun-elysia/tsconfig.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions tests/dotnet-samples/dotnetapp
Submodule dotnetapp added at cb5dbc
26 changes: 0 additions & 26 deletions tests/dotnet-samples/dotnetapp/Program.cs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/dotnet-samples/dotnetapp/dotnetapp.csproj

This file was deleted.

1 change: 1 addition & 0 deletions tests/elixir-cases/elixir
Submodule elixir added at d170b6
18 changes: 0 additions & 18 deletions tests/elixir-cases/elixir/README.md

This file was deleted.

Loading

0 comments on commit 667b75e

Please sign in to comment.