Skip to content

Commit

Permalink
CI: test with multiple Nim versions
Browse files Browse the repository at this point in the history
- plus Nim-1.6 fix
- and enable Windows
  • Loading branch information
stefantalpalaru committed Nov 18, 2021
1 parent 9aabb5a commit 747e4da
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 74 deletions.
136 changes: 71 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: CI
on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
workflow_dispatch:

jobs:
build:
strategy:
fail-fast: false
max-parallel: 20
matrix:
target:
- os: linux
Expand All @@ -16,27 +20,33 @@ jobs:
cpu: amd64
- os: windows
cpu: amd64
- os: windows
cpu: i386
#- os: windows
#cpu: i386
branch: [version-1-2, version-1-4, version-1-6, devel]
include:
- target:
os: linux
builder: ubuntu-18.04
shell: bash
- target:
os: macos
builder: macos-10.15
shell: bash
- target:
os: windows
builder: windows-2019
shell: msys2 {0}

name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}'
defaults:
run:
shell: ${{ matrix.shell }}

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' }}
steps:
- name: Checkout nim-chronicles
- name: Checkout
uses: actions/checkout@v2
with:
path: nim-chronicles
submodules: false

- name: Install build dependencies (Linux i386)
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
Expand All @@ -58,13 +68,26 @@ jobs:
chmod 755 external/bin/gcc external/bin/g++
echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH
- name: Restore MinGW-W64 (Windows) from cache
if: runner.os == 'Windows'
id: windows-mingw-cache
uses: actions/cache@v2
- name: MSYS2 (Windows i386)
if: runner.os == 'Windows' && matrix.target.cpu == 'i386'
uses: msys2/setup-msys2@v2
with:
path-type: inherit
msystem: MINGW32
install: >-
base-devel
git
mingw-w64-i686-toolchain
- name: MSYS2 (Windows amd64)
if: runner.os == 'Windows' && matrix.target.cpu == 'amd64'
uses: msys2/setup-msys2@v2
with:
path: external/mingw-${{ matrix.target.cpu }}
key: 'mingw-${{ matrix.target.cpu }}'
path-type: inherit
install: >-
base-devel
git
mingw-w64-x86_64-toolchain
- name: Restore Nim DLLs dependencies (Windows) from cache
if: runner.os == 'Windows'
Expand All @@ -74,29 +97,10 @@ jobs:
path: external/dlls-${{ matrix.target.cpu }}
key: 'dlls-${{ matrix.target.cpu }}'

- name: Install MinGW64 dependency (Windows)
if: >
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
shell: bash
run: |
mkdir -p external
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
MINGW_URL="https://github.com/brechtsanders/winlibs_mingw/releases/download/11.2.0-12.0.1-9.0.0-r1/winlibs-x86_64-posix-seh-gcc-11.2.0-mingw-w64-9.0.0-r1.7z"
ARCH=64
else
MINGW_URL="https://github.com/brechtsanders/winlibs_mingw/releases/download/11.2.0-12.0.1-9.0.0-r1/winlibs-i686-posix-dwarf-gcc-11.2.0-mingw-w64-9.0.0-r1.7z"
ARCH=32
fi
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.7z"
7z x -y "external/mingw-${{ matrix.target.cpu }}.7z" -oexternal/
mv external/mingw$ARCH external/mingw-${{ matrix.target.cpu }}
- name: Install DLLs dependencies (Windows)
if: >
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
shell: bash
run: |
mkdir -p external
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
Expand All @@ -105,58 +109,60 @@ jobs:
- name: Path to cached dependencies (Windows)
if: >
runner.os == 'Windows'
shell: bash
run: |
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
echo '${{ github.workspace }}'"/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
- name: Get latest nimbus-build-system commit hash
id: versions
shell: bash
run: |
getHash() {
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
}
nbsHash=$(getHash status-im/nimbus-build-system)
echo "::set-output name=nimbus_build_system::$nbsHash"
- name: Restore prebuilt Nim from cache
id: nim-cache
uses: actions/cache@v2
with:
path: NimBinaries
key: 'NimBinaries-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}'

