Skip to content

Commit

Permalink
Merge pull request #15 from tech-thinker/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mrasif authored Dec 16, 2024
2 parents 1fbf8f6 + e847000 commit 436f2bf
Show file tree
Hide file tree
Showing 26 changed files with 1,374 additions and 251 deletions.
56 changes: 43 additions & 13 deletions .github/workflows/go-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,52 @@ name: Go Tests

on:
push:
branches: [ 'main', 'develop' ]
branches: ["main", "develop"]
pull_request:
branches: [ '*' ]
branches: ["*"]

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.22
- name: Build
run: make build
- name: Test
run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.22
- name: Build
run: make build
- name: Test
run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.22
- name: Build
run: make build
- name: Create project
run: ./gozen create -pkg github.com/tech-thinker/demo-app
- name: Test newly created app
run: |
cd demo-app
make setup
make build
export $(cat .env|xargs)
./demo-app start &
APP_PID=$!
sleep 5
curl -sS "http://127.0.0.1:3000/ping" | jq
if [[ $? -ne 0 ]]; then
echo "curl failed with error code $?"
fi
# Killing process
kill "$APP_PID"
echo "App with PID $APP_PID killed."
- name: Remove newly created app
run: rm -rf demo-app
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ gozen
gozen-*

# Test binary, built with `go test -c`
_test_*
*.test
*.out
coverage.out

# Directory
build/
coverage/
.vscode
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ dist:
GOOS=linux GOARCH=arm go build -ldflags="$(LDFLAGS)" -o build/gozen-linux-arm
cp build/gozen-linux-arm build/gozen
tar -zcvf build/gozen-linux-arm.tar.gz build/gozen man/gozen.1

GOOS=darwin GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o build/gozen-darwin-amd64
cp build/gozen-darwin-amd64 build/gozen
tar -zcvf build/gozen-darwin-amd64.tar.gz build/gozen man/gozen.1

GOOS=darwin GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o build/gozen-darwin-arm64
cp build/gozen-darwin-arm64 build/gozen
tar -zcvf build/gozen-darwin-arm64.tar.gz build/gozen man/gozen.1
rm build/gozen

GOOS=windows GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o build/gozen-windows-amd64.exe
GOOS=windows GOARCH=386 go build -ldflags="$(LDFLAGS)" -o build/gozen-windows-i386.exe

# Generating checksum
cd build && sha256sum * >> checksum-sha256sum.txt
cd build && md5sum * >> checksum-md5sum.txt
Expand All @@ -71,3 +71,9 @@ dist:
clean:
rm -rf gozen*
rm -rf build

generate-mocks:
# Mockery version v2.50.0
@mockery --name=ShellWrapper --dir=wrappers --output=wrappers --outpkg=wrappers --filename=shell_wrapper_mock.go --structname=ShellWrapperMock
@mockery --name=FileSystemWrapper --dir=wrappers --output=wrappers --outpkg=wrappers --filename=file_system_wrapper_mock.go --structname=FileSystemWrapperMock
# @mockery --name=FileSystemWrapper --dir=cmd/wrappers --output=cmd/wrappers --outpkg=wrappers --filename=file_system_repo_mock.go --structname=FileSystemWrapperMock
76 changes: 76 additions & 0 deletions cmd/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package cmd

import (
"fmt"

"github.com/tech-thinker/gozen/cmd/service"
"github.com/tech-thinker/gozen/models"
"github.com/urfave/cli/v2"
)

type App interface {
CreateProject() *cli.Command
}

type app struct {
appService service.AppService
}

func (c *app) CreateProject() *cli.Command {

var packageName, outputDir, driver string

return &cli.Command{
Name: "create",
Usage: "Create new Projects.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "pkg",
Aliases: []string{"p"},
Value: "",
Usage: "Package name for new project.",
Destination: &packageName,
},
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Value: ".",
Usage: "Output directory for new project.",
Destination: &outputDir,
},
&cli.StringFlag{
Name: "driver",
Aliases: []string{"d"},
Value: "sqlite",
Usage: "Database driver for new project. eg. [sqlite, mysql, postgres]",
Destination: &driver,
},
},
Action: func(ctx *cli.Context) error {
project := models.Project{
AppName: ctx.Args().Get(0),
PackageName: packageName,
Driver: driver,
WorkingDir: outputDir,
}

err := project.Validate()
if err != nil {
fmt.Println(err)
return nil
}

project.AutoFixes()

return c.appService.CreateApp(project)
},
}
}

func NewApp(
appService service.AppService,
) App {
return &app{
appService: appService,
}
}
89 changes: 0 additions & 89 deletions cmd/create_app.go

This file was deleted.

67 changes: 0 additions & 67 deletions cmd/helper/common.go

This file was deleted.

Loading

0 comments on commit 436f2bf

Please sign in to comment.