From 0173fcb876af2ab0f2e6a34d5ce39b4c14b783d2 Mon Sep 17 00:00:00 2001 From: matheusalcantarazup <84723211+matheusalcantarazup@users.noreply.github.com> Date: Mon, 18 Oct 2021 08:35:46 -0300 Subject: [PATCH] docs: improvement on dev setup on contributing (#676) Improvement on `How to contribute` section informing required tools and how to build, test and coverage. This commit also add a new make command to easily build on development. Signed-off-by: Matheus Alcantara --- CONTRIBUTING.md | 32 ++++++++++++++++++++++++++++++-- Makefile | 16 ++++++++++------ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 554913df7..eb6090110 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ This is Horusec contributing guide. Please read the following sections to learn 2. [**Code Review**](#Code-Review) 3. [**Pull Requests**](#Pull-Requests) 3. [**How to contribute?**](#How-to-contribute?) - 1. [**Prepare your development environment**](#Using-Docker) + 1. [**Prepare your development environment**](#Prepare-your-development-environment) 2. [**First contribution**](#First-contribution) 4. [**Add new feature, bugfixing or improvement**](#Add-new-feature-bugfixing-or-improvement) 5. [**Pull Request's approval**](#Pull-Request's-approval) @@ -74,6 +74,34 @@ When opening a PR: See the guidelines to submit your changes: ### **Prepare your development environment** +To start contributing with Horusec you first need to install [Go](https://golang.org/dl/). The minimal version required to build is 1.17. +[GNU Make](https://www.gnu.org/software/make/) is also required to development. + +After installing Go you can build using `make build-dev`. + + +#### Testing +Horusec has a suite of unit and end-to-end tests you can run them using the following commands. + +``` +make test + +make test-e2e +``` + +Make sure all the tests pass before you commit and push :) + +#### Coverage +You can get the test coverage using the following command. + +```bash +make coverage + +go tool cover -html=coverage.out # Open coverage status in your browser +``` + +--- + Horusec has other repositories and you can check the README for each one of them: - [**Admin**](https://github.com/ZupIT/horusec-admin) @@ -127,4 +155,4 @@ Your pull request is approved when: Thank you for your contribution, you rock! 🚀 -**Horusec team** \ No newline at end of file +**Horusec team** diff --git a/Makefile b/Makefile index c8d57dd3c..3766805fb 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ ADDLICENSE ?= addlicense HORUSEC ?= horusec DOCKER_COMPOSE ?= docker-compose PATH_BINARY_BUILD_CLI ?= $(GOPATH)/bin +MAIN = ./cmd/app fmt: $(GOFMT) -w $(GO_FILES) @@ -58,37 +59,40 @@ security: $(HORUSEC) start -p="./" -e="true" endif +build-dev: + $(GO) build -o horusec $(MAIN) + build-install-cli-linux: rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux" &> /dev/null - CGO_ENABLED=0 GOOS=linux $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux" ./cmd/app/main.go + CGO_ENABLED=0 GOOS=linux $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux" $(MAIN) chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux" horusec-linux version build-install-cli-darwin: rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac" &> /dev/null - CGO_ENABLED=0 GOOS=darwin $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac" ./cmd/app/main.go + CGO_ENABLED=0 GOOS=darwin $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac" $(MAIN) chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac" horusec-mac version build-install-cli-windows: rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" &> /dev/null - env GOOS=windows GOARCH=amd64 $(GO) build -o "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" ./cmd/app/main.go + env GOOS=windows GOARCH=amd64 $(GO) build -o "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" $(MAIN) build-install-stand-alone-cli-linux: rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux" &> /dev/null - CGO_ENABLED=0 GOOS=linux $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux" ./cmd/app/main.go + CGO_ENABLED=0 GOOS=linux $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux" $(MAIN) chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux" horusec-linux version build-install-stand-alone-cli-darwin: rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac" &> /dev/null - CGO_ENABLED=0 GOOS=darwin $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac" ./cmd/app/main.go + CGO_ENABLED=0 GOOS=darwin $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac" $(MAIN) chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac" horusec-mac version build-install-stand-alone-cli-windows: rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" &> /dev/null - env GOOS=windows GOARCH=amd64 $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -o "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" ./cmd/app/main.go + env GOOS=windows GOARCH=amd64 $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -o "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" $(MAIN) install: ./deployments/scripts/install.sh latest