on master help sign in
Test verify-migration in CI (hydra)
commitfbce10856391ddc7010b6df3052042be7ae9a85b authorSridhar Ratnakumar <srid@srid.ca> dateMon 25 Jun 2018, 14:34 (8 years ago) parente7e65ac
5 files changed+30−10
default.nix+1 lib/command/src/Obelisk/Command/Upgrade/Hash.hs+5−5 migration/95955d1dd0981ebb538ee941cde1f963-07900e6c41ab9a78917f66fcf7e0d9b8/obelisk-handoff migration/95955d1dd0981ebb538ee941cde1f963-07900e6c41ab9a78917f66fcf7e0d9b8/obelisk-upgrade release.nix+24−5
default.nix+1
@@ -130,6 +130,7 @@ with pkgs.lib;
130130rec {
131131 inherit reflex-platform;
132132 inherit (reflex-platform) nixpkgs pinBuildInputs;
133+ pathGit = ./.; # Used in CI by the migration graph hash algorithm to correctly ignore files.
133134 path = reflex-platform.filterGit ./.;
134135 obelisk = ghcObelisk;
135136 commandWithMigration = ghcObelisk.obelisk-command.overrideAttrs (drv: {
lib/command/src/Obelisk/Command/Upgrade/Hash.hs+5−5
@@ -36,12 +36,12 @@ import Obelisk.Migration
3636-- * ignored Git files
3737-- * empty directories
3838--
39−-- Uses the same predictive algorithm as that of Nix (`nix hash-path`).
39+-- Uses the same predictive algorithm as that of Nix (`nix-hash`).
4040--
4141-- This function will do a full copy of the directory to a temporary location before
4242-- computing the hash. Because it will be deleting the files in exclude list, and
43−-- other files if the directory is a git repo, which needs to be done as `nix
44−-- hash-path` doesn't support taking an excludes list.
43+-- other files if the directory is a git repo, which needs to be done as `nix-hash`
44+-- doesn't support taking an excludes list.
4545getDirectoryHash :: MonadObelisk m => [FilePath] -> FilePath -> m Hash
4646getDirectoryHash excludes dir = withSystemTempDirectory "obelisk-hash-" $ \tmpDir -> do
4747 withSpinnerNoTrail (T.pack $ "Copying " <> dir <> " to " <> tmpDir) $ do
@@ -87,8 +87,8 @@ getHashAtGitRevision revs excludes dir = withSystemTempDirectory "obelisk-hashre
8787 return result
8888
8989nixHash :: MonadObelisk m => FilePath -> m Hash
90−nixHash dir = withSpinnerNoTrail "Running `nix hash-path`" $
91− readProc $ proc "nix" ["hash-path", "--type", "md5", dir]
90+nixHash dir = withSpinnerNoTrail "Running `nix-hash`" $
91+ readProc $ proc "nix-hash" [dir]
9292
9393-- | Clean up the following files in the git working copy
9494--
migration/95955d1dd0981ebb538ee941cde1f963-07900e6c41ab9a78917f66fcf7e0d9b8/obelisk-handoffnew file

No changes to the content.

migration/95955d1dd0981ebb538ee941cde1f963-07900e6c41ab9a78917f66fcf7e0d9b8/obelisk-upgradenew file

No changes to the content.

release.nix+24−5
@@ -9,15 +9,34 @@ with pkgs;
99 built-skeleton = (import ./skeleton {}).all;
1010 tests = {
1111 #TODO: Doesn't work; see discussion in https://www.pivotaltracker.com/story/show/157265140
12− #ob-init = runCommand "ob-init" {
12+ # ob-init = runCommand "ob-init" {
1313 # nativeBuildInputs = [
1414 # self.command
1515 # nix
1616 # ];
17− #} ''
18− # mkdir $out
19− # cd $out
20− # ob init --symlink=${self.path}
17+ # } ''
18+ # # mkdir $out
19+ # # cd $out
20+ # # ob init --symlink=${self.path}
2121 #'';
22+
23+ verify-migration = runCommand "verify-migration" {
24+ nativeBuildInputs = [
25+ self.command
26+ nix # obelisk uses `nix-hash`
27+ ];
28+ } ''
29+ set -xe
30+ # Fix permissions so `removePathForcibly` works on copied-to-tmp paths
31+ cp -a ${self.pathGit} $TMPDIR/obelisk
32+ cd $TMPDIR/obelisk
33+ chmod -R u+w .
34+
35+ ob internal hash
36+ ob internal verify-migration
37+
38+ mkdir -p $out
39+ touch $out/done
40+ '';
2241 };
2342}