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

fix: Re-arrange classes & structs. Make the overall project structure capable of accommodating other runtimes too #22

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ go.work
/tmp/
*.orig
*_gen.go
/mocks/
/mocks/
vendor
31 changes: 31 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
run:
skip-files:
- ".*_test.go"
- "mock_.*.go"
timeout: "100s"

linters:
enable:
- goimports
- revive
- errcheck
- ineffassign
- typecheck
- unconvert
- exportloopref
- dupl
- misspell
- govet
- staticcheck
- unused
- gosimple
disable-all: true

linters-settings:
goimports:
local-prefixes: github.com/wasify-go
revive:
enableAllRules: true
rules:
- name: receiver-naming
disabled: true
79 changes: 79 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

source "$(dirname "${0}")/resources/tools/commons.lib"

readonly PROJECT_PATH="$(realpath "$(dirname "${0}")")"
readonly PROJECT_NAME="$(basename "${PROJECT_PATH}")"

function help() {
cat <<END
Buildery for ${PROJECT_NAME} v1.0

Syntax: build [--help|run-all|test|lint|build|update|generate|integration-test]

Supported Flags:

◦ [no-]help Print help and exit (default: off)
◦ [no-]run-all Run all stages at once (default: on)
◦ [no-]update Enable/disable the 'update' stage (default: off)
◦ [no-]generate Enable/disable the 'generate' stage (default: off)
◦ [no-]build Enable/disable the 'build' stage (default: off)
◦ [no-]lint Enable/disable the 'lint' stage (default: off)
◦ [no-]test Enable/disable the 'test' stage (default: off)
◦ [no-]integration-test Enable/disable the 'integration-test' stage (default: off)

In addition flags can be given values:

◦ for raising a flag - [y|yes|t|true|on]
◦ for lowering a flag - [n|no|f|false|off]

Example:

◦ generate code - build --no-run-all --generate
◦ run all integration & unit tests - build --no-run-all --test --integration-test

END
}

function run_buildery() {
local help="$(_read_cmd_flag "help" "false" "${@}")"
local run_all="$(_read_cmd_flag "run-all" "true" "${@}")"
local run_tests="$(_read_cmd_flag "test" "${run_all}" "${@}")"
local lint_project="$(_read_cmd_flag "lint" "${run_all}" "${@}")"
local build_project="$(_read_cmd_flag "build" "${run_all}" "${@}")"
local update_dependencies="$(_read_cmd_flag "update" "${run_all}" "${@}")"
local generate_resources="$(_read_cmd_flag "generate" "${run_all}" "${@}")"
local run_integration_tests="$(_read_cmd_flag "integration-test" "${run_all}" "${@}")"

if _is_truthy "${help}"; then
help "${@}"
exit 0
fi

_info "-------------------------------------------------------------------------------"
_info "Welcome to ${PROJECT_NAME} Buildery v1.0"
_info "-------------------------------------------------------------------------------"
_info "Using the following settings:"
_info " --run-all ${run_all}"
_info " --test ${run_tests}"
_info " --lint ${lint_project}"
_info " --build ${build_project}"
_info " --update ${update_dependencies}"
_info "-------------------------------------------------------------------------------"

_assert_success "${PROJECT_PATH}" ./resources/tools/updeps "${@}"
_assert_success "${PROJECT_PATH}" ./resources/tools/build "${@}"
_assert_success "${PROJECT_PATH}" ./resources/tools/lint "${@}"
_assert_success "${PROJECT_PATH}" ./resources/tools/test "${@}"
}

function main() {
if _is_truthy "$(_read_cmd_flag "help" "false" "${@}")"; then
help "${@}"
exit 0
fi

run_buildery "${@}"
}

main "${@}"
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module github.com/wasify-io/wasify-go

go 1.21
go 1.22

require (
github.com/stretchr/testify v1.8.4
github.com/tetratelabs/wazero v1.5.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
github.com/tetratelabs/wazero v1.6.0
)

require (
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/tetratelabs/wazero v1.5.0 h1:Yz3fZHivfDiZFUXnWMPUoiW7s8tC1sjdBtlJn08qYa0=
github.com/tetratelabs/wazero v1.5.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tetratelabs/wazero v1.6.0 h1:z0H1iikCdP8t+q341xqepY4EWvHEw8Es7tlqiVzlP3g=
github.com/tetratelabs/wazero v1.6.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
56 changes: 0 additions & 56 deletions guest_function.go

This file was deleted.

61 changes: 0 additions & 61 deletions guest_function_test.go

This file was deleted.

112 changes: 0 additions & 112 deletions guest_function_wazero.go

This file was deleted.

Loading