Skip to content

Commit c3c5160

Browse files
Merge #152: A bunch of fixes to sync with deps
* `saltine` * `tasty-hspec` * `attoparsec` * Splitting Core & Remote Cabal GitHub CI workflows
2 parents db71ece + bd00d38 commit c3c5160

File tree

9 files changed

+98
-27
lines changed

9 files changed

+98
-27
lines changed

.github/workflows/Cabal-Linux.yml renamed to .github/workflows/Cabal-Linux-Remote.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
21-
packageRoot: [ hnix-store-core, hnix-store-remote ]
21+
packageRoot: [ hnix-store-remote ]
2222
ghc: [ "8.10", "8.4" ]
2323
defaults:
2424
run:
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: "Hackage, Cabal, Linux"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
schedule:
9+
- cron: "45 02 * * *"
10+
11+
env:
12+
cabalConfig: --enable-tests --disable-optimization --enable-deterministic
13+
14+
jobs:
15+
16+
build10:
17+
name: "GHC"
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
# Separation between Core & Store workflows made deliberately, so when one fixes Core, CI does not falls because of the Hackage Core Remote builds with.
22+
# Also singleton also use is deliberate, it allows to reference the value in the further configuration & also leaves a name in the CI & preserves matrix flexibility for the future.
23+
packageRoot: [ hnix-store-core ]
24+
ghc: [ "8.10", "8.4" ]
25+
defaults:
26+
run:
27+
working-directory: "./${{ matrix.packageRoot }}"
28+
steps:
29+
30+
- name: "Git checkout"
31+
uses: actions/checkout@v2
32+
with:
33+
submodules: recursive
34+
35+
- name: "Haskell env setup"
36+
id: HaskEnvSetup
37+
uses: haskell/actions/setup@v1
38+
with:
39+
ghc-version: ${{ matrix.ghc }}
40+
41+
- name: "Repository update"
42+
run: cabal v2-update
43+
44+
- name: "Install additional system packages"
45+
run: sudo apt install libsodium-dev
46+
47+
# NOTE: Freeze is for the caching
48+
- name: "Configuration freeze"
49+
run: cabal v2-freeze $cabalConfig
50+
51+
- name: "Hack: Copy freeze file to the root dir"
52+
run: cp -a cabal.project.freeze ../cabal.project.freeze
53+
54+
- name: "Configuring GitHub cache"
55+
uses: actions/cache@v2
56+
with:
57+
path: |
58+
${{ steps.HaskEnvSetup.outputs.cabal-store }}
59+
dist-newstyle
60+
key: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-${{ matrix.ghc }}-${{ hashFiles( 'cabal.project.freeze' ) }}
61+
restore-keys: ${{ matrix.packageRoot }}-${{ runner.os }}-Cabal-${{ matrix.ghc }}-
62+
63+
- name: "Build"
64+
run: cabal v2-build $cabalConfig
65+
66+
- name: "Tests"
67+
run: cabal v2-test $cabalConfig
68+
69+
- name: "Source distribution file"
70+
if: ${{ matrix.ghc == '8.10' }}
71+
run: cabal v2-sdist

.github/workflows/Cabal-macOS.yml renamed to .github/workflows/Core-Cabal-macOS.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ env:
1313

1414
jobs:
1515

16-
# 2021-03-12: NOTE: Please, enable uncommented working code when `remote` builds on macOS.
1716
build10:
1817
name: "GHC"
1918
runs-on: macos-latest
2019
strategy:
2120
matrix:
2221
packageRoot: [ hnix-store-core ]
23-
# packageRoot: [ hnix-store-core, hnix-store-remote ]
2422
defaults:
2523
run:
2624
working-directory: "./${{ matrix.packageRoot }}"
@@ -43,16 +41,6 @@ jobs:
4341
- name: "Install additional system packages"
4442
run: cabal v2-install tasty-discover
4543

46-
# # Still required for Remote
47-
# - name: "Install Nix"
48-
# uses: cachix/install-nix-action@v12
49-
# if: matrix.packageRoot == 'hnix-store-remote'
50-
51-
# # Remote: Enabling testsuite, because it requires networking in the default Nix environment.
52-
# - name: "Project-specific Cabal configuration"
53-
# if: matrix.packageRoot == 'hnix-store-remote'
54-
# run: echo "cabalConfig=$cabalConfig -f io-testsuite" >> $GITHUB_ENV
55-
5644
# NOTE: Freeze is for the caching
5745
- name: "Configuration freeze"
5846
run: cabal v2-freeze $cabalConfig

