forked from ZupIT/horusec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add the BUILD.md file for horusec-cli (ZupIT#857)
Signed-off-by: Henrique Rodrigues <[email protected]>
- Loading branch information
1 parent
856913f
commit 4e35dbe
Showing
1 changed file
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# **BUILD** | ||
|
||
## **Table of contents** | ||
### 1. [**About**](#about) | ||
### 2. [**Environment**](#environment) | ||
### 3. [**Development**](#development) | ||
>#### 3.1. [**Install and Run**](#install-and-run) | ||
>#### 3.2. [**Style Guide**](#style-guide) | ||
>#### 3.3. [**Tests**](#security) | ||
>##### 3.3.1 [**E2E**](#e2e) | ||
>##### 3.3.2 [**Unitary Tests**](#unitary-tests) | ||
>#### 3.4 [**Security**](#security) | ||
### 4. [**Production**](#production) | ||
|
||
|
||
## **About** | ||
The **BUILD.md** is a file to check the environment and build specifications of **horusec-cli** project. | ||
|
||
|
||
## **Environment** | ||
|
||
- [**Golang**: ^1.17.X](https://go.dev/dl/) | ||
- [**GNU Make**: ^4.2.X](https://www.gnu.org/software/make/) | ||
- [**Git**: ^2.25.X](https://git-scm.com/) | ||
- [**Docker**: ^19.3.X](https://docs.docker.com/get-docker/) | ||
|
||
|
||
## **Development** | ||
|
||
Use a command-line interface (CLI) of your choice to run the following commands to download and install the dependencies. | ||
|
||
### **Install and Run** | ||
|
||
From the root of the project, run the command below to download the dependencies: | ||
|
||
```go | ||
go mod download | ||
``` | ||
|
||
The command below build the Horusec cli for development: | ||
|
||
```bash | ||
make build-dev | ||
``` | ||
After build successful you can execute running: | ||
|
||
```bash | ||
./horusec | ||
``` | ||
Or on Windows: | ||
|
||
```bash | ||
horusec | ||
``` | ||
|
||
### **Style Guide** | ||
|
||
There is a pattern for the source code and the [**golangci-lint**](https://golangci-lint.run) tool is used as an aggregator to the Golang's linter. | ||
You can check lint through the `make` command, see it below: | ||
|
||
```bash | ||
make lint | ||
``` | ||
|
||
The project also has a dependency import stardard, and the command below organizes your code in the stardard definied: | ||
|
||
```bash | ||
make format | ||
``` | ||
|
||
All project files must have the [**license header**](./copyright.txt). To check if all files are in agreement, run the command: | ||
|
||
```bash | ||
make license | ||
``` | ||
|
||
If you need to add the license in any file, the command below inserts it in all files that do not have it: | ||
|
||
```bash | ||
make license-fix | ||
``` | ||
|
||
### **Tests** | ||
|
||
The source code has two test segments, E2E and unitary test. | ||
|
||
#### **E2E** | ||
|
||
The e2e tests were writen with the packages: | ||
|
||
- [**Ginkgo**](https://onsi.github.io/ginkgo/) | ||
- [**Gomega**](https://onsi.github.io/gomega/) | ||
|
||
You can run the tests by the command below: | ||
|
||
```bash | ||
make test-e2e | ||
``` | ||
|
||
#### **Unitary Tests** | ||
|
||
The unit tests were written with the [**Golang standard**](https://pkg.go.dev/testing) package and some mock and assert snippets, we used the [**testify**](https://github.com/stretchr/testify). You can run the tests using the command below: | ||
|
||
```bash | ||
make test | ||
``` | ||
|
||
To check test coverage, run the command below: | ||
|
||
```bash | ||
make coverage | ||
``` | ||
|
||
### **Security** | ||
|
||
[**Horusec**](https://horusec.io/site/) uses the latest version to keep our source code safe. You can verify using the command below: | ||
|
||
```bash | ||
make security | ||
``` | ||
|
||
## **Production** | ||
|
||
Run the commands below in your project's root according to your Operating System to create Horusec's binary: | ||
|
||
- **Windows** | ||
|
||
```bash | ||
make build-install-cli-windows | ||
``` | ||
|
||
- **Linux** | ||
|
||
```bash | ||
make build-install-cli-linux | ||
``` | ||
|
||
- **MacOs** | ||
|
||
```bash | ||
make build-install-cli-darwin | ||
``` |