Merge pull request #12 from aquasecurity/github_actions-1
Introduce GitHub Actions
This commit is contained in:
commit
af3f78af2a
29
.github/workflows/go.yml
vendored
Normal file
29
.github/workflows/go.yml
vendored
Normal 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 ./...
|
||||
|
@ -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)
|
||||
|
@ -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
4
debian/debian.go
vendored
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -152,15 +152,13 @@ func FetchConcurrently(urls []string, concurrency, wait, retry int) (responses [
|
||||
tasks := GenWorkers(concurrency, wait)
|
||||
for range urls {
|
||||
tasks <- func() {
|
||||
select {
|
||||
case url := <-reqChan:
|
||||
res, err := FetchURL(url, "", retry)
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
resChan <- res
|
||||
url := <-reqChan
|
||||
res, err := FetchURL(url, "", retry)
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
resChan <- res
|
||||
}
|
||||
bar.Increment()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user