Skip to content

Commit

Permalink
using multiple nim version in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Aug 2, 2022
1 parent d2635d0 commit 4ef25a2
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 18 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
max-parallel: 20
matrix:
test_lang: [c]
branch: [version-1-2, version-1-4, version-1-6, devel]
target:
- os: linux
cpu: amd64
Expand All @@ -30,7 +31,7 @@ jobs:
os: windows
builder: windows-2019

name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.test_lang }}'
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.test_lang }}-(Nim ${{ matrix.branch }})'
runs-on: ${{ matrix.builder }}
steps:
- name: Checkout nim-graphql
Expand Down Expand Up @@ -143,7 +144,9 @@ jobs:
else
MAKE_CMD="make"
fi
env MAKE="$MAKE_CMD -j2" ARCH_OVERRIDE=$PLATFORM CC=gcc bash build_nim.sh nim csources dist/nimble NimBinaries
env MAKE="$MAKE_CMD -j2" ARCH_OVERRIDE=$PLATFORM NIM_COMMIT=${{ matrix.branch }} \
QUICK_AND_DIRTY_COMPILER=1 QUICK_AND_DIRTY_NIMBLE=1 CC=gcc \
bash build_nim.sh nim csources dist/nimble NimBinaries
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
- name: Run nim-graphql tests
Expand Down
12 changes: 11 additions & 1 deletion graphql.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ requires "nim >= 1.2.0",
"https://github.com/status-im/nim-unittest2"

proc test(env, path: string, shouldRun = true) =
# nnkArglist was changed to nnkArgList, so can't always use --styleCheck:error
# https://github.com/nim-lang/Nim/pull/17529
# https://github.com/nim-lang/Nim/pull/19822
let styleCheckStyle =
if (NimMajor, NimMinor) < (1, 6):
"hint"
else:
"error"

# Compilation language is controlled by TEST_LANG
var lang = "c"
if existsEnv"TEST_LANG":
Expand All @@ -33,7 +42,8 @@ proc test(env, path: string, shouldRun = true) =
let run = if shouldRun: " -r" else: ""

exec "nim " & lang & " " & env & run &
" --styleCheck:usages --styleCheck:error --hints:off --warnings:off " & path
" --styleCheck:usages --styleCheck:" & styleCheckStyle &
" --hints:off --warnings:off " & path

task test, "Run all tests":
test "--threads:off", "tests/test_all"
Expand Down
18 changes: 9 additions & 9 deletions graphql/private/utf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const
Utf16Shift = 10
Utf16Base = 0x0010000
Utf16Mask = 0x3FF
Utf16Maxbmp= 0xFFFF
Utf16MaxBmp= 0xFFFF
MaxUtf = 0x10FFFF

DefaultReplacement* = 0xFFFD
Expand Down Expand Up @@ -93,7 +93,7 @@ proc utf*(_: type Utf16, c1, c2: int): int =
((c1 - highBegin) shl Utf16Shift) + (c2 - lowBegin) + Utf16Base

proc inc*(_: type Utf16, cp: int, res: var int): bool =
if cp <= Utf16Maxbmp:
if cp <= Utf16MaxBmp:
if cp >= highBegin and cp <= lowBegin:
return false
else:
Expand Down Expand Up @@ -164,19 +164,19 @@ proc utf8Len*(_: type Utf16, text: openArray[uint16]): Result[int, string] =
if c1 >= highBegin and c1 <= highEnd:
inc i
if i >= text.len:
return err(InvalidUtf16)
return err(InvalidUTF16)
# surrogate pairs
let c2 = text[i]
if c2 < lowBegin or c2 > lowEnd:
return err(InvalidUtf16)
return err(InvalidUTF16)
let cp = Utf16.utf(c1, c2)
if not Utf8.inc(cp, res):
return err(InvalidUtf16)
return err(InvalidUTF16)
elif c1 >= lowBegin and c1 <= lowEnd:
return err(InvalidUtf16)
return err(InvalidUTF16)
inc i
if not Utf8.inc(c1, res):
return err(InvalidUtf16)
return err(InvalidUTF16)

ok(res)

Expand Down Expand Up @@ -237,7 +237,7 @@ proc append*(_: type Utf8, text: var (string | seq[byte]), c1, c2: int): bool =
Utf8.append(text, Utf16.utf(c1, c2))

proc append*(_: type Utf16, text: var seq[uint16], cp: int): bool =
if cp <= Utf16Maxbmp:
if cp <= Utf16MaxBmp:
if cp >= highBegin and cp <= lowBegin:
return false
else:
Expand Down Expand Up @@ -318,7 +318,7 @@ type
lo*: uint16

proc toPair*(_: type Utf16, cp: int): Utf16Pair =
if cp <= Utf16Maxbmp:
if cp <= Utf16MaxBmp:
if cp >= highBegin and cp <= lowBegin:
Utf16Pair(state: Utf16Error)
else:
Expand Down
3 changes: 2 additions & 1 deletion graphql/test_common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ proc runSuite(ctx: GraphqlRef, savePoint: NameCounter, fileName: string, counter
let parts = splitFile(fileName)
let cases = Toml.loadFile(fileName, TestCase)
suite parts.name:
for unit in cases.units:
for x in cases.units:
let unit = x # prevent nim >= 1.6 cannot capture lent
test unit.name:
if unit.skip:
ctx.purgeQueries(true)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_httpserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ proc runSuite(client: GraphqlHttpClientRef, fileName: string, counter: Counter)
let parts = splitFile(fileName)
let cases = Toml.loadFile(fileName, TestCase)
suite parts.name:
for unit in cases.units:
for x in cases.units:
let unit = x # prevent nim >= 1.6 cannot capture lent
test unit.name:
if unit.skip:
skip()
Expand Down Expand Up @@ -211,7 +212,8 @@ when isMainModule:
let cases = Toml.loadFile(fileName, TestCase)
let server = createServer(serverAddress)
server.start()
for unit in cases.units:
for x in cases.units:
let unit = x # prevent nim >= 1.6 cannot capture lent
if unit.name != conf.unit:
continue
test unit.name:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_parser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ proc suite3() =
for fileName in walkDirRec("tests" / "schemas"):
fileNames.add fileName

for fileName in fileNames:
for x in fileNames:
let fileName = x # prevent nim >= 1.6 cannot capture lent
test fileName:
check runGoodDoc(fileName) == true

Expand Down
3 changes: 2 additions & 1 deletion tests/test_schemaintros.nim
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ proc main() =
continue
fileNames.add fileName

for fileName in fileNames:
for x in fileNames:
let fileName = x # prevent nim >= 1.6 cannot capture lent
let parts = splitFile(fileName)
test parts.name:
ctx.runValidator(fileName, testStatusIMPL)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_validation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ proc runSuite(ctx: GraphqlRef, savePoint: NameCounter, fileName: string, counter
let parts = splitFile(fileName)
let cases = Toml.loadFile(fileName, TestCase)
suite parts.name:
for unit in cases.units:
for x in cases.units:
let unit = x # prevent nim >= 1.6 cannot capture lent
test unit.name:
if unit.skip:
skip()
Expand Down

0 comments on commit 4ef25a2

Please sign in to comment.