CI: refactor Nim compiler caching (#33)

This commit is contained in:
Ștefan Talpalaru 2021-06-03 02:08:23 +02:00 committed by GitHub
parent 67ebdfa801
commit d790c42206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 52 deletions

View File

@ -1,4 +1,4 @@
name: nim-secp256k1 CI name: CI
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
@ -7,38 +7,18 @@ jobs:
fail-fast: false fail-fast: false
max-parallel: 20 max-parallel: 20
matrix: matrix:
branch: [master] test_lang: [c, cpp]
target: target:
- os: linux - os: linux
cpu: amd64 cpu: amd64
TEST_LANG: c
- os: linux
cpu: amd64
TEST_LANG: cpp
- os: linux - os: linux
cpu: i386 cpu: i386
TEST_LANG: c
- os: linux
cpu: i386
TEST_LANG: cpp
- os: macos - os: macos
cpu: amd64 cpu: amd64
TEST_LANG: c
- os: macos
cpu: amd64
TEST_LANG: cpp
- os: windows - os: windows
cpu: amd64 cpu: amd64
TEST_LANG: c
- os: windows
cpu: amd64
TEST_LANG: cpp
- os: windows - os: windows
cpu: i386 cpu: i386
TEST_LANG: c
- os: windows
cpu: i386
TEST_LANG: cpp
include: include:
- target: - target:
os: linux os: linux
@ -50,7 +30,7 @@ jobs:
os: windows os: windows
builder: windows-2019 builder: windows-2019
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.target.TEST_LANG }} (${{ matrix.branch }})' name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.test_lang }}'
runs-on: ${{ matrix.builder }} runs-on: ${{ matrix.builder }}
steps: steps:
- name: Checkout nim-secp256k1 - name: Checkout nim-secp256k1
@ -145,11 +125,10 @@ jobs:
id: nim-cache id: nim-cache
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: nim path: NimBinaries
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}' key: 'NimBinaries-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}'
- name: Build Nim and associated tools - name: Build Nim and associated tools
if: steps.nim-cache.outputs.cache-hit != 'true'
shell: bash shell: bash
run: | run: |
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
@ -164,23 +143,11 @@ jobs:
MAKE_CMD="make" MAKE_CMD="make"
fi 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 CC=gcc bash build_nim.sh nim csources dist/nimble NimBinaries
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
# clean up to save cache space
cd nim
rm koch
rm -rf nimcache
rm -rf csources
rm -rf tests
rm -rf dist
rm -rf .git
- name: Setup environment
shell: bash
run: echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
- name: Run nim-secp256k1 tests - name: Run nim-secp256k1 tests
shell: bash shell: bash
working-directory: nim-secp256k1 working-directory: nim-secp256k1
run: | run: |
nimble install -y --depsOnly nimble install -y --depsOnly
env TEST_LANG="${{ matrix.target.TEST_LANG }}" nimble test env TEST_LANG="${{ matrix.test_lang }}" nimble test

View File

@ -5,7 +5,7 @@
[![License: Apache](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![License: Apache](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![Stability: experimental](https://img.shields.io/badge/stability-experimental-orange.svg) ![Stability: experimental](https://img.shields.io/badge/stability-experimental-orange.svg)
![Github action](https://github.com/status-im/nim-secp256k1/workflows/nim-secp256k1%20CI/badge.svg) ![Github action](https://github.com/status-im/nim-secp256k1/workflows/CI/badge.svg)
# Introduction # Introduction

View File

@ -11,18 +11,16 @@ requires "nim >= 1.2.0"
requires "stew" requires "stew"
requires "nimcrypto" requires "nimcrypto"
proc getLang(): string = proc test(env, path: string) =
result = "c" # Compilation language is controlled by TEST_LANG
var lang = "c"
if existsEnv"TEST_LANG": if existsEnv"TEST_LANG":
result = getEnv"TEST_LANG" lang = getEnv"TEST_LANG"
proc test(name: string, lang: string = "c") = exec "nim " & lang & " " & env &
if not dirExists "build": " -r -f --hints:off --skipParentCfg " & path
mkDir "build"
--run
--threads:on
switch("out", ("./build/" & name))
setCommand lang, "tests/" & name & ".nim"
task test, "Tests": task test, "Tests":
test "all_tests", getLang() test "--threads:on", "tests/all_tests"
test "--threads:off", "tests/all_tests"