Skip to content

Commit

Permalink
Merge pull request #324 from metrumresearchgroup/ci-lint-update
Browse files Browse the repository at this point in the history
ci: update lint workflow
  • Loading branch information
kyleam authored Aug 14, 2024
2 parents 5e1f919 + f044cb9 commit 94c9262
Show file tree
Hide file tree
Showing 23 changed files with 78 additions and 89 deletions.
21 changes: 4 additions & 17 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,15 @@ on:
- 'scratch/**'
pull_request:

# Note: this avoids golangci/golangci-lint-action to work around an
# error triggered by us pinning to a golangci-lint version built with
# an older Go. Revisit when moving from golangci-lint v1.47.2.
#
# https://github.com/golangci/golangci-lint-action/issues/442#issuecomment-1203786890
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install golangci-lint
shell: bash
run: |
bin=$(mktemp -d)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
sh -s -- -b "$bin" v1.47.2
echo "$bin" >>$GITHUB_PATH
go-version: stable
- name: Run golangci-lint
shell: bash
run: |
command -v golangci-lint
golangci-lint run --out-format=github-actions
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
10 changes: 3 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ issues:
- gocyclo
- dupl
- gosec
exclude-dirs:
- (^|/)mock($|/)

linters-settings:
errcheck:
check-type-assertions: true
govet:
check-shadowing: true
shadow: true
unparam:
check-exported: true
unused:
Expand All @@ -31,22 +33,17 @@ linters-settings:

run:
skip-dirs-use-default: true
skip-dirs:
- (^|/)mock($|/)
timeout: 3m

linters:
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
# - gosec
- unparam
- unconvert
Expand All @@ -58,5 +55,4 @@ linters:
- whitespace
- rowserrcheck
- godot
- ifshort
- nakedret
1 change: 1 addition & 0 deletions cmd/bbi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
var buildTime string

// if want to generate docs
//
// import "github.com/spf13/cobra/doc"
// err := doc.GenMarkdownTree(cmd.RootCmd, "../../docs/bbi")
// if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions cmd/sge.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type sgeOperation struct {
Models []SGEModel `json:"models"`
}