- name: Build Nim and associated tools
shell: bash
- name: Derive environment variables
run: |
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
PLATFORM=x64
else
PLATFORM=x86
fi
if [[ '${{ matrix.target.os }}' == 'windows' ]]; then
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
ncpu=
MAKE_CMD="make"
case '${{ runner.os }}' in
'Linux')
ncpu=$(nproc)
;;
'macOS')
ncpu=$(sysctl -n hw.ncpu)
;;
'Windows')
ncpu=$NUMBER_OF_PROCESSORS
MAKE_CMD="mingw32-make"
else
MAKE_CMD="make"
fi
env MAKE="$MAKE_CMD -j2" ARCH_OVERRIDE=$PLATFORM CC=gcc bash build_nim.sh nim csources dist/nimble NimBinaries
;;
esac
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
echo "ncpu=$ncpu" >> $GITHUB_ENV
echo "MAKE_CMD=${MAKE_CMD}" >> $GITHUB_ENV
- name: Build Nim and Nimble
run: |
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
env MAKE="${MAKE_CMD} -j${ncpu}" ARCH_OVERRIDE=${PLATFORM} NIM_COMMIT=${{ matrix.branch }} \
QUICK_AND_DIRTY_COMPILER=1 QUICK_AND_DIRTY_NIMBLE=1 CC=gcc \
bash build_nim.sh nim csources dist/nimble NimBinaries
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
- name: Setup environment
shell: bash
run: |
if [[ '${{ matrix.target.os }}' == 'linux' ]]; then
echo '/home/runner/.nimble/bin' >> $GITHUB_PATH
elif [[ '${{ matrix.target.os }}' == 'windows' ]]; then
echo '/c/Users/runneradmin/.nimble/bin' >> $GITHUB_PATH
else
echo '~/.nimble/bin' >> $GITHUB_PATH
fi
- name: Run nim-chronicles tests
shell: bash
working-directory: nim-chronicles
- name: Run tests
run: |
nim --version
nimble --version
nimble install -y --depsOnly
nimble test
#nimble test # can't find or run "ntu" on Windows
ntu test tests
6 changes: 1 addition & 5 deletions chronicles.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ requires "testutils"
requires "json_serialization"

task test, "run CPU tests":
when defined(windows):
# exec "cmd.exe /C ntu.cmd test tests"
echo "`ntu` doesn't work on Windows"
else:
exec "ntu test tests"
exec "ntu test tests"
4 changes: 3 additions & 1 deletion chronicles/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ proc handleEnumOption(E: typedesc[enum],
type R = type(result)
return R(0)
else:
return parseEnum[E](optValue)
# This enum parsing is supposed to be case insensitive, but it isn't in
# Nim-1.6.0.
return parseEnum[E](optValue.capitalizeAscii())
except: error &"'{optValue}' is not a recognized value for '{optName}'. " &
&"Allowed values are {enumValues E}"

Expand Down
1 change: 1 addition & 0 deletions tests/config.nims
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
switch("path", "../")
2 changes: 1 addition & 1 deletion tests/perf/release_opt_size.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ program="../lexical_scopes"
chronicles_sinks="textlines[stdout]"
chronicles_colors=None
chronicles_timestamps=None
max_size=175000
max_size=450000

release
--opt:size
Expand Down
2 changes: 1 addition & 1 deletion tests/perf/size_check_debug.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
program="../size"
max_size=1250000
max_size=1400000

chronicles_sinks="textlines[stdout]"
chronicles_colors=AnsiColors
Expand Down
2 changes: 1 addition & 1 deletion tests/perf/size_check_release.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
program="../size"
max_size=1000000
max_size=1200000
release

chronicles_sinks="textlines[stdout]"
Expand Down

0 comments on commit 747e4da

Please sign in to comment.