diff --git a/CONTRIBUTORS_GUIDE.md b/CONTRIBUTORS_GUIDE.md new file mode 100644 index 0000000..e604bd0 --- /dev/null +++ b/CONTRIBUTORS_GUIDE.md @@ -0,0 +1,53 @@ +# Contributors Guide + +This guide aims to guide newcomers to getting started with the project standards. + + +## Code Style + +For this project we use basically the default configuration for most used IDEs. +For the configurations below, make sure to properly configure your IDE: + +- **imports**: goimports + +This should be enough to get you started. + +If you are unsure that your IDE is not correctly configured, you can run the lint checks: + +```bash +make lint +``` + +If something goes wrong, the error will be printed, e.g.: +```bash +$ make lint +make addheaders +make fmt +./hack/go-lint.sh +util/floatstr/floatstr_test.go:19: File is not `goimports`-ed (goimports) + "k8s.io/apimachinery/pkg/util/yaml" +make: *** [lint] Error 1 +``` + +Lint issues can be fixed with the `--fix` flag, this command can be used: +```bash +make lint params=--fix +``` + + +### EditorConfig +For IntelliJ you can find an example `editorconfig` file [here](contrib/intellij.editorconfig). To use it please visit +the Jetbrains [documentation](https://www.jetbrains.com/help/idea/editorconfig.html). + + +## Known Issues + +On MacOSX/darwin you might get this issue: +``` + goimports: can't extract issues from gofmt diff output +``` +To solve install the `diffutils` package: + +```bash + brew install diffutils +``` \ No newline at end of file diff --git a/Makefile b/Makefile index 5a7c8a4..f713372 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ lint: @command -v golangci-lint > /dev/null || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GOPATH}/bin" make addheaders make fmt - ./hack/go-lint.sh + ./hack/go-lint.sh ${params} .PHONY: test coverage="false" diff --git a/README.md b/README.md index 786225f..bf998fd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,21 @@ # Go SDK for Serverless Workflow - Here you will find all the [specification types](https://github.com/serverlessworkflow/specification/blob/main/schema/workflow.json) defined by our Json Schemas, in Go. +Table of Contents +================= + +- [Status](#status) +- [Releases](#releases) +- [How to Use](#how-to-use) + - [Parsing Serverless Workflow files](#parsing-serverless-workflow-files) +- [Slack Channel](#slack-channel) +- [Contributors Guide](#contributors-guide) + - [Code Style](#code-style) + - [EditorConfig](#editorconfig) + - [Known Issues](#known-issues) + + +## Status Current status of features implemented in the SDK is listed in the table below: | Feature | Status | @@ -12,8 +26,8 @@ Current status of features implemented in the SDK is listed in the table below: | Validate workflow definitions (Integrity) | :heavy_check_mark: | | Generate workflow diagram (SVG) | :no_entry_sign: | -## Status +## Releases | Latest Releases | Conformance to spec version | |:--------------------------------------------------------------------------:| :---: | | [v1.0.0](https://github.com/serverlessworkflow/sdk-go/releases/tag/v1.0.0) | [v0.5](https://github.com/serverlessworkflow/specification/tree/0.5.x) | @@ -66,3 +80,58 @@ The `Workflow` structure then can be used in your application. ## Slack Channel Join us at [CNCF Slack](https://communityinviter.com/apps/cloud-native/cncf), channel `#serverless-workflow-sdk` and say hello 🙋. + +## Contributors Guide + +This guide aims to guide newcomers to getting started with the project standards. + + +### Code Style + +For this project we use basically the default configuration for most used IDEs. +For the configurations below, make sure to properly configure your IDE: + +- **imports**: goimports + +This should be enough to get you started. + +If you are unsure that your IDE is not correctly configured, you can run the lint checks: + +```bash +make lint +``` + +If something goes wrong, the error will be printed, e.g.: +```bash +$ make lint +make addheaders +make fmt +./hack/go-lint.sh +util/floatstr/floatstr_test.go:19: File is not `goimports`-ed (goimports) + "k8s.io/apimachinery/pkg/util/yaml" +make: *** [lint] Error 1 +``` + +Lint issues can be fixed with the `--fix` flag, this command can be used: +```bash +make lint params=--fix +``` + + +### EditorConfig +For IntelliJ you can find an example `editorconfig` file [here](contrib/intellij.editorconfig). To use it please visit +the Jetbrains [documentation](https://www.jetbrains.com/help/idea/editorconfig.html). + + +### Known Issues + +On MacOSX/darwin you might get this issue: +``` + goimports: can't extract issues from gofmt diff output +``` +To solve install the `diffutils` package: + +```bash + brew install diffutils +``` + diff --git a/contrib/intellij.editorconfig b/contrib/intellij.editorconfig new file mode 100644 index 0000000..5b5a1ca --- /dev/null +++ b/contrib/intellij.editorconfig @@ -0,0 +1,30 @@ +root = true + +[{*.go,*.go2}] +indent_style = tab +ij_continuation_indent_size = 4 +ij_go_GROUP_CURRENT_PROJECT_IMPORTS = true +ij_go_add_leading_space_to_comments = true +ij_go_add_parentheses_for_single_import = false +ij_go_call_parameters_new_line_after_left_paren = true +ij_go_call_parameters_right_paren_on_new_line = true +ij_go_call_parameters_wrap = off +ij_go_fill_paragraph_width = 80 +ij_go_group_stdlib_imports = true +ij_go_import_sorting = goimports +ij_go_keep_indents_on_empty_lines = false +ij_go_local_group_mode = project +ij_go_move_all_imports_in_one_declaration = true +ij_go_move_all_stdlib_imports_in_one_group = false +ij_go_remove_redundant_import_aliases = true +ij_go_run_go_fmt_on_reformat = true +ij_go_use_back_quotes_for_imports = false +ij_go_wrap_comp_lit = off +ij_go_wrap_comp_lit_newline_after_lbrace = true +ij_go_wrap_comp_lit_newline_before_rbrace = true +ij_go_wrap_func_params = off +ij_go_wrap_func_params_newline_after_lparen = true +ij_go_wrap_func_params_newline_before_rparen = true +ij_go_wrap_func_result = off +ij_go_wrap_func_result_newline_after_lparen = true +ij_go_wrap_func_result_newline_before_rparen = true \ No newline at end of file diff --git a/hack/go-lint.sh b/hack/go-lint.sh index a9c0251..7b034aa 100755 --- a/hack/go-lint.sh +++ b/hack/go-lint.sh @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -golangci-lint run ./... --timeout 2m0s +golangci-lint run -E goimports -E errorlint -E gosec "${1}" ./... --timeout 2m0s diff --git a/maintainer_guidelines.md b/maintainer_guidelines.md index ecd1b11..d40d33b 100644 --- a/maintainer_guidelines.md +++ b/maintainer_guidelines.md @@ -16,7 +16,7 @@ Here are a few tips for repository maintainers. ## Branch Management -The `main` branch is is the bleeding edge. New major versions of the module +The `main` branch is the bleeding edge. New major versions of the module are cut from this branch and tagged. If you intend to submit a pull request you should use `main HEAD` as your starting point. diff --git a/model/object.go b/model/object.go index cdb87ac..17895d3 100644 --- a/model/object.go +++ b/model/object.go @@ -116,7 +116,7 @@ func (obj *Object) UnmarshalJSON(data []byte) error { default: // json parses all not typed numbers as float64, let's enforce to int32 if valInt, parseErr := strconv.Atoi(fmt.Sprint(val)); parseErr != nil { - return fmt.Errorf("falied to parse %d to int32: %s", valInt, parseErr.Error()) + return fmt.Errorf("falied to parse %d to int32: %w", valInt, parseErr) } else { var intVal Integer if err := json.Unmarshal(data, &intVal); err != nil { diff --git a/model/util.go b/model/util.go index 849eb5c..d90f966 100644 --- a/model/util.go +++ b/model/util.go @@ -21,6 +21,7 @@ import ( "net/http" "os" "path/filepath" + "sigs.k8s.io/yaml" "strings" diff --git a/util/floatstr/floatstr_test.go b/util/floatstr/floatstr_test.go index c01f2b2..ee25fbe 100644 --- a/util/floatstr/floatstr_test.go +++ b/util/floatstr/floatstr_test.go @@ -16,9 +16,10 @@ package floatstr import ( "encoding/json" - "k8s.io/apimachinery/pkg/util/yaml" "reflect" "testing" + + "k8s.io/apimachinery/pkg/util/yaml" ) func TestFromFloat(t *testing.T) {