From 027953b3f38bf35d55e5cfd57920108c60a7f7db Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Wed, 30 Oct 2024 10:56:30 +0100 Subject: [PATCH] ci: copy-paste updates from other projects --- .github/workflows/ci.yml | 27 +++++++++++++++++++-------- .gitignore | 1 + bncurve.nimble | 20 +++++++++++++++++++- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ee64f1..ecdad2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,14 @@ name: CI -on: [push, pull_request] +on: + push: + branches: + - master + 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: @@ -7,7 +16,6 @@ jobs: fail-fast: false max-parallel: 20 matrix: - test_lang: [c] target: - os: linux cpu: amd64 @@ -19,6 +27,7 @@ jobs: cpu: amd64 - os: windows cpu: i386 + branch: [version-1-6, version-2-0, version-2-2, devel] include: - target: os: linux @@ -30,14 +39,13 @@ jobs: os: windows builder: windows-latest - name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.test_lang }}' + name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})' runs-on: ${{ matrix.builder }} steps: - - name: Checkout nim-bncurve + - name: Checkout uses: actions/checkout@v4 with: - path: nim-bncurve - submodules: false + submodules: true - name: Install build dependencies (Linux i386) if: runner.os == 'Linux' && matrix.target.cpu == 'i386' @@ -146,9 +154,12 @@ jobs: env MAKE="$MAKE_CMD -j2" ARCH_OVERRIDE=$PLATFORM CC=gcc bash build_nim.sh nim csources dist/nimble NimBinaries echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH - - name: Run nim-bncurve tests + - name: Run tests shell: bash working-directory: nim-bncurve run: | + nim --version + nimble --version + gcc --version nimble install -y --depsOnly - env TEST_LANG="${{ matrix.test_lang }}" nimble test + nimble test diff --git a/.gitignore b/.gitignore index 5dff305..1ca467b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /tests +build/ diff --git a/bncurve.nimble b/bncurve.nimble index 1941738..9940e8d 100644 --- a/bncurve.nimble +++ b/bncurve.nimble @@ -11,6 +11,24 @@ requires "nim >= 1.6.0", "nimcrypto", "stint" +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 cfg = + " --styleCheck:usages --styleCheck:error" & + (if verbose: "" else: " --verbosity:0 --hints:off") & + " --skipParentCfg --skipUserCfg --outdir:build --nimcache:build/nimcache -f" + +proc build(args, path: string) = + exec nimc & " " & lang & " " & cfg & " " & flags & " " & args & " " & path + +proc run(args, path: string) = + build args & " --mm:refc -r", path + if (NimMajor, NimMinor) > (1, 6): + build args & " --mm:orc -r", path + task test, "Run all tests": for tprog in @[ "tests/tarith", @@ -20,4 +38,4 @@ task test, "Run all tests": "tests/tether", "tests/tvectors", ]: - exec "nim c -f -r -d:release --styleCheck:error --styleCheck:usages --threads:on " & tprog + run "--threads:on", tprog