mirror of
https://github.com/serokell/xrefcheck.git
synced 2024-09-11 21:47:20 +03:00
[#107] Replace file-embed library with inline config
Problem: At new resolver version we recieved obscure error when tried to cross-compile project to Windows on CI. Changing file-embed version to the old one doesn't help us. Solution: inline content of this file into haskell source, using raw-string-qq library, that helps us to avoid escaping and typing newline characters.
This commit is contained in:
parent
b255445a55
commit
e460301275
@ -7,3 +7,7 @@ License: Unlicense
|
||||
Files: links-tests/ftp_root/**/*
|
||||
Copyright: 2021 Serokell <https://serokell.io>
|
||||
License: Unlicense
|
||||
|
||||
Files: tests/configs/github-config.yaml
|
||||
Copyright: 2019-2021 Serokell <https://serokell.io>
|
||||
License: Unlicense
|
||||
|
@ -17,7 +17,6 @@ description: Please see the README on GitHub at <https://github.com/sero
|
||||
extra-source-files:
|
||||
- README.md
|
||||
- CHANGES.md
|
||||
- src-files/*
|
||||
|
||||
default-extensions:
|
||||
- AllowAmbiguousTypes
|
||||
@ -71,7 +70,7 @@ dependencies:
|
||||
- directory
|
||||
- dlist
|
||||
- filepath
|
||||
- file-embed < 0.14
|
||||
- raw-strings-qq
|
||||
- fmt
|
||||
- ftp-client
|
||||
- Glob
|
||||
@ -126,6 +125,7 @@ tests:
|
||||
dependencies:
|
||||
- firefly
|
||||
- hspec
|
||||
- hspec-expectations
|
||||
- QuickCheck
|
||||
- xrefcheck
|
||||
build-tools:
|
||||
|
@ -23,8 +23,6 @@ import Text.Regex.TDFA qualified as R
|
||||
import Text.Regex.TDFA.ByteString ()
|
||||
import Text.Regex.TDFA.Text qualified as R
|
||||
|
||||
import Data.FileEmbed (embedFile)
|
||||
import System.FilePath ((</>))
|
||||
import Time (KnownRatName, Second, Time, unitsP)
|
||||
|
||||
import Xrefcheck.Core
|
||||
@ -32,6 +30,7 @@ import Xrefcheck.Scan
|
||||
import Xrefcheck.Scanners.Markdown
|
||||
import Xrefcheck.System (RelGlobPattern)
|
||||
import Xrefcheck.Util (aesonConfigOption, postfixFields, (-:))
|
||||
import Xrefcheck.Config.Default
|
||||
|
||||
-- | Overall config.
|
||||
data Config = Config
|
||||
@ -65,14 +64,6 @@ data ScannersConfig = ScannersConfig
|
||||
makeLensesWith postfixFields ''Config
|
||||
makeLensesWith postfixFields ''VerifyConfig
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Default config
|
||||
-----------------------------------------------------------
|
||||
|
||||
defConfigUnfilled :: ByteString
|
||||
defConfigUnfilled =
|
||||
$(embedFile ("src-files" </> "def-config.yaml"))
|
||||
|
||||
-- | Picks raw config with @:PLACEHOLDER:<key>:@ and fills the specified fields
|
||||
-- in it, picking a replacement suitable for the given key. Only strings and lists
|
||||
-- of strings can be filled this way.
|
||||
|
@ -1,8 +1,19 @@
|
||||
# SPDX-FileCopyrightText: 2019-2021 Serokell <https://serokell.io>
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
{- SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
|
||||
-
|
||||
- SPDX-License-Identifier: MPL-2.0
|
||||
-}
|
||||
|
||||
# Parameters of repository traversal.
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Xrefcheck.Config.Default where
|
||||
|
||||
import Universum
|
||||
|
||||
import Text.RawString.QQ
|
||||
|
||||
defConfigUnfilled :: ByteString
|
||||
defConfigUnfilled =
|
||||
[r|# Parameters of repository traversal.
|
||||
traversal:
|
||||
# Files and folders which we pretend do not exist
|
||||
# (so they are neither analyzed nor can be referenced).
|
||||
@ -50,3 +61,4 @@ scanners:
|
||||
#
|
||||
# This affects which anchors are generated for headers.
|
||||
flavor: :PLACEHOLDER:flavor:
|
||||
|]
|
@ -13,6 +13,5 @@ extra-deps:
|
||||
- pretty-terminal-0.1.0.0
|
||||
- roman-numerals-0.5.1.5
|
||||
- with-utf8-1.0.2.3
|
||||
- file-embed-0.0.13.0
|
||||
- th-utilities-0.2.4.0@sha256:ba19cd8441aa43dbaed40e9055bb5a7cbd7cf9e154f5253c6bf9293af8b1f96b,1869
|
||||
- firefly-0.2.1.0@sha256:e9d73486464c3e223ec457e02b30ddd5b550fdbf6292b268c64581e2b07d888b,1519
|
||||
|
@ -25,13 +25,6 @@ packages:
|
||||
hackage: with-utf8-1.0.2.3@sha256:3de710e4aa70856ab0845373bfde4746920fd45b8641bfaa3bd5cd2c200c4704,3051
|
||||
original:
|
||||
hackage: with-utf8-1.0.2.3
|
||||
- completed:
|
||||
pantry-tree:
|
||||
sha256: 6c8f71ca993658844b93a2120f2ff1536400e705890a6fbf0f4e9889ff502649
|
||||
size: 477
|
||||
hackage: file-embed-0.0.13.0@sha256:a819e90b91cab919ffef5895ab6e1b2a44eac395a585f489b0c289a4a12d1c54,1396
|
||||
original:
|
||||
hackage: file-embed-0.0.13.0
|
||||
- completed:
|
||||
pantry-tree:
|
||||
sha256: 8c577d112a8398a5542aa4205b2e8a470a66d57590e6606d752d71e75d7425ea
|
||||
|
@ -13,7 +13,8 @@ import Control.Exception qualified as E
|
||||
import Data.ByteString qualified as BS
|
||||
import Network.HTTP.Types (Status (..))
|
||||
import Test.Hspec (Spec, before, describe, it, shouldBe)
|
||||
import Test.QuickCheck (counterexample, ioProperty, once)
|
||||
import Test.Hspec.Expectations (expectationFailure)
|
||||
import Test.QuickCheck (ioProperty, once)
|
||||
|
||||
import Xrefcheck.Config (Config (..), VerifyConfig (..), defConfig, defConfigText)
|
||||
import Xrefcheck.Core (Flavor (GitHub), allFlavors)
|
||||
@ -34,16 +35,13 @@ spec = do
|
||||
-- stack exec xrefcheck -- dump-config -t GitHub -o tests/configs/github-config.yaml
|
||||
it "Config matches" $
|
||||
\config ->
|
||||
let matches =
|
||||
when (config /= defConfigText GitHub) $
|
||||
expectationFailure $ toString $ unwords
|
||||
[ "Config does not match the expected format."
|
||||
, "Run"
|
||||
, "`stack exec xrefcheck -- dump-config -t GitHub -o tests/configs/github-config.yaml`"
|
||||
, "and verify changes"
|
||||
]
|
||||
in
|
||||
counterexample
|
||||
(toString $ unwords matches)
|
||||
(config == defConfigText GitHub)
|
||||
|
||||
describe "`ignoreAuthFailures` working as expected" $ do
|
||||
let config = (cVerification $ defConfig GitHub) { vcCheckLocalhost = True }
|
||||
|
@ -1,7 +1,3 @@
|
||||
# SPDX-FileCopyrightText: 2019-2021 Serokell <https://serokell.io>
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
# Parameters of repository traversal.
|
||||
traversal:
|
||||
# Files and folders which we pretend do not exist
|
||||
|
Loading…
Reference in New Issue
Block a user