hnix-store-core/hnix-store-core.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ test-suite format-tests
109109
, process
110110
, tasty
111111
, tasty-golden
112+
, hspec
112113
, tasty-hspec
113114
, tasty-hunit
114115
, tasty-quickcheck

hnix-store-core/src/System/Nix/Internal/Signature.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Description : Nix-relevant interfaces to NaCl signatures.
33
-}
44
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5+
{-# LANGUAGE CPP #-}
56

67
module System.Nix.Internal.Signature where
78

@@ -11,16 +12,25 @@ import qualified Data.ByteString as Bytes
1112
import Data.Coerce ( coerce )
1213
import Crypto.Saltine.Core.Sign ( PublicKey )
1314
import Crypto.Saltine.Class ( IsEncoding(..) )
14-
import qualified Crypto.Saltine.Internal.ByteSizes as NaClSizes
1515

16+
-- 2021-05-30: NOTE: Please, clean-up these overloads in ~2022
17+
#if MIN_VERSION_saltine(0,2,0)
18+
import qualified Crypto.Saltine.Internal.Sign as NaClSizes
19+
#else
20+
import qualified Crypto.Saltine.Internal.ByteSizes as NaClSizes
21+
#endif
1622

1723
-- | A NaCl signature.
1824
newtype Signature = Signature ByteString
1925
deriving (Eq, Ord)
2026

2127
instance IsEncoding Signature where
2228
decode s
29+
#if MIN_VERSION_saltine(0,2,0)
30+
| Bytes.length s == NaClSizes.sign_bytes = Just $ Signature s
31+
#else
2332
| Bytes.length s == NaClSizes.sign = Just $ Signature s
33+
#endif
2434
| otherwise = Nothing
2535
encode = coerce
2636

hnix-store-core/tests/Derivation.hs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,26 @@ import System.Nix.Derivation ( parseDerivation
1010
, buildDerivation
1111
)
1212

13-
import qualified Data.Attoparsec.Text.Lazy
13+
import qualified Data.Attoparsec.Text
1414
import qualified Data.Text.IO
1515
import qualified Data.Text.Lazy
1616
import qualified Data.Text.Lazy.Builder
1717

1818
processDerivation :: FilePath -> FilePath -> IO ()
1919
processDerivation source dest = do
2020
contents <- Data.Text.IO.readFile source
21-
case
22-
Data.Attoparsec.Text.Lazy.parseOnly
23-
(parseDerivation "/nix/store")
24-
contents
25-
of
26-
Left e -> error e
27-
Right drv ->
21+
either
22+
fail
23+
(\ drv ->
2824
Data.Text.IO.writeFile dest
2925
. Data.Text.Lazy.toStrict
3026
. Data.Text.Lazy.Builder.toLazyText
3127
$ buildDerivation drv
28+
)
29+
(Data.Attoparsec.Text.parseOnly
30+
(parseDerivation "/nix/store")
31+
contents
32+
)
3233

3334
test_derivation :: TestTree
3435
test_derivation =

hnix-store-core/tests/Hash.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import qualified Data.ByteString.Base64.Lazy as B64
1414
import qualified Data.ByteString.Lazy as BSL
1515
import Data.Text (Text)
1616

17-
import Test.Tasty.Hspec
17+
import Test.Hspec
1818
import Test.Tasty.QuickCheck
1919

2020
import System.Nix.Hash

hnix-store-core/tests/NarFormat.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import qualified System.IO.Temp as Temp
3737
import qualified System.Posix.Process as Unix
3838
import qualified System.Process as P
3939
import Test.Tasty as T
40-
import Test.Tasty.Hspec
40+
import Test.Hspec
4141
import qualified Test.Tasty.HUnit as HU
4242
import Test.Tasty.QuickCheck
4343
import qualified Text.Printf as Printf

hnix-store-core/tests/StorePath.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
module StorePath where
77

8-
import qualified Data.Attoparsec.Text.Lazy
8+
import qualified Data.Attoparsec.Text
99

1010
import Test.Tasty.QuickCheck
1111

@@ -24,8 +24,8 @@ prop_storePathRoundtrip' x =
2424

2525
prop_storePathRoundtripParser :: NixLike -> NixLike -> Property
2626
prop_storePathRoundtripParser (_ :: NixLike) = \(NixLike x) ->
27-
(Data.Attoparsec.Text.Lazy.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x
27+
(Data.Attoparsec.Text.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x
2828

2929
prop_storePathRoundtripParser' :: StorePath -> Property
3030
prop_storePathRoundtripParser' x =
31-
(Data.Attoparsec.Text.Lazy.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x
31+
(Data.Attoparsec.Text.parseOnly (pathParser $ storePathRoot x) $ storePathToText x) === Right x

0 commit comments

Comments
 (0)