//SGEModel is the struct used for SGE operations containing the NonMemModel.
// SGEModel is the struct used for SGE operations containing the NonMemModel.
type SGEModel struct {
Nonmem *NonMemModel
Cancel chan bool
Expand Down Expand Up @@ -66,12 +66,12 @@ func (s *SGEModel) GetWorkingPath() string {
return s.Nonmem.OutputDir
}

//Begin Scalable method definitions.
// Begin Scalable method definitions.
func (l SGEModel) CancellationChannel() chan bool {
return l.Cancel
}

//Prepare is basically the old EstimateModel function. Responsible for creating directories and preparation.
// Prepare is basically the old EstimateModel function. Responsible for creating directories and preparation.
func (l SGEModel) Prepare(channels *turnstile.ChannelMap) {
log.Debugf("%s Beginning Prepare phase of SGE Work", l.Nonmem.LogIdentifier())

Expand Down Expand Up @@ -122,7 +122,7 @@ func (l SGEModel) Prepare(channels *turnstile.ChannelMap) {
}
}

//Work describes the Turnstile execution phase -> IE What heavy lifting should be done.
// Work describes the Turnstile execution phase -> IE What heavy lifting should be done.
func (l SGEModel) Work(channels *turnstile.ChannelMap) {
cerr := executeNonMemJob(executeSGEJob, l.Nonmem)

Expand All @@ -139,12 +139,12 @@ func (l SGEModel) Work(channels *turnstile.ChannelMap) {
channels.Completed <- 1
}

//Monitor is the 3rd phase of turnstile (not implemented here).
// Monitor is the 3rd phase of turnstile (not implemented here).
func (l SGEModel) Monitor(_ *turnstile.ChannelMap) {
//Do nothing for this implementation
}

//Cleanup is the last phase of execution, in which computation / hard work is done and we're cleaning up leftover files, copying results around et all.
// Cleanup is the last phase of execution, in which computation / hard work is done and we're cleaning up leftover files, copying results around et all.
func (l SGEModel) Cleanup(_ *turnstile.ChannelMap) {
//err := configlib.WriteViperConfig(l.Nonmem.OutputDir, true)
//
Expand Down Expand Up @@ -352,7 +352,7 @@ func sgeModelsFromArguments(args []string, config configlib.Config) ([]SGEModel,
return output, nil
}

//Generate the command line script to execute bbi on the grid.
// Generate the command line script to execute bbi on the grid.
func generateBbiScript(fileTemplate string, l NonMemModel) ([]byte, error) {
t, err := template.New("file").Parse(fileTemplate)
buf := new(bytes.Buffer)
Expand Down
8 changes: 4 additions & 4 deletions integration/nonmem/bbi_expansion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

. "github.com/metrumresearchgroup/bbi/integration"
bi "github.com/metrumresearchgroup/bbi/integration"
"github.com/metrumresearchgroup/bbi/utils"

"github.com/metrumresearchgroup/wrapt"
Expand Down Expand Up @@ -39,7 +39,7 @@ func TestBBIExpandsWithoutPrefix(tt *testing.T) {
filepath.Join(scenario.Workpath, "model", targets),
}

output, err := ExecuteCommand(context.Background(), "bbi", commandAndArgs...)
output, err := bi.ExecuteCommand(context.Background(), "bbi", commandAndArgs...)

t.R.NoError(err)
t.R.NotEmpty(output)
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestBBIExpandsWithPrefix(tt *testing.T) {
filepath.Join(scenario.Workpath, "model", targets),
}

output, err := ExecuteCommand(context.Background(), "bbi", commandAndArgs...)
output, err := bi.ExecuteCommand(context.Background(), "bbi", commandAndArgs...)

t.R.NoError(err)
t.R.NotEmpty(output)
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestBBIExpandsWithPrefixToPartialMatch(tt *testing.T) {
filepath.Join(scenario.Workpath, "model", targets),
}

output, err := ExecuteCommand(context.Background(), "bbi", commandAndArgs...)
output, err := bi.ExecuteCommand(context.Background(), "bbi", commandAndArgs...)

t.R.NoError(err)
t.R.NotEmpty(output)
Expand Down
4 changes: 2 additions & 2 deletions integration/nonmem/bbi_local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"time"

. "github.com/metrumresearchgroup/bbi/integration"
bi "github.com/metrumresearchgroup/bbi/integration"
"github.com/metrumresearchgroup/bbi/utils"

"github.com/metrumresearchgroup/wrapt"
Expand Down Expand Up @@ -136,7 +136,7 @@ func TestNMFEOptionsEndInScript(tt *testing.T) {

// Now let's run the script that was generated
t.R.NoError(os.Chdir(filepath.Join(scenario.Workpath, m.identifier)))
_, err = ExecuteCommand(ctx, filepath.Join(scenario.Workpath, m.identifier, m.identifier+".sh"))
_, err = bi.ExecuteCommand(ctx, filepath.Join(scenario.Workpath, m.identifier, m.identifier+".sh"))
t.R.NoError(os.Chdir(whereami))
t.R.NoError(err)

Expand Down
4 changes: 2 additions & 2 deletions integration/nonmem/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"runtime"
"testing"

. "github.com/metrumresearchgroup/bbi/integration"
bi "github.com/metrumresearchgroup/bbi/integration"
"github.com/metrumresearchgroup/bbi/utils"

"github.com/metrumresearchgroup/wrapt"
Expand All @@ -35,7 +35,7 @@ func TestInitialization(tt *testing.T) {
scenario.Prepare(t, context.Background())

t.Run(fmt.Sprintf("init_%s", scenario.identifier), func(t *wrapt.T) {
_, err := ExecuteCommand(context.Background(), "bbi", "init", "--dir", os.Getenv("NONMEMROOT"))
_, err := bi.ExecuteCommand(context.Background(), "bbi", "init", "--dir", os.Getenv("NONMEMROOT"))
t.R.NoError(err)

t.A.FileExists(filepath.Join(scenario.Workpath, "bbi.yaml"))
Expand Down
8 changes: 4 additions & 4 deletions integration/nonmem/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strconv"
"strings"

. "github.com/metrumresearchgroup/bbi/integration"
bi "github.com/metrumresearchgroup/bbi/integration"

"github.com/metrumresearchgroup/wrapt"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -61,7 +61,7 @@ func (m Model) Execute(scenario *Scenario, args ...string) (string, error) {
filepath.Join(scenario.Workpath, m.filename),
}...)

return ExecuteCommand(scenario.ctx, "bbi", cmdArguments...)
return bi.ExecuteCommand(scenario.ctx, "bbi", cmdArguments...)
}

var ErrNoModelsLocated = errors.New("no model directories were located in the provided scenario")
Expand Down Expand Up @@ -431,7 +431,7 @@ func findModelFiles(path string) []string {
func (scenario *Scenario) Prepare(t *wrapt.T, ctx context.Context) {
t.Helper()

_, err := ExecuteCommand(ctx, "bbi", "init", "--dir", os.Getenv("NONMEMROOT"))
_, err := bi.ExecuteCommand(ctx, "bbi", "init", "--dir", os.Getenv("NONMEMROOT"))
t.R.NoError(err)

fs := afero.NewOsFs()
Expand All @@ -451,7 +451,7 @@ func (scenario *Scenario) Prepare(t *wrapt.T, ctx context.Context) {

t.R.NoError(os.Chdir(scenario.Workpath))

_, err = ExecuteCommand(ctx, "bbi", "init", "--dir", os.Getenv("NONMEMROOT"))
_, err = bi.ExecuteCommand(ctx, "bbi", "init", "--dir", os.Getenv("NONMEMROOT"))
t.R.NoError(err)

t.R.NoError(os.Chdir(whereami))
Expand Down
6 changes: 3 additions & 3 deletions integration/postrun/bbi_covcor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regexp"
"testing"

. "github.com/metrumresearchgroup/bbi/integration"
bi "github.com/metrumresearchgroup/bbi/integration"
"github.com/metrumresearchgroup/bbi/utils"

"github.com/metrumresearchgroup/wrapt"
Expand All @@ -33,7 +33,7 @@ func TestCovCorHappyPath(tt *testing.T) {
filepath.Join(SUMMARY_TEST_DIR, mod.name, mod.name),
}

output, err := ExecuteCommand(context.Background(), "bbi", commandAndArgs...)
output, err := bi.ExecuteCommand(context.Background(), "bbi", commandAndArgs...)

t.R.NoError(err)
t.R.NotEmpty(output)
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestCovCorErrors(tt *testing.T) {

// try without flag and get error
var output string
output, err := ExecuteCommandNoErrorCheck(context.Background(), "bbi", commandAndArgs...)
output, err := bi.ExecuteCommandNoErrorCheck(context.Background(), "bbi", commandAndArgs...)
t.R.Error(err)

errorMatch := rgx.MatchString(output)
Expand Down
6 changes: 3 additions & 3 deletions integration/postrun/bbi_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"path/filepath"
"testing"

. "github.com/metrumresearchgroup/bbi/integration"
bi "github.com/metrumresearchgroup/bbi/integration"
"github.com/metrumresearchgroup/bbi/utils"
"github.com/metrumresearchgroup/wrapt"
)
Expand Down Expand Up @@ -39,7 +39,7 @@ func TestParamsSingleModel(tt *testing.T) {
commandAndArgs = append(commandAndArgs, tc.bbiOption)
}

output, err := ExecuteCommand(context.Background(), "bbi", commandAndArgs...)
output, err := bi.ExecuteCommand(context.Background(), "bbi", commandAndArgs...)

t.R.NoError(err)
t.R.NotEmpty(output)
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestParamsDir(tt *testing.T) {
commandAndArgs = append(commandAndArgs, tc.bbiOption)
}

output, err := ExecuteCommand(context.Background(), "bbi", commandAndArgs...)
output, err := bi.ExecuteCommand(context.Background(), "bbi", commandAndArgs...)

t.R.NoError(err)
t.R.NotEmpty(output)
Expand Down
6 changes: 3 additions & 3 deletions integration/postrun/bbi_reclean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regexp"
"testing"

. "github.com/metrumresearchgroup/bbi/integration"
bi "github.com/metrumresearchgroup/bbi/integration"
"github.com/metrumresearchgroup/wrapt"
)

Expand All @@ -23,7 +23,7 @@ func TestBBIRecleanBasic(tt *testing.T) {
_ = os.WriteFile(fdataCSV, []byte("fake"), 0644)
t.A.FileExists(fdataCSV)

output, err := ExecuteCommand(context.Background(),
output, err := bi.ExecuteCommand(context.Background(),
"bbi", "nonmem", "reclean", "--recleanLvl=1", "-v", dir)
t.R.NoError(err)
t.R.NotEmpty(output)
Expand All @@ -34,7 +34,7 @@ func TestBBIRecleanBasic(tt *testing.T) {
func TestBBIRecleanError(tt *testing.T) {
t := wrapt.WrapT(tt)

output, err := ExecuteCommandNoErrorCheck(context.Background(),
output, err := bi.ExecuteCommandNoErrorCheck(context.Background(),
"bbi", "nonmem", "reclean")

t.R.NotNil(err)
Expand Down
Loading

0 comments on commit 94c9262

Please sign in to comment.