on master help sign in
upload-nightly
e77403eMichael Snoyman
ChangeLog.md+3−2
@@ -1,6 +1,7 @@
1−## 0.4.0.1
1+## 0.4.1
2
2
3−* Print "Still Alive" while checking, to avoid Travis timeouts.
3+* Print "Still Alive" while checking, to avoid Travis timeouts
4+* Include `stackage upload-nightly` command
4
5
5## 0.4.0
6## 0.4.0
6
7
Stackage/CompleteBuild.hs+54−31
@@ -7,6 +7,7 @@ module Stackage.CompleteBuild
7 , BuildFlags (..)
7 , BuildFlags (..)
8 , completeBuild
8 , completeBuild
9 , justCheck
9 , justCheck
10+ , justUploadNightly
10 ) where
11 ) where
11
12
12import Control.Concurrent (threadDelay)
13import Control.Concurrent (threadDelay)
@@ -53,28 +54,38 @@ data Settings = Settings
53 , postBuild :: IO ()
54 , postBuild :: IO ()
54 }
55 }
55
56
57+nightlyPlanFile :: Text -- ^ day
58+ -> FilePath
59+nightlyPlanFile day = fpFromText ("nightly-" ++ day) <.> "yaml"
60+
61+nightlySettings :: Text -- ^ day
62+ -> BuildPlan
63+ -> Settings
64+nightlySettings day plan' = Settings
65+ { planFile = nightlyPlanFile day
66+ , buildDir = fpFromText $ "builds/stackage-nightly-" ++ day
67+ , logDir = fpFromText $ "logs/stackage-nightly-" ++ day
68+ , title = \ghcVer -> concat
69+ [ "Stackage Nightly "
70+ , day
71+ , ", GHC "
72+ , ghcVer
73+ ]
74+ , slug = slug'
75+ , setArgs = \ghcVer ub -> ub { ubNightly = Just ghcVer }
76+ , plan = plan'
77+ , postBuild = return ()
78+ }
79+ where
80+ slug' = "nightly-" ++ day
81+
56getSettings :: Manager -> BuildType -> IO Settings
82getSettings :: Manager -> BuildType -> IO Settings
57getSettings man Nightly = do
83getSettings man Nightly = do
58 day <- tshow . utctDay <$> getCurrentTime
84 day <- tshow . utctDay <$> getCurrentTime
59− let slug' = "nightly-" ++ day
60 bc <- defaultBuildConstraints man
85 bc <- defaultBuildConstraints man
61 pkgs <- getLatestAllowedPlans bc
86 pkgs <- getLatestAllowedPlans bc
62 plan' <- newBuildPlan pkgs bc
87 plan' <- newBuildPlan pkgs bc
63− return Settings
88+ return $ nightlySettings day plan'
64− { planFile = fpFromText ("nightly-" ++ day) <.> "yaml"
65− , buildDir = fpFromText $ "builds/stackage-nightly-" ++ day
66− , logDir = fpFromText $ "logs/stackage-nightly-" ++ day
67− , title = \ghcVer -> concat
68− [ "Stackage Nightly "
69− , day
70− , ", GHC "
71− , ghcVer
72− ]
73− , slug = slug'
74− , setArgs = \ghcVer ub -> ub { ubNightly = Just ghcVer }
75− , plan = plan'
76− , postBuild = return ()
77− }
78getSettings man (LTS bumpType) = do
89getSettings man (LTS bumpType) = do
79 Option mlts <- fmap (fmap getMax) $ runResourceT
90 Option mlts <- fmap (fmap getMax) $ runResourceT
80 $ sourceDirectory "."
91 $ sourceDirectory "."
@@ -178,6 +189,19 @@ justCheck = stillAlive $ withManager tlsManagerSettings $ \man -> do
178
189
179 putStrLn "Plan seems valid!"
190 putStrLn "Plan seems valid!"
180
191
192+getPerformBuild :: BuildFlags -> Settings -> PerformBuild
193+getPerformBuild buildFlags Settings {..} = PerformBuild
194+ { pbPlan = plan
195+ , pbInstallDest = buildDir
196+ , pbLogDir = logDir
197+ , pbLog = hPut stdout
198+ , pbJobs = 8
199+ , pbGlobalInstall = False
200+ , pbEnableTests = bfEnableTests buildFlags
201+ , pbEnableLibProfiling = bfEnableLibProfile buildFlags
202+ , pbVerbose = bfVerbose buildFlags
203+ }
204+
181-- | Make a complete plan, build, test and upload bundle, docs and
205-- | Make a complete plan, build, test and upload bundle, docs and
182-- distro.
206-- distro.
183completeBuild :: BuildType -> BuildFlags -> IO ()
207completeBuild :: BuildType -> BuildFlags -> IO ()
@@ -194,26 +218,23 @@ completeBuild buildType buildFlags = withManager tlsManagerSettings $ \man -> do
194 checkBuildPlan plan
218 checkBuildPlan plan
195
219
196 putStrLn "Performing build"
220 putStrLn "Performing build"
197− let pb = PerformBuild
198− { pbPlan = plan
199− , pbInstallDest = buildDir
200− , pbLogDir = logDir
201− , pbLog = hPut stdout
202− , pbJobs = 8
203− , pbGlobalInstall = False
204− , pbEnableTests = bfEnableTests buildFlags
205− , pbEnableLibProfiling = bfEnableLibProfile buildFlags
206− , pbVerbose = bfVerbose buildFlags
207− }
208− performBuild pb >>= mapM_ putStrLn
221+ performBuild (getPerformBuild buildFlags settings) >>= mapM_ putStrLn
209
222
210 when (bfDoUpload buildFlags) $
223 when (bfDoUpload buildFlags) $
211− finallyUpload settings man pb
224+ finallyUpload settings man
225+
226+justUploadNightly
227+ :: Text -- ^ nightly date
228+ -> IO ()
229+justUploadNightly day = do
230+ plan <- decodeFileEither (fpToString $ nightlyPlanFile day)
231+ >>= either throwM return
232+ withManager tlsManagerSettings $ finallyUpload $ nightlySettings day plan
212
233
213-- | The final part of the complete build process: uploading a bundle,
234-- | The final part of the complete build process: uploading a bundle,
214-- docs and a distro to hackage.
235-- docs and a distro to hackage.
215−finallyUpload :: Settings -> Manager -> PerformBuild -> IO ()
236+finallyUpload :: Settings -> Manager -> IO ()
216−finallyUpload Settings{..} man pb = do
237+finallyUpload settings@Settings{..} man = do
217 putStrLn "Uploading bundle to Stackage Server"
238 putStrLn "Uploading bundle to Stackage Server"
218 token <- readFile "/auth-token"
239 token <- readFile "/auth-token"
219 now <- epochTime
240 now <- epochTime
@@ -253,3 +274,5 @@ finallyUpload Settings{..} man pb = do
253 , udmDocDir = pbDocDir pb
274 , udmDocDir = pbDocDir pb
254 , udmPlan = plan
275 , udmPlan = plan
255 } man >>= print
276 } man >>= print
277+ where
278+ pb = getPerformBuild (error "finallyUpload.buildFlags") settings
app/stackage.hs+10
@@ -4,6 +4,7 @@ module Main where
4
4
5import Control.Monad
5import Control.Monad
6import Data.Monoid
6import Data.Monoid
7+import Data.String (fromString)
7import Data.Version
8import Data.Version
8import Options.Applicative
9import Options.Applicative
9import Paths_stackage (version)
10import Paths_stackage (version)
@@ -45,6 +46,11 @@ main =
45 (fmap (LTS Minor, ) buildFlags)
46 (fmap (LTS Minor, ) buildFlags)
46 "lts-minor"
47 "lts-minor"
47 "Build, test and upload the LTS (minor) snapshot"
48 "Build, test and upload the LTS (minor) snapshot"
49+ , cmnd
50+ justUploadNightly
51+ nightlyUploadFlags
52+ "upload-nightly"
53+ "Upload an already-built nightly snapshot"
48 , cmnd
54 , cmnd
49 (const justCheck)
55 (const justCheck)
50 (pure ())
56 (pure ())
@@ -73,3 +79,7 @@ main =
73 switch
79 switch
74 (long "verbose" <> short 'v' <>
80 (long "verbose" <> short 'v' <>
75 help "Output verbose detail about the build steps")
81 help "Output verbose detail about the build steps")
82+
83+ nightlyUploadFlags = fromString <$> strArgument
84+ (metavar "DATE" <>
85+ help "Date, in YYYY-MM-DD format")
stackage.cabal+1−1
@@ -1,5 +1,5 @@
1name: stackage
1name: stackage
2−version: 0.4.0.1
2+version: 0.4.1
3synopsis: "Stable Hackage," tools for creating a vetted set of packages from Hackage.
3synopsis: "Stable Hackage," tools for creating a vetted set of packages from Hackage.
4description: Please see <http://www.stackage.org/package/stackage> for a description and documentation.
4description: Please see <http://www.stackage.org/package/stackage> for a description and documentation.
5homepage: https://github.com/fpco/stackage
5homepage: https://github.com/fpco/stackage