Skip to content

Commit

Permalink
Add more commands to the Makefile and use them in CI (#24)
Browse files Browse the repository at this point in the history
* Add more commands to the Makefile and use them in CI

Signed-off-by: Philippe Martin <phmartin@redhat.com>

* Make check_registry.sh executable

Signed-off-by: Philippe Martin <phmartin@redhat.com>

* Move scripts to ./scripts directory

Signed-off-by: Philippe Martin <phmartin@redhat.com>

---------

Signed-off-by: Philippe Martin <phmartin@redhat.com>
  • Loading branch information
feloy authored Sep 12, 2023
1 parent 04361c9 commit 2f1e8ab
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ jobs:

- name: Run Gosec Security Scanner
run: |
export PATH=$PATH:$(go env GOPATH)/bin
go install github.com/securego/gosec/v2/cmd/gosec@v2.14.0
./run_gosec.sh
make gosec_install
PATH=$PATH:$(go env GOPATH)/bin make gosec
if [[ $? != 0 ]]
then
echo "gosec scanner failed to run "
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
id: build
run: |
make build
bash test/check_registry/check_registry.sh
make check_registry
28 changes: 22 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
.PHONY: help
help: ## Show this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.PHONY: gomod_tidy
gomod_tidy:
gomod_tidy: ## Update Go mod dependencies
go mod tidy

.PHONY: gofmt
gofmt:
gofmt: ## Run Go formatting checks
go fmt -x ./...

.PHONY: build
build:
build: ## Build executable without extension (Unix)
go build -o alizer

.PHONY: buildWin
buildWin:
buildWin: ## Build executable with Windows .exe extension
go build -o alizer.exe

.PHONY: test
test:
go test -coverprofile cover.out -v ./...
test: ## Run unit tests with coverage
go test -coverprofile cover.out -v ./...

.PHONY: check_registry
check_registry: ## Run registry checks
./test/check_registry/check_registry.sh

.PHONY: gosec_install
gosec_install: ## Install gosec utility
go install github.com/securego/gosec/v2/cmd/gosec@v2.14.0

.PHONY: gosec
gosec: ## Run go security checks
./scripts/run_gosec.sh
2 changes: 1 addition & 1 deletion run_gosec.sh → scripts/run_gosec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

if ! command -v gosec 2> /dev/null
then
echo "error gosec must be installed with this command: go install github.com/securego/gosec/v2/cmd/gosec@v2.14.0" && exit 1
echo "error gosec must be installed with this command: make gosec_install" && exit 1
fi

gosec -no-fail -fmt=sarif -out=gosec.sarif -exclude-dir test -exclude-dir generator ./...
Empty file modified test/check_registry/check_registry.sh
100644 → 100755
Empty file.

0 comments on commit 2f1e8ab

Please sign in to comment.