Skip to content

Commit

Permalink
docs: improvement on dev setup on contributing (#676)
Browse files Browse the repository at this point in the history
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 <matheus.alcantara@zup.com.br>
  • Loading branch information
matheusalcantarazup authored Oct 18, 2021
1 parent 778869a commit 0173fcb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
32 changes: 30 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -127,4 +155,4 @@ Your pull request is approved when:

Thank you for your contribution, you rock! 🚀

**Horusec team**
**Horusec team**
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0173fcb

Please sign in to comment.