Merge pull request #12 from aquasecurity/github_actions-1

Introduce GitHub Actions
This commit is contained in:
Simarpreet Singh 2019-10-12 17:44:29 -07:00 committed by GitHub
commit af3f78af2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 13 deletions

29
.github/workflows/go.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Go
on: [push, pull_request]
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Install GolangCI-Lint
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s $version
env:
version: v1.19.1
- name: Lint
run: ./bin/golangci-lint run
- name: Test
run: |
go test -v ./...

View File

@ -53,7 +53,11 @@ func (c Config) Update() (err error) {
}
// restore branch
defer c.GitClient.Checkout(repoDir, "master")
defer func() {
if derr := c.GitClient.Checkout(repoDir, "master"); derr != nil {
log.Printf("checkout error: %s", derr)
}
}()
for _, branch := range branches {
branch = strings.TrimSpace(branch)

View File

@ -24,17 +24,17 @@ type MockGitConfig struct {
mock.Mock
}
func (mgc MockGitConfig) CloneOrPull(a string, b string) (map[string]struct{}, error) {
func (mgc *MockGitConfig) CloneOrPull(a string, b string) (map[string]struct{}, error) {
args := mgc.Called(a, b)
return args.Get(0).(map[string]struct{}), args.Error(1)
}
func (mgc MockGitConfig) RemoteBranch(a string) ([]string, error) {
func (mgc *MockGitConfig) RemoteBranch(a string) ([]string, error) {
args := mgc.Called(a)
return args.Get(0).([]string), args.Error(1)
}
func (mgc MockGitConfig) Checkout(a string, b string) error {
func (mgc *MockGitConfig) Checkout(a string, b string) error {
args := mgc.Called(a, b)
return args.Error(0)
}

4
debian/debian.go vendored
View File

@ -31,7 +31,9 @@ func Update() error {
for pkgName, cves := range vulns {
for cveID, cve := range cves {
dir := filepath.Join(utils.VulnListDir(), debianDir, pkgName)
os.MkdirAll(dir, os.ModePerm)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
return xerrors.Errorf("failed to create the directory: %w", err)
}
filePath := filepath.Join(dir, fmt.Sprintf("%s.json", cveID))
if err = utils.Write(filePath, cve); err != nil {
return xerrors.Errorf("failed to write Debian CVE details: %w", err)

View File

@ -70,6 +70,9 @@ func Update() error {
func walkDir(root string) error {
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return xerrors.Errorf("file walk error: %w", err)
}
if info.IsDir() {
return nil
}

View File

@ -152,8 +152,7 @@ func FetchConcurrently(urls []string, concurrency, wait, retry int) (responses [
tasks := GenWorkers(concurrency, wait)
for range urls {
tasks <- func() {
select {
case url := <-reqChan:
url := <-reqChan
res, err := FetchURL(url, "", retry)
if err != nil {
errChan <- err
@ -161,7 +160,6 @@ func FetchConcurrently(urls []string, concurrency, wait, retry int) (responses [
}
resChan <- res
}
}
bar.Increment()
}
bar.Finish()