Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(golang): fixed golang data races and make file #4741

Merged
merged 1 commit into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/go-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Build binary
run: make build
run: make build-dev
- name: Get Binary Path
id: getbin
run: |
Expand All @@ -68,7 +68,7 @@ jobs:
E2E_KICS_BINARY: ${{ steps.getbin.outputs.kics }}
E2E_KICS_QUERIES_PATH: ${{ steps.getbin.outputs.queries }}
run: |
go test "github.com/Checkmarx/kics/e2e" -timeout 1500s -json > results.json
go test -tags dev "github.com/Checkmarx/kics/e2e" -timeout 1500s -json > results.json
- name: Generate E2E Report
if: always()
run: |
Expand Down
11 changes: 3 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,11 @@ test: ## Run all tests
test: test-cover test-e2e
$(call print-target)

.PHONY: test
test-dev: ## Run all tests
test-dev: test-cover test-e2e
$(call print-target)

.PHONY: test-race-dev
test-race-dev: ## Run tests with race detector
test-race-dev: generate
$(call print-target)
@go test -tags dev -race $(shell go list ./... | grep -v e2e)
@go test -tags dev -timeout 5000s -race $(shell go list -tags dev ./... | grep -v e2e)

.PHONY: test-race
test-race: ## Run tests with race detector
Expand All @@ -126,7 +121,7 @@ test-unit: generate
test-unit-dev: ## Run unit tests
test-unit-dev: generate
$(call print-target)
@go test -tags dev $(shell go list ./... | grep -v e2e)
@go test -tags dev $(shell go list -tags dev ./... | grep -v e2e)

.PHONY: test-cover
test-cover: ## Run tests with code coverage
Expand All @@ -138,7 +133,7 @@ test-cover: generate
test-cover-dev: ## Run tests with code coverage
test-cover-dev: generate
$(call print-target)
@go test -tags dev -covermode=atomic -v -coverprofile=coverage.out $(shell go list ./... | grep -v e2e)
@go test -tags dev -covermode=atomic -v -coverprofile=coverage.out $(shell go list -tags dev ./... | grep -v e2e)

.PHONY: test-coverage-report
test-coverage-report: ## Run unit tests and generate test coverage report
Expand Down
4 changes: 4 additions & 0 deletions pkg/model/comment_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package model

import (
"strings"
"sync"

"gopkg.in/yaml.v3"
)
Expand All @@ -18,10 +19,13 @@ type Ignore struct {
var (
// NewIgnore is the ignore struct
NewIgnore = &Ignore{}
memoryMu sync.Mutex
)

// build builds the ignore struct
func (i *Ignore) build(lines []int) {
defer memoryMu.Unlock()
memoryMu.Lock()
i.Lines = append(i.Lines, lines...)
}

Expand Down