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

Update common workflow actions #182

Merged
merged 4 commits into from
Nov 13, 2024
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
42 changes: 2 additions & 40 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
name: Workflow
on:
on: # yamllint disable-line rule:truthy
push:
branches: [main]
pull_request:
branches: [main]
jobs:
code-check:
name: Check Go formatting, linting, vetting
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Run the formatter, linter, and vetter
uses: dell/common-github-actions/go-code-formatter-linter-vetter@main
with:
directories: ./...
sanitize:
name: Check for forbidden words
runs-on: ubuntu-latest
Expand All @@ -25,35 +15,7 @@ jobs:
uses: dell/common-github-actions/code-sanitizer@main
with:
args: /github/workspace
test:
name: Run Go unit tests and check package coverage
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Run unit tests and check package coverage
uses: dell/common-github-actions/go-code-tester@main
with:
threshold: 90
go_security_scan:
name: Go security
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Run Go Security
uses: securego/gosec@master
malware_security_scan:
name: Malware Scanner
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Run malware scan
uses: dell/common-github-actions/malware-scanner@main
with:
directories: .
options: -ri

image_security_scan:
name: Image Scanner
runs-on: ubuntu-latest
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/common-workflows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Common Workflows
on: # yamllint disable-line rule:truthy
push:
branches: [main]
pull_request:
branches: ["**"]

jobs:

# golang static analysis checks
go-static-analysis:
uses: dell/common-github-actions/.github/workflows/go-static-analysis.yaml@main
name: Golang Validation

common:
name: Quality Checks
uses: dell/common-github-actions/.github/workflows/go-common.yml@main
2 changes: 1 addition & 1 deletion .github/workflows/go-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Reusable workflow to perform go version update on Golang based projects
name: Go Version Update

on:
on: # yamllint disable-line rule:truthy
workflow_dispatch:
repository_dispatch:
types: [go-update-workflow]
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/linters.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions .golangci.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion internal/k8s/k8sapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func Test_NewForConfigError(t *testing.T) {
defer func() { k8s.NewConfigFn = oldNewConfigFn }()
expected := "could not create Clientset from KubeConfig"
k8s.NewConfigFn = func(_ *rest.Config) (*kubernetes.Clientset, error) {
return nil, fmt.Errorf(expected)
return nil, fmt.Errorf("%s", expected)
}

_, err := k8sapi.GetStorageClasses()
Expand Down
16 changes: 8 additions & 8 deletions internal/service/configuration_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ type ConfigurationReader struct{}
// If no default system is supplied, the first system in the list is returned
func (c *ConfigurationReader) GetStorageSystemConfiguration(file string) ([]ArrayConnectionData, error) {
if _, err := os.Stat(file); os.IsNotExist(err) {
return nil, fmt.Errorf(fmt.Sprintf("File %s does not exist", file))
return nil, fmt.Errorf("%s", fmt.Sprintf("File %s does not exist", file))
}

config, err := os.ReadFile(filepath.Clean(file))
if err != nil {
return nil, fmt.Errorf(fmt.Sprintf("File %s errors: %v", file, err))
return nil, fmt.Errorf("%s", fmt.Sprintf("File %s errors: %v", file, err))
}

if string(config) == "" {
Expand All @@ -58,12 +58,12 @@ func (c *ConfigurationReader) GetStorageSystemConfiguration(file string) ([]Arra
// support backward compatibility
config, err = yaml.JSONToYAML(config)
if err != nil {
return nil, fmt.Errorf(fmt.Sprintf("converting json to yaml: %v", err))
return nil, fmt.Errorf("%s", fmt.Sprintf("converting json to yaml: %v", err))
}

err = yaml.Unmarshal(config, &connectionData)
if err != nil {
return nil, fmt.Errorf(fmt.Sprintf("Unable to parse the credentials: %v", err))
return nil, fmt.Errorf("%s", fmt.Sprintf("Unable to parse the credentials: %v", err))
}

if len(connectionData) == 0 {
Expand All @@ -82,16 +82,16 @@ func (c *ConfigurationReader) GetStorageSystemConfiguration(file string) ([]Arra

func validateStorageSystem(system ArrayConnectionData, i int) error {
if system.SystemID == "" {
return fmt.Errorf(fmt.Sprintf("invalid value for system name at index %d", i))
return fmt.Errorf("%s", fmt.Sprintf("invalid value for system name at index %d", i))
}
if system.Username == "" {
return fmt.Errorf(fmt.Sprintf("invalid value for Username at index %d", i))
return fmt.Errorf("%s", fmt.Sprintf("invalid value for Username at index %d", i))
}
if system.Password == "" {
return fmt.Errorf(fmt.Sprintf("invalid value for Password at index %d", i))
return fmt.Errorf("%s", fmt.Sprintf("invalid value for Password at index %d", i))
}
if system.Endpoint == "" {
return fmt.Errorf(fmt.Sprintf("invalid value for Endpoint at index %d", i))
return fmt.Errorf("%s", fmt.Sprintf("invalid value for Endpoint at index %d", i))
}
return nil
}
4 changes: 2 additions & 2 deletions internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (s *PowerFlexService) pushSDCMetrics(ctx context.Context, sdcMetrics <-chan
if err != nil {
s.Logger.WithError(err).WithField("sdc", mr.sdcMeta.ID).Error("recording statistics for sdc")
} else {
ch <- fmt.Sprintf(mr.sdcMeta.ID)
ch <- fmt.Sprintf("%s", mr.sdcMeta.ID)
}
}(record)
}
Expand Down Expand Up @@ -525,7 +525,7 @@ func (s *PowerFlexService) pushVolumeMetrics(ctx context.Context, volumeMetrics
if err != nil {
s.Logger.WithError(err).WithField("volume_id", metrics.volumeMeta.ID).Error("recording statistics for volume")
} else {
ch <- fmt.Sprintf(metrics.volumeMeta.ID)
ch <- fmt.Sprintf("%s", metrics.volumeMeta.ID)
}
}(metrics)
}
Expand Down