Normalise nimble (#36)

* normalise nimble file, ci / deprecation fixes

* other deprecations
This commit is contained in:
Jacek Sieka 2022-11-23 16:27:20 +01:00 • committed by GitHub
commit 5ec974ed1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 48 deletions

View file

@ -6,6 +6,10 @@ on:
pull_request:
workflow_dispatch:
concurrency: # Cancel stale PR builds (but not push builds)
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
build:
strategy:
@ -43,10 +47,10 @@ jobs:
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})'
runs-on: ${{ matrix.builder }}
continue-on-error: ${{ matrix.branch == 'version-1-6' || matrix.branch == 'devel' }}
continue-on-error: ${{ matrix.branch == 'devel' }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install build dependencies (Linux i386)
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
@ -94,23 +98,23 @@ jobs:
id: windows-dlls-cache
uses: actions/cache@v2
with:
path: external/dlls
key: 'dlls'
path: external/dlls-${{ matrix.target.cpu }}
key: 'dlls-${{ matrix.target.cpu }}'
- name: Install DLL dependencies (Windows)
- name: Install DLLs dependencies (Windows)
if: >
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
run: |
mkdir external
mkdir -p external
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
7z x external/windeps.zip -oexternal/dlls
7z x -y external/windeps.zip -oexternal/dlls-${{ matrix.target.cpu }}
- name: Path to cached dependencies (Windows)
if: >
runner.os == 'Windows'
run: |
echo '${{ github.workspace }}'"/external/dlls" >> $GITHUB_PATH
echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
- name: Derive environment variables
run: |
@ -152,5 +156,5 @@ jobs:
nim --version
nimble --version
nimble install -y --depsOnly
env TEST_LANG="c" nimble test
env TEST_LANG="cpp" nimble test
env NIMLANG=c nimble test
env NIMLANG=cpp nimble test

View file

@ -12,37 +12,27 @@ requires "nim >= 1.2.0",
"chronos",
"unittest2"
### Helper functions
proc test(args, path: string) =
# Compilation language is controlled by TEST_LANG
let lang = getEnv("TEST_LANG", "c")
let nimc = getEnv("NIMC", "nim") # Which nim compiler to use
let lang = getEnv("NIMLANG", "c") # Which backend (c/cpp/js)
let flags = getEnv("NIMFLAGS", "") # Extra flags for the compiler
let verbose = getEnv("V", "") notin ["", "0"]
# 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"
let styleCheckStyle = if (NimMajor, NimMinor) < (1, 6): "hint" else: "error"
let cfg =
" --styleCheck:usages --styleCheck:" & styleCheckStyle &
(if verbose: "" else: " --verbosity:0 --hints:off") &
" --skipParentCfg --skipUserCfg --outdir:build --nimcache:build/nimcache -f"
var common_args = "-r -f " & getEnv("NIMFLAGS") & " --hints:off --styleCheck:usages --styleCheck:" & styleCheckStyle
proc build(args, path: string) =
exec nimc & " " & lang & " " & cfg & " " & flags & " " & args & " " & path
if getEnv("NIMBUS_ENV_DIR") != "":
common_args &= " --skipParentCfg"
exec "nim " & lang & " " & args &
" -d:asyncBackend=none " & common_args & " " & path
exec "nim " & lang & " " & args &
" -d:asyncBackend=chronos " & common_args & " " & path
# TODO std backend is broken / untested
# exec "nim " & lang & " " & args &
# " -d:asyncBackend=asyncdispatch " & common_args & " " & path
proc run(args, path: string) =
build args & " -r", path
task test, "Run all tests":
test "-d:debug --threads:off", "tests/all_tests"
test "-d:release --threads:off", "tests/all_tests"
test "-d:danger --threads:off", "tests/all_tests"
test "-d:debug --threads:on", "tests/all_tests"
test "-d:release --threads:on", "tests/all_tests"
test "-d:danger --threads:on", "tests/all_tests"
# TODO asyncdispatch backend is broken / untested
for backend in ["-d:asyncBackend=none", "-d:asyncBackend=chronos"]:
for threads in ["--threads:off", "--threads:on"]:
for mode in ["-d:debug", "-d:release", "-d:danger"]:
run backend & " " & threads & " " & mode, "tests/all_tests"

View file

@ -1,6 +1,6 @@
import
deques,
stew/[ptrops, ranges/ptr_arith],
stew/ptrops,
async_backend
export

View file

@ -1,6 +1,6 @@
import
os, memfiles, options,
stew/[ptrops, ranges/ptr_arith],
stew/[ptrops],
async_backend, buffers
export

View file

@ -8,7 +8,7 @@
import
deques, typetraits,
stew/[ptrops, strings, ranges/ptr_arith],
stew/[ptrops, strings],
buffers, async_backend
export

View file

@ -126,7 +126,7 @@ const
NewLines* = {'\r', '\n'}
Digits* = {'0'..'9'}
proc readLine*(s: InputStream, keepEol = false): TaintedString {.fsMultiSync.} =
proc readLine*(s: InputStream, keepEol = false): string {.fsMultiSync.} =
fsAssert readableNow(s)
while s.readable:
@ -145,7 +145,7 @@ proc readLine*(s: InputStream, keepEol = false): TaintedString {.fsMultiSync.} =
result.add s.read.char
proc readUntil*(s: InputStream,
sep: openArray[char]): Option[TaintedString] =
sep: openArray[char]): Option[string] =
fsAssert readableNow(s)
var res = ""
while s.readable(sep.len):
@ -153,14 +153,14 @@ proc readUntil*(s: InputStream,
return some(res)
res.add s.read.char
template nextLine*(sp: InputStream, keepEol = false): Option[TaintedString] =
template nextLine*(sp: InputStream, keepEol = false): Option[string] =
let s = sp
if s.readable:
some readLine(s, keepEol)
else:
none string
iterator lines*(s: InputStream, keepEol = false): TaintedString =
iterator lines*(s: InputStream, keepEol = false): string =
while s.readable:
yield readLine(s, keepEol)

View file

@ -4,7 +4,7 @@ import
os, unittest2, strutils, random,
../faststreams, ../faststreams/textio
setCurrentDir getAppDir()
setCurrentDir currentSourcePath.parentDir
proc str(bytes: openArray[byte]): string =
result = newStringOfCap(bytes.len)

View file

@ -2,7 +2,7 @@
import
os, unittest2, random, strformat,
stew/ranges/ptr_arith,
stew/ptrops,
../faststreams, ../faststreams/textio
proc bytes(s: string): seq[byte] =