Skip to content

Add Arduino Lint installation path as a configuration field #29

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

Merged
merged 1 commit into from
May 21, 2021
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
3 changes: 2 additions & 1 deletion config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"LibrariesIndex": "/tmp/libraries/library_index.json",
"LibrariesDB": "/tmp/libraries_db.json",
"GitClonesFolder": "/tmp/gitclones",
"ArduinoLintPath": "/usr/bin/arduino-lint",
"CronTabEntry": "0 0 0 * * *"
}
}
9 changes: 7 additions & 2 deletions libraries/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ func official(metadata *Repo) bool {
}

// RunArduinoLint runs Arduino Lint on the library and returns the report in the event of error or warnings.
func RunArduinoLint(folder string, metadata *Repo) ([]byte, error) {
func RunArduinoLint(arduinoLintPath string, folder string, metadata *Repo) ([]byte, error) {
if arduinoLintPath == "" {
// Assume Arduino Lint is installed under PATH.
arduinoLintPath = "arduino-lint"
}

JSONReportFolder, err := ioutil.TempDir("", "arduino-lint-report-")
if err != nil {
panic(err)
Expand All @@ -59,7 +64,7 @@ func RunArduinoLint(folder string, metadata *Repo) ([]byte, error) {

// See: https://arduino.github.io/arduino-lint/latest/commands/arduino-lint/
cmd := exec.Command(
"arduino-lint",
arduinoLintPath,
"--compliance=permissive",
"--format=text",
"--project-type=library",
Expand Down
2 changes: 1 addition & 1 deletion libraries/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestRunArduinoLint(t *testing.T) {
} else {
metadata.Types = []string{"Contributed"}
}
report, err := RunArduinoLint(filepath.Join(testDataPath, "libraries", testTable.folder), &metadata)
report, err := RunArduinoLint("", filepath.Join(testDataPath, "libraries", testTable.folder), &metadata)
assert.Regexp(t, regexp.MustCompile(testTable.reportRegexp), string(report), testTable.testName)
testTable.errorAssertion(t, err, testTable.testName)
}
Expand Down
3 changes: 2 additions & 1 deletion sync_libraries.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Config struct {
LibrariesIndex string
GitClonesFolder string
DoNotRunClamav bool
ArduinoLintPath string
}

func logError(err error) bool {
Expand Down Expand Up @@ -308,7 +309,7 @@ func syncLibraryTaggedRelease(logger *log.Logger, repo *libraries.Repository, ta
}
}

report, err := libraries.RunArduinoLint(repo.FolderPath, repoMeta)
report, err := libraries.RunArduinoLint(config.ArduinoLintPath, repo.FolderPath, repoMeta)
reportTemplate := `<a href="https://arduino.github.io/arduino-lint/latest/">Arduino Lint</a> %s:
<details><summary>Click to expand Arduino Lint report</summary>
<hr>
Expand Down