From 898ff1ee29019ca3178b6ce3b38e8de5d4812556 Mon Sep 17 00:00:00 2001 From: Mike Pilgrem Date: Sun, 4 Feb 2024 18:50:22 +0000 Subject: [PATCH] Prefer snapshot to resolver --- .github/workflows/tests.yml | 22 +++++++++++----------- int/Pantry/Types.hs | 16 ++++++++-------- test/Pantry/TypesSpec.hs | 30 +++++++++++++++--------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d8c664fe..8163fd1d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,18 +19,18 @@ jobs: matrix: os: - ubuntu-latest - resolver: + snapshot: - stack-ghc-9.4.8.yaml - stack-ghc-9.6.4.yaml - stack-ghc-9.8.1.yaml include: - os: macos-latest - resolver: stack-ghc-9.8.1.yaml + snapshot: stack-ghc-9.8.1.yaml # macos-14 provides macOS/AArch64 (M1) - os: macos-14 - resolver: stack-ghc-9.8.1.yaml + snapshot: stack-ghc-9.8.1.yaml - os: windows-latest - resolver: stack-ghc-9.8.1.yaml + snapshot: stack-ghc-9.8.1.yaml steps: - name: Clone project uses: actions/checkout@v4 @@ -39,7 +39,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.stack - key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.resolver }} + key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.snapshot }} - name: Cache dependencies on Windows if: startsWith(runner.os, 'Windows') uses: actions/cache@v4 @@ -47,7 +47,7 @@ jobs: path: | ~\AppData\Roaming\stack ~\AppData\Local\Programs\stack - key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.resolver }} + key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.snapshot }} - name: Build and run tests shell: bash run: | @@ -59,7 +59,7 @@ jobs: curl -sSL https://get.haskellstack.org/ | sh fi - stack --resolver ${{ matrix.resolver }} test --bench --no-run-benchmarks --haddock --no-haddock-deps + stack --resolver ${{ matrix.snapshot }} test --bench --no-run-benchmarks --haddock --no-haddock-deps test-pretty-exceptions: name: Test build of test-pretty-exceptions runs-on: ${{ matrix.os }} @@ -69,7 +69,7 @@ jobs: os: - ubuntu-latest - windows-latest - resolver: + snapshot: - stack-ghc-9.8.1.yaml steps: - name: Clone project @@ -79,7 +79,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.stack - key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.resolver }}-pretty + key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.snapshot }}-pretty - name: Cache dependencies on Windows if: startsWith(runner.os, 'Windows') uses: actions/cache@v4 @@ -87,9 +87,9 @@ jobs: path: | ~\AppData\Roaming\stack ~\AppData\Local\Programs\stack - key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.resolver }}-pretty + key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.snapshot }}-pretty - name: Build test-pretty-exceptions shell: bash run: | set -ex - stack --resolver ${{ matrix.resolver }} build --flag pantry:test-pretty-exceptions + stack --resolver ${{ matrix.snapshot }} build --flag pantry:test-pretty-exceptions diff --git a/int/Pantry/Types.hs b/int/Pantry/Types.hs index 6dd80243..a416b54b 100644 --- a/int/Pantry/Types.hs +++ b/int/Pantry/Types.hs @@ -1225,7 +1225,7 @@ instance Display PantryException where <> displayShow (toFilePath dir) display (InvalidOverrideCompiler x y) = "Error: [S-287]\n" - <> "Specified compiler for a resolver (" + <> "Specified compiler for a snapshot (" <> display x <> "), but also specified an override compiler (" <> display y @@ -1605,7 +1605,7 @@ instance Pretty PantryException where "[S-287]" <> line <> fillSep - [ flow "Specified compiler for a resolver" + [ flow "Specified compiler for a snapshot" , parens (style Shell (fromString . T.unpack $ textDisplay x)) , flow "but also specified an override compiler" , parens (style Shell (fromString . T.unpack $ textDisplay y)) <> "." @@ -3225,17 +3225,17 @@ instance ToJSON RawSnapshotLayer where instance FromJSON (WithJSONWarnings (Unresolved RawSnapshotLayer)) where parseJSON = withObjectWarnings "Snapshot" $ \o -> do _ :: Maybe Text <- o ..:? "name" -- avoid warnings for old snapshot format - mcompiler <- o ..:? "compiler" - mresolver <- jsonSubWarningsT $ o ...:? ["snapshot", "resolver"] + mCompiler <- o ..:? "compiler" + mSnapshot <- jsonSubWarningsT $ o ...:? ["snapshot", "resolver"] unresolvedSnapshotParent <- - case (mcompiler, mresolver) of - (Nothing, Nothing) -> fail "Snapshot must have either resolver or compiler" + case (mCompiler, mSnapshot) of + (Nothing, Nothing) -> fail "Snapshot must have either a compiler or a snapshot" (Just compiler, Nothing) -> pure $ pure (RSLCompiler compiler, Nothing) (_, Just (Unresolved usl)) -> pure $ Unresolved $ \mdir -> do sl <- usl mdir - case (sl, mcompiler) of + case (sl, mCompiler) of (RSLCompiler c1, Just c2) -> throwIO $ InvalidOverrideCompiler c1 c2 - _ -> pure (sl, mcompiler) + _ -> pure (sl, mCompiler) unresolvedLocs <- jsonSubWarningsT (o ..:? "packages" ..!= []) rslDropPackages <- Set.map unCabalString <$> (o ..:? "drop-packages" ..!= Set.empty) diff --git a/test/Pantry/TypesSpec.hs b/test/Pantry/TypesSpec.hs index c9227876..3ef9abb5 100644 --- a/test/Pantry/TypesSpec.hs +++ b/test/Pantry/TypesSpec.hs @@ -24,7 +24,7 @@ import Pantry.Types ( Tree (..), TreeEntry (..), parseTree, renderTree ) import RIO import qualified RIO.Text as T -import RIO.Time ( Day (..) ) +import RIO.Time ( Day (..), fromGregorian ) import Test.Hspec import Text.RawString.QQ @@ -108,20 +108,20 @@ spec = do it "parses snapshot using 'resolver'" $ do RawSnapshotLayer{..} <- parseSl $ "name: 'test'\n" ++ - "resolver: lts-2.10\n" - rslParent `shouldBe` RSLSynonym (LTS 2 10) + "resolver: lts-22.9\n" + rslParent `shouldBe` RSLSynonym (LTS 22 9) it "parses snapshot using 'snapshot'" $ do RawSnapshotLayer{..} <- parseSl $ "name: 'test'\n" ++ - "snapshot: lts-2.10\n" - rslParent `shouldBe` RSLSynonym (LTS 2 10) + "snapshot: lts-22.9\n" + rslParent `shouldBe` RSLSynonym (LTS 22 9) it "throws if both 'resolver' and 'snapshot' are present" $ do let go = parseSl $ "name: 'test'\n" ++ - "resolver: lts-2.10\n" ++ - "snapshot: lts-2.10\n" + "resolver: lts-22.9\n" ++ + "snapshot: lts-22.9\n" go `shouldThrow` anyException it "throws if both 'snapshot' and 'compiler' are not present" $ do @@ -131,8 +131,8 @@ spec = do it "works if no 'snapshot' specified" $ do RawSnapshotLayer{..} <- parseSl $ "name: 'test'\n" ++ - "compiler: ghc-8.0.1\n" - rslParent `shouldBe` RSLCompiler (WCGhc (mkVersion [8, 0, 1])) + "compiler: ghc-9.6.4\n" + rslParent `shouldBe` RSLCompiler (WCGhc (mkVersion [9, 6, 4])) hh "rendering the name of an LTS to JSON" $ property $ do (major, minor) <- forAll $ (,) @@ -211,14 +211,14 @@ spec = do txt `shouldBe` txt'' sameUrl _ _ _ = liftIO $ error "Snapshot synonym did not complete as expected" - it "default location for nightly-2020-01-01" $ do - let sn = Nightly $ ModifiedJulianDay 58849 + it "default location for nightly-2024-02-04" $ do + let sn = Nightly $ fromGregorian 2024 2 4 loc <- runPantryAppClean $ completeSnapshotLocation $ RSLSynonym sn sameUrl loc (defaultSnapshotLocation sn) - "https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2020/1/1.yaml" + "https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2024/2/4.yaml" - it "default location for lts-15.1" $ do - let sn = LTS 15 1 + it "default location for lts-22.9" $ do + let sn = LTS 22 9 loc <- runPantryAppClean $ completeSnapshotLocation $ RSLSynonym sn sameUrl loc (defaultSnapshotLocation sn) - "https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/15/1.yaml" + "https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/9.yaml"