From 8e1d11c7991df0ca6826827c2846b1ff781ddb39 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Sat, 19 Nov 2022 16:50:01 +0100 Subject: [PATCH] update ci/nimble (#40) * update flag parsing * fix mac CI --- .github/workflows/ci.yml | 19 ++++++++++--------- secp256k1.nimble | 30 +++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea6ad05..da3c05b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: shell: bash - target: os: macos - builder: macos-10.15 + builder: macos-12 shell: bash - target: os: windows @@ -43,6 +43,7 @@ jobs: name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})' runs-on: ${{ matrix.builder }} + continue-on-error: ${{ matrix.branch == 'devel' }} steps: - name: Checkout uses: actions/checkout@v2 @@ -95,23 +96,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: | @@ -153,5 +154,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 diff --git a/secp256k1.nimble b/secp256k1.nimble index ea115a1..6c31dfa 100644 --- a/secp256k1.nimble +++ b/secp256k1.nimble @@ -8,16 +8,28 @@ license = "Apache License 2.0" skipDirs = @["tests"] installDirs = @["secp256k1_wrapper"] -requires "nim >= 1.2.0" -requires "stew" -requires "nimcrypto" +requires "nim >= 1.2.0", + "stew", + "nimcrypto" -proc test(args, path: string) = - # style checking can't generate errors, because nimcrypto mixes styles - exec "nim " & getEnv("TEST_LANG", "c") & " " & getEnv("NIMFLAGS") & " " & args & - " -r -f --hints:off --styleCheck:usages --styleCheck:hint --skipParentCfg " & path +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"] + +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" + +proc build(args, path: string) = + exec nimc & " " & lang & " " & cfg & " " & flags & " " & args & " " & path + +proc run(args, path: string) = + build args & " -r", path task test, "Tests": - test "--threads:on", "tests/all_tests" - test "--threads:off", "tests/all_tests" + run "--threads:on", "tests/all_tests" + run "--threads:off", "tests/all_tests"