Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Fixes lein analysis for common CI workflows #379

Merged
merged 2 commits into from
Sep 28, 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: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Spectrometer Changelog

## v2.15.24
- Leiningen: Executes `lein --version` before performing any analysis, to ensure Leiningen has performed its install tasks (done on its first invocation). ([#379](https://github.com/fossas/spectrometer/pull/379))

## v2.15.23
- Maven: Fixes `mvn:dependency` tactic to exclude root project as direct dependency. ([#375](https://github.com/fossas/spectrometer/pull/375))

Expand Down
13 changes: 13 additions & 0 deletions src/Strategy/Leiningen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ leinDepsCmd =
, cmdAllowErr = Never
}

leinVersionCmd :: Command
leinVersionCmd =
Command
{ cmdName = "lein"
, cmdArgs = ["--version"]
, cmdAllowErr = Always
}

discover :: (Has ReadFS sig m, Has Diagnostics sig m, Has Exec rsig run, Has Diagnostics rsig run) => Path Abs Dir -> m [DiscoveredProject run]
discover dir = context "Leiningen" $ do
projects <- context "Finding projects" $ findProjects dir
Expand Down Expand Up @@ -89,6 +97,11 @@ data LeiningenProject = LeiningenProject

analyze :: (Has Exec sig m, Has Diagnostics sig m) => Path Abs File -> m DependencyResults
analyze file = do
-- Lein executable performs configuration task and prints its progress on the first invocation.
-- Intentionally invoke --version command to ensure subsequent analyses command are not lein's first invocation.
-- This ensures, subsequent analyzes commands' outputs are not contaminated with lein's configuration task's output.
_ <- exec (parent file) leinVersionCmd

stdoutBL <- execThrow (parent file) leinDepsCmd
let stdoutTL = decodeUtf8 stdoutBL
stdout = TL.toStrict stdoutTL
Expand Down