Lint and grammar fixes (#237)

* Apply hlint suggestions

* Fix spelling error

* chore: Fix spelling error and update release identifier comments

* Undo change not needed
This commit is contained in:
Franz Guzmán 2024-06-20 21:32:27 -05:00 committed by GitHub
parent e8ec435b2b
commit b7fd5361b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 27 deletions

View File

@ -152,7 +152,7 @@ spec = do
it "creates the maintenance file in the given path" $ \(deployPath, _) -> do
result <- runHap $ do
writeMaintenanceFile deployPath $(mkRelDir "maintenance") $(mkRelFile "maintenance.html")
liftIO $ System.Directory.doesFileExist ((fromAbsDir deployPath) <> "/maintenance/maintenance.html")
liftIO $ System.Directory.doesFileExist (fromAbsDir deployPath <> "/maintenance/maintenance.html")
result `shouldBe` True
describe "deleteMaintenanceFile" $
context "when the file exists" $
@ -160,7 +160,7 @@ spec = do
result <- runHap $ do
writeMaintenanceFile deployPath $(mkRelDir "maintenance") $(mkRelFile "maintenance.html")
deleteMaintenanceFile deployPath $(mkRelDir "maintenance") $(mkRelFile "maintenance.html")
liftIO $ System.Directory.doesFileExist ((fromAbsDir deployPath) <> "/maintenance/maintenance.html")
liftIO $ System.Directory.doesFileExist (fromAbsDir deployPath <> "/maintenance/maintenance.html")
result `shouldBe` False
describe "releasePath" $ do
context "when the configWorkingDir is Nothing" $
@ -273,7 +273,7 @@ spec = do
True
describe "playScriptLocally (error exit)" $
it "check that deployment isn't done" $ \(deployPath, repoPath) ->
(runHap $ do
runHap (do
let localCommands =
mapMaybe Hap.mkGenericCommand ["pwd", "ls", "false"]
task = mkTask deployPath repoPath
@ -281,29 +281,29 @@ spec = do
release <- Hap.pushRelease task
Hap.createHapistranoDeployState deployPath release Success) `shouldThrow`
anyException
describe "rollback" $ do
describe "rollback" $
it "resets the current symlink correctly" $ \(deployPath, repoPath) ->
runHap $ do
let task = mkTask deployPath repoPath
noCmd = Nothing
rs <- replicateM 5 (Hap.pushRelease task)
Hap.rollback currentSystem deployPath 2 noCmd
rpath <- Hap.releasePath deployPath (rs !! 2) Nothing
let rc :: Hap.Readlink Dir
rc =
Hap.Readlink currentSystem (Hap.currentSymlinkPath deployPath)
Hap.exec rc Nothing `shouldReturn` rpath
Path.IO.doesFileExist (Hap.tempSymlinkPath deployPath) `shouldReturn` False
describe "rollback to non-exist release" $ do
runHap $ do
let task = mkTask deployPath repoPath
noCmd = Nothing
rs <- replicateM 5 (Hap.pushRelease task)
Hap.rollback currentSystem deployPath 2 noCmd
rpath <- Hap.releasePath deployPath (rs !! 2) Nothing
let rc :: Hap.Readlink Dir
rc =
Hap.Readlink currentSystem (Hap.currentSymlinkPath deployPath)
Hap.exec rc Nothing `shouldReturn` rpath
Path.IO.doesFileExist (Hap.tempSymlinkPath deployPath) `shouldReturn` False
describe "rollback to non-exist release" $
it "trying to rollback to a non-exist release, should throw exception" $ \(deployPath, repoPath) ->
(runHap $ do
let task = mkTask deployPath repoPath
noCmd = Nothing
replicateM_ 5 (Hap.pushRelease task)
Hap.rollback currentSystem deployPath 6 noCmd) `shouldThrow`
anyException
runHap (do
let task = mkTask deployPath repoPath
noCmd = Nothing
replicateM_ 5 (Hap.pushRelease task)
Hap.rollback currentSystem deployPath 6 noCmd) `shouldThrow`
anyException
describe "dropOldReleases" $ do
it "works" $ \(deployPath, repoPath) ->
it "should not keep more than 5 releases by default after a successful release" $ \(deployPath, repoPath) ->
runHap $ do
rs <-
replicateM 7 $ do
@ -513,3 +513,4 @@ arbitraryReleaseFormat = elements [ReleaseShort, ReleaseLong]
arbitraryKeepReleases :: Gen Natural
arbitraryKeepReleases = fromInteger . getPositive <$> arbitrary

View File

@ -155,7 +155,7 @@ deploy
:: HC.Config -- ^ Deploy configuration
-> ReleaseFormat -- ^ Long or Short format
-> Natural -- ^ Number of releases to keep
-> Bool -- ^ Wheter we should keep one failed release or not
-> Bool -- ^ Whether we should keep one failed release or not
-> ExecutionMode -- ^ Is running on lead target
-> Hapistrano ()
deploy HC.Config{..} releaseFormat keepReleases keepOneFailed executionMode = do

View File

@ -158,7 +158,7 @@ data OutputDest
| StderrDest
deriving (Eq, Show, Read, Ord, Bounded, Enum)
-- | Release indentifier.
-- | Release identifier.
data Release =
Release ReleaseFormat UTCTime
deriving (Eq, Show, Ord)
@ -201,7 +201,7 @@ data Command
| Maintenance MaintenanceOptions
| InitConfig -- ^ initialize configuration file
-- | Create a 'Release' indentifier.
-- | Create a 'Release' identifier.
mkRelease :: ReleaseFormat -> UTCTime -> Release
mkRelease = Release
@ -209,7 +209,7 @@ mkRelease = Release
releaseTime :: Release -> UTCTime
releaseTime (Release _ time) = time
-- | Render 'Release' indentifier as a 'String'.
-- | Render 'Release' identifier as a 'String'.
renderRelease :: Release -> String
renderRelease (Release rfmt time) = formatTime defaultTimeLocale fmt time
where