Skip to content

Commit

Permalink
add --service-name option
Browse files Browse the repository at this point in the history
  • Loading branch information
msakai authored and killy971 committed Sep 2, 2015
1 parent 8ed4948 commit 9a3de1d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/HpcCoverallsCmdLine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ data HpcCoverallsArgs = CmdMain
{ optExcludeDirs :: [String]
, argTestSuites :: [String]
, optCabalFile :: Maybe String
, optServiceName :: Maybe String
, optRepoToken :: Maybe String
, optDisplayReport :: Bool
, optCurlVerbose :: Bool
Expand All @@ -27,6 +28,7 @@ hpcCoverallsArgs = CmdMain
, optDontSend = False &= explicit &= name "dont-send" &= help "Do not send the report to coveralls.io"
, optCoverageMode = AllowPartialLines &= explicit &= typ "MODE" &= name "coverage-mode" &= help "Coverage conversion mode: AllowPartialLines (default), StrictlyFullLines"
, optCabalFile = Nothing &= explicit &= typ "FILE" &= name "cabal-file" &= help "Cabal file (ex.: module-name.cabal)"
, optServiceName = Nothing &= explicit &= typ "TOKEN" &= name "service-name" &= help "service-name (e.g. travis-pro)"
, optRepoToken = Nothing &= explicit &= typ "TOKEN" &= name "repo-token" &= help "Coveralls repo token"
, argTestSuites = [] &= typ "TEST-SUITES" &= args
} &= summary ("hpc-coveralls-" ++ versionString version ++ ", (C) Guillaume Nargeot 2014-2015")
Expand Down
11 changes: 7 additions & 4 deletions src/HpcCoverallsMain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import System.Environment (getEnv, getEnvironment)
import System.Exit (exitFailure)
import Trace.Hpc.Coveralls
import Trace.Hpc.Coveralls.Cabal
import Trace.Hpc.Coveralls.Config (Config(Config), cabalFile)
import Trace.Hpc.Coveralls.Config (Config(Config, cabalFile, serviceName))
import Trace.Hpc.Coveralls.Curl
import Trace.Hpc.Coveralls.GitInfo (getGitInfo)
import Trace.Hpc.Coveralls.Util
Expand Down Expand Up @@ -44,6 +44,7 @@ getConfig hca = Config
(optExcludeDirs hca)
(optCoverageMode hca)
(optCabalFile hca)
(optServiceName hca)
(optRepoToken hca)
<$> listToMaybe (argTestSuites hca)

Expand All @@ -53,14 +54,16 @@ main = do
case getConfig hca of
Nothing -> putStrLn "Please specify a target test suite name"
Just config -> do
(serviceName, jobId) <- getServiceAndJobID
(defaultServiceName, jobId) <- getServiceAndJobID
let sn = fromMaybe defaultServiceName (serviceName config)
gitInfo <- getGitInfo
mPkgNameVer <- case cabalFile config of
Just cabalFilePath -> getPackageNameVersion cabalFilePath
Nothing -> currDirPkgNameVer
gitInfo <- getGitInfo
coverallsJson <- generateCoverallsFromTix serviceName jobId gitInfo config mPkgNameVer
coverallsJson <- generateCoverallsFromTix sn jobId gitInfo config mPkgNameVer
when (optDisplayReport hca) $ BSL.putStrLn $ encode coverallsJson
let filePath = serviceName ++ "-" ++ jobId ++ ".json"
let filePath = sn ++ "-" ++ jobId ++ ".json"
writeJson filePath coverallsJson
unless (optDontSend hca) $ do
response <- postJson filePath urlApiV1 (optCurlVerbose hca)
Expand Down
1 change: 1 addition & 0 deletions src/Trace/Hpc/Coveralls/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ data Config = Config {
excludedDirs :: ![FilePath],
coverageMode :: !CoverageMode,
cabalFile :: !(Maybe FilePath),
serviceName :: !(Maybe String),
repoToken :: !(Maybe String),
testSuites :: ![String]
}

0 comments on commit 9a3de1d

Please sign in to comment.