Skip to content

Commit

Permalink
normalise nimble, update CI (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck committed Nov 24, 2022
1 parent b42cd3c commit a7d815e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -30,7 +34,7 @@ jobs:
shell: bash
- target:
os: macos
builder: macos-10.15
builder: macos-12
shell: bash
- target:
os: windows
Expand All @@ -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'
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -156,5 +160,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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ nimcache
*.exe
nimble.develop
nimble.paths
build/
28 changes: 19 additions & 9 deletions json_serialization.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,28 @@ description = "Flexible JSON serialization not relying on run-time type inform
license = "Apache License 2.0"
skipDirs = @["tests"]

requires "nim >= 0.17.0",
requires "nim >= 1.2.0",
"serialization",
"stew"

proc test(args, path: string) =
if not dirExists "build":
mkDir "build"
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"]

exec "nim " & getEnv("TEST_LANG", "c") & " " & getEnv("NIMFLAGS") & " " & args &
" -d:nimOldCaseObjects " &
" -r --hints:off --skipParentCfg --styleCheck:usages --styleCheck:error " & path
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" &
" -d:nimOldCaseObjects"

proc build(args, path: string) =
exec nimc & " " & lang & " " & cfg & " " & flags & " " & args & " " & path

proc run(args, path: string) =
build args & " -r", path

task test, "Run all tests":
test "--threads:off", "tests/test_all"
test "--threads:on", "tests/test_all"
for threads in ["--threads:off", "--threads:on"]:
run threads, "tests/test_all"

0 comments on commit a7d815e

Please sign in to comment.