build: setup nimbus-build-system and basic project structure
This commit is contained in:
parent
27b257abeb
commit
8753fdd53a
|
@ -0,0 +1 @@
|
||||||
|
* text=auto eol=lf
|
|
@ -0,0 +1,77 @@
|
||||||
|
name: Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
env:
|
||||||
|
NPROC: 2
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- {
|
||||||
|
icon: 🏁,
|
||||||
|
os: windows,
|
||||||
|
shell: msys2
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
icon: 🍎,
|
||||||
|
os: macos,
|
||||||
|
shell: bash --noprofile --norc -eo pipefail
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
icon: 🐧,
|
||||||
|
os: ubuntu,
|
||||||
|
shell: bash --noprofile --norc -eo pipefail
|
||||||
|
}
|
||||||
|
name: ${{ matrix.platform.icon }} ${{ matrix.platform.os }}
|
||||||
|
runs-on: ${{ matrix.platform.os }}-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: ${{ matrix.platform.shell }} {0}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Install awk (gawk) and coreutils via Homebrew
|
||||||
|
if: matrix.platform.os == 'macos'
|
||||||
|
run: |
|
||||||
|
brew install coreutils gawk
|
||||||
|
|
||||||
|
- uses: msys2/setup-msys2@v2
|
||||||
|
if: matrix.platform.os == 'windows'
|
||||||
|
with:
|
||||||
|
msystem: MINGW64
|
||||||
|
update: true
|
||||||
|
install: >
|
||||||
|
base-devel
|
||||||
|
git
|
||||||
|
mingw-w64-x86_64-toolchain
|
||||||
|
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Calculate cache key from submodules tree
|
||||||
|
id: calc-cache-key
|
||||||
|
run: |
|
||||||
|
echo "::set-output name=hash::$(git submodule foreach --quiet --recursive 'git rev-parse $(git rev-parse --abbrev-ref HEAD)' | sha1sum | awk '{print $1}')"
|
||||||
|
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: vendor/nimbus-build-system/vendor/Nim/bin
|
||||||
|
key: ${{ matrix.platform.os }}-${{ steps.calc-cache-key.outputs.hash }}
|
||||||
|
|
||||||
|
- name: Install and build dependencies
|
||||||
|
run: |
|
||||||
|
make -j${NPROC} NIMFLAGS="--parallelBuild:${NPROC}" V=1 update
|
||||||
|
make -j${NPROC} NIMFLAGS="--parallelBuild:${NPROC}" V=1 deps
|
||||||
|
|
||||||
|
- name: Build and run tests
|
||||||
|
run: |
|
||||||
|
make -j${NPROC} NIMFLAGS="--parallelBuild:${NPROC}" V=1 test
|
|
@ -0,0 +1,9 @@
|
||||||
|
.DS_Store
|
||||||
|
/.idea
|
||||||
|
/.update.timestamp
|
||||||
|
/.vscode
|
||||||
|
/task_runner.nims
|
||||||
|
/nimcache
|
||||||
|
/test/build
|
||||||
|
/vendor/.nimble
|
||||||
|
TODO
|
|
@ -0,0 +1,14 @@
|
||||||
|
[submodule "vendor/nimbus-build-system"]
|
||||||
|
path = vendor/nimbus-build-system
|
||||||
|
url = https://github.com/status-im/nimbus-build-system.git
|
||||||
|
branch = master
|
||||||
|
ignore = dirty
|
||||||
|
[submodule "vendor/nim-chronos"]
|
||||||
|
path = vendor/nim-chronos
|
||||||
|
url = https://github.com/status-im/nim-chronos.git
|
||||||
|
[submodule "vendor/nim-stew"]
|
||||||
|
path = vendor/nim-stew
|
||||||
|
url = https://github.com/status-im/nim-stew.git
|
||||||
|
[submodule "vendor/nim-bearssl"]
|
||||||
|
path = vendor/nim-bearssl
|
||||||
|
url = https://github.com/status-im/nim-bearssl.git
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020 Status Research & Development GmbH
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,59 @@
|
||||||
|
SHELL := bash # the shell used internally by "make"
|
||||||
|
|
||||||
|
# used inside the included makefiles
|
||||||
|
BUILD_SYSTEM_DIR := vendor/nimbus-build-system
|
||||||
|
|
||||||
|
# we don't want an error here, so we can handle things later, in the ".DEFAULT" target
|
||||||
|
-include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk
|
||||||
|
|
||||||
|
.PHONY: \
|
||||||
|
all \
|
||||||
|
clean \
|
||||||
|
deps \
|
||||||
|
test \
|
||||||
|
update
|
||||||
|
|
||||||
|
ifeq ($(NIM_PARAMS),)
|
||||||
|
# "variables.mk" was not included, so we update the submodules.
|
||||||
|
GIT_SUBMODULE_UPDATE := git submodule update --init --recursive
|
||||||
|
.DEFAULT:
|
||||||
|
+@ echo -e "Git submodules not found. Running '$(GIT_SUBMODULE_UPDATE)'.\n"; \
|
||||||
|
$(GIT_SUBMODULE_UPDATE) && \
|
||||||
|
echo
|
||||||
|
# Now that the included *.mk files appeared, and are newer than this file, Make will restart itself:
|
||||||
|
# https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles
|
||||||
|
#
|
||||||
|
# After restarting, it will execute its original goal, so we don't have to start a child Make here
|
||||||
|
# with "$(MAKE) $(MAKECMDGOALS)". Isn't hidden control flow great?
|
||||||
|
|
||||||
|
else # "variables.mk" was included. Business as usual until the end of this file.
|
||||||
|
|
||||||
|
# default target, because it's the first one that doesn't start with '.'
|
||||||
|
all: test
|
||||||
|
|
||||||
|
# must be included after the default target
|
||||||
|
-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
# is Windows_NT on XP, 2000, 7, Vista, 10...
|
||||||
|
detected_OS := Windows
|
||||||
|
else ifeq ($(strip $(shell uname)),Darwin)
|
||||||
|
detected_OS := macOS
|
||||||
|
else
|
||||||
|
# e.g. Linux
|
||||||
|
detected_OS := $(strip $(shell uname))
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean: | clean-common clean-build-dirs
|
||||||
|
|
||||||
|
clean-build-dirs:
|
||||||
|
rm -rf test/build
|
||||||
|
|
||||||
|
deps: | deps-common
|
||||||
|
|
||||||
|
update: | update-common
|
||||||
|
|
||||||
|
test: | deps
|
||||||
|
$(ENV_SCRIPT) nimble tests
|
||||||
|
|
||||||
|
endif # "variables.mk" was not included
|
|
@ -1 +1,6 @@
|
||||||
# nim-task-runner
|
# nim-task-runner
|
||||||
|
[![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)
|
||||||
|
[![Tests (GitHub Actions)](https://github.com/status-im/nim-task-runner/workflows/Tests/badge.svg?branch=master)](https://github.com/status-im/nim-task-runner/actions?query=workflow%3ATests+branch%3Amaster)
|
||||||
|
|
||||||
|
General purpose background task runner for Nim programs
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# We use ${BASH_SOURCE[0]} instead of $0 to allow sourcing this file
|
||||||
|
# and we fall back to a Zsh-specific special var to also support Zsh.
|
||||||
|
REL_PATH="$(dirname ${BASH_SOURCE[0]:-${(%):-%x}})"
|
||||||
|
ABS_PATH="$(cd ${REL_PATH}; pwd)"
|
||||||
|
source ${ABS_PATH}/vendor/nimbus-build-system/scripts/env.sh
|
|
@ -0,0 +1,2 @@
|
||||||
|
proc foo*(): string =
|
||||||
|
"bar"
|
|
@ -0,0 +1,44 @@
|
||||||
|
mode = ScriptMode.Verbose
|
||||||
|
|
||||||
|
version = "0.1.0"
|
||||||
|
author = "Status Research & Development GmbH"
|
||||||
|
description = "General purpose background task runner for Nim programs"
|
||||||
|
license = "MIT"
|
||||||
|
skipDirs = @["test"]
|
||||||
|
|
||||||
|
requires "nim >= 1.2.0",
|
||||||
|
"chronos"
|
||||||
|
|
||||||
|
import strutils
|
||||||
|
|
||||||
|
proc buildAndRunTest(name: string,
|
||||||
|
srcDir = "test/",
|
||||||
|
outDir = "test/build/",
|
||||||
|
params = "",
|
||||||
|
cmdParams = "",
|
||||||
|
lang = "c") =
|
||||||
|
rmDir outDir
|
||||||
|
mkDir outDir
|
||||||
|
# allow something like "nim test --verbosity:0 --hints:off beacon_chain.nims"
|
||||||
|
var extra_params = params
|
||||||
|
for i in 2..<paramCount():
|
||||||
|
extra_params &= " " & paramStr(i)
|
||||||
|
exec "nim " &
|
||||||
|
lang &
|
||||||
|
" --debugger:native" &
|
||||||
|
" --define:chronicles_line_numbers" &
|
||||||
|
" --define:debug" &
|
||||||
|
" --nimcache:nimcache/test/" & name &
|
||||||
|
" --out:" & outDir & name &
|
||||||
|
" --threads:on" &
|
||||||
|
" --tlsEmulation:off" &
|
||||||
|
" " &
|
||||||
|
extra_params &
|
||||||
|
" " &
|
||||||
|
srcDir & name & ".nim" &
|
||||||
|
" " &
|
||||||
|
cmdParams
|
||||||
|
exec outDir & name
|
||||||
|
|
||||||
|
task tests, "Run all tests":
|
||||||
|
buildAndRunTest "all_tests"
|
|
@ -0,0 +1,2 @@
|
||||||
|
import
|
||||||
|
./test_task_runner
|
|
@ -0,0 +1,12 @@
|
||||||
|
import chronos, unittest
|
||||||
|
|
||||||
|
template asyncTest*(name, body: untyped) =
|
||||||
|
test name:
|
||||||
|
proc scenario {.async.} = body
|
||||||
|
waitFor scenario()
|
||||||
|
|
||||||
|
template procSuite*(name, body: untyped) =
|
||||||
|
proc suitePayload =
|
||||||
|
suite name:
|
||||||
|
body
|
||||||
|
suitePayload()
|
|
@ -0,0 +1,11 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import
|
||||||
|
../task_runner,
|
||||||
|
./test_helpers
|
||||||
|
|
||||||
|
suite "task_runner test stub":
|
||||||
|
test "foo test":
|
||||||
|
|
||||||
|
check:
|
||||||
|
foo() == "bar"
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit ba5f4687987817902c2727e30b35cb5ad1e61203
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 46c0bf3c5aff131ac437a88c00aa112133c94d54
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 1401c34374fe7606dbf1252e361725415890f5f0
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit e2de003ce634deca72dab3b3c79426698e7b8579
|
Loading…
Reference in New Issue