Compare commits
2 Commits
v1.3.0.0
...
5ac02fc505
Author | SHA1 | Date | |
---|---|---|---|
5ac02fc505 | |||
9b11300d23
|
3
.gitea/deploy.awk
Normal file
3
.gitea/deploy.awk
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
END {
|
||||||
|
system("cabal upload --username belka --password "ENVIRON["HACKAGE_PASSWORD"]" "$0)
|
||||||
|
}
|
@ -9,28 +9,14 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
audit:
|
audit:
|
||||||
runs-on: haskell
|
runs-on: buildenv
|
||||||
steps:
|
steps:
|
||||||
- name: Set up environment
|
|
||||||
run: |
|
|
||||||
apt-get update -y
|
|
||||||
apt-get upgrade -y
|
|
||||||
apt-get install -y nodejs pkg-config
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- run: hlint -- src tests
|
||||||
run: |
|
|
||||||
cabal update
|
|
||||||
cabal install hlint "--constraint=hlint ==3.8"
|
|
||||||
- run: cabal exec hlint -- src tests
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: haskell
|
runs-on: buildenv
|
||||||
steps:
|
steps:
|
||||||
- name: Set up environment
|
|
||||||
run: |
|
|
||||||
apt-get update -y
|
|
||||||
apt-get upgrade -y
|
|
||||||
apt-get install -y nodejs pkg-config
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: cabal update
|
run: cabal update
|
||||||
@ -39,13 +25,8 @@ jobs:
|
|||||||
- run: cabal test --test-show-details=streaming
|
- run: cabal test --test-show-details=streaming
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
runs-on: haskell
|
runs-on: buildenv
|
||||||
steps:
|
steps:
|
||||||
- name: Set up environment
|
|
||||||
run: |
|
|
||||||
apt-get update -y
|
|
||||||
apt-get upgrade -y
|
|
||||||
apt-get install -y nodejs pkg-config
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: cabal update
|
run: cabal update
|
||||||
|
@ -7,17 +7,11 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: haskell
|
runs-on: buildenv
|
||||||
steps:
|
steps:
|
||||||
- name: Set up environment
|
|
||||||
run: |
|
|
||||||
apt-get update -y
|
|
||||||
apt-get upgrade -y
|
|
||||||
apt-get install -y nodejs pkg-config
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Upload a candidate
|
- name: Upload a candidate
|
||||||
env:
|
env:
|
||||||
HACKAGE_PASSWORD: ${{ secrets.HACKAGE_PASSWORD }}
|
HACKAGE_PASSWORD: ${{ secrets.HACKAGE_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
cabal sdist
|
cabal sdist | awk -f .gitea/deploy.awk
|
||||||
cabal upload --username belka --password ${HACKAGE_PASSWORD}
|
|
||||||
|
@ -85,6 +85,7 @@ test-suite graphql-test
|
|||||||
Language.GraphQL.Execute.CoerceSpec
|
Language.GraphQL.Execute.CoerceSpec
|
||||||
Language.GraphQL.Execute.OrderedMapSpec
|
Language.GraphQL.Execute.OrderedMapSpec
|
||||||
Language.GraphQL.ExecuteSpec
|
Language.GraphQL.ExecuteSpec
|
||||||
|
Language.GraphQL.THSpec
|
||||||
Language.GraphQL.Type.OutSpec
|
Language.GraphQL.Type.OutSpec
|
||||||
Language.GraphQL.Validate.RulesSpec
|
Language.GraphQL.Validate.RulesSpec
|
||||||
Schemas.HeroSchema
|
Schemas.HeroSchema
|
||||||
|
@ -12,17 +12,26 @@ import Language.Haskell.TH (Exp(..), Lit(..))
|
|||||||
|
|
||||||
stripIndentation :: String -> String
|
stripIndentation :: String -> String
|
||||||
stripIndentation code = reverse
|
stripIndentation code = reverse
|
||||||
$ dropNewlines
|
$ dropWhile isLineBreak
|
||||||
$ reverse
|
$ reverse
|
||||||
$ unlines
|
$ unlines
|
||||||
$ indent spaces <$> lines withoutLeadingNewlines
|
$ indent spaces <$> lines' withoutLeadingNewlines
|
||||||
where
|
where
|
||||||
indent 0 xs = xs
|
indent 0 xs = xs
|
||||||
indent count (' ' : xs) = indent (count - 1) xs
|
indent count (' ' : xs) = indent (count - 1) xs
|
||||||
indent _ xs = xs
|
indent _ xs = xs
|
||||||
withoutLeadingNewlines = dropNewlines code
|
withoutLeadingNewlines = dropWhile isLineBreak code
|
||||||
dropNewlines = dropWhile $ flip any ['\n', '\r'] . (==)
|
|
||||||
spaces = length $ takeWhile (== ' ') withoutLeadingNewlines
|
spaces = length $ takeWhile (== ' ') withoutLeadingNewlines
|
||||||
|
lines' "" = []
|
||||||
|
lines' string =
|
||||||
|
let (line, rest) = break isLineBreak string
|
||||||
|
reminder =
|
||||||
|
case rest of
|
||||||
|
[] -> []
|
||||||
|
'\r' : '\n' : strippedString -> lines strippedString
|
||||||
|
_ : strippedString -> lines strippedString
|
||||||
|
in line : reminder
|
||||||
|
isLineBreak = flip any ['\n', '\r'] . (==)
|
||||||
|
|
||||||
-- | Removes leading and trailing newlines. Indentation of the first line is
|
-- | Removes leading and trailing newlines. Indentation of the first line is
|
||||||
-- removed from each line of the string.
|
-- removed from each line of the string.
|
||||||
|
23
tests/Language/GraphQL/THSpec.hs
Normal file
23
tests/Language/GraphQL/THSpec.hs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{- This Source Code Form is subject to the terms of the Mozilla Public License,
|
||||||
|
v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||||
|
obtain one at https://mozilla.org/MPL/2.0/. -}
|
||||||
|
|
||||||
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
|
|
||||||
|
module Language.GraphQL.THSpec
|
||||||
|
( spec
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Language.GraphQL.TH (gql)
|
||||||
|
import Test.Hspec (Spec, describe, it, shouldBe)
|
||||||
|
|
||||||
|
spec :: Spec
|
||||||
|
spec =
|
||||||
|
describe "gql" $
|
||||||
|
it "replaces CRNL with NL" $
|
||||||
|
let expected = "line1\nline2"
|
||||||
|
actual = [gql|
|
||||||
|
line1
|
||||||
|
line2
|
||||||
|
|]
|
||||||
|
in actual `shouldBe` expected
|
Reference in New Issue
Block a user