Skip to content

Commit

Permalink
Merge pull request #58 from alaviss/ci-nimskull
Browse files Browse the repository at this point in the history
add nimskull support and expand nim test matrix

Main changes:

* Dropped Nim 1.6 support as it was untested and did not work once testing was hooked up.
* Refactored `strings.filter()` to make it work on nimskull.
* Added Nim 2.0 and nimskull to CI.
* nim-sys version is now 0.0.1.

Known issues:

* Windows and i386 testing for nimskull has been temporary disabled as fixes are required to get them going.
* Docgen in CI has been disabled for nimskull due to nim-works/nimskull#1151
  • Loading branch information
alaviss authored Feb 1, 2024
2 parents 26c36ca + f1c8605 commit 5dd52f2
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 29 deletions.
85 changes: 78 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ jobs:
fail-fast: false
matrix:
branch: [devel]
compiler:
- name: nim
version: devel
- name: nim
version: version-2-0
- name: nimskull
version: "*"
target: [linux, macos, windows]
arch: [i386, amd64]
include:
Expand All @@ -24,12 +31,31 @@ jobs:
winlib_arch: x86_64
- target: linux
arch: amd64
branch: devel
builddocs: true
compiler:
name: nim
version: devel
uploaddocs: true
# XXX: nimskull hangs forever trying to build docs
- compiler:
name: nimskull
nodocs: true
exclude:
- target: macos
arch: i386
name: ${{ matrix.target }} on ${{ matrix.arch }} (Nim ${{ matrix.branch }})

# TODO: nimskull needs fixes for this to work
- target: linux
arch: i386
compiler:
name: nimskull

# TODO: a handful of problems with SSL must be solved before this
- target: windows
compiler:
name: nimskull
name:
${{ matrix.target }} on ${{ matrix.arch }} (${{ matrix.compiler.name }}
${{ matrix.compiler.version }})
runs-on: ${{ matrix.builder }}

defaults:
Expand All @@ -56,32 +82,68 @@ jobs:
libstdc++-10-dev-i386-cross
mkdir -p ~/.config/nim
cat << EOF > ~/.config/nim/nim.cfg
cpu = "i386"
gcc.exe = "i686-linux-gnu-gcc-10"
gcc.cpp.exe = "i686-linux-gnu-g++-10"
gcc.linkerexe = "i686-linux-gnu-gcc-10"
gcc.cpp.linkerexe = "i686-linux-gnu-g++-10"
EOF
- name: Configure target architecture for Windows (i386)
if: matrix.arch == 'i386' && runner.os == 'Windows'
run: |
mkdir -p "$APPDATA/nim"
echo 'cpu = "i386"' >> "$APPDATA/nim/nim.cfg"
- name: Setup GCC (Windows-only)
if: runner.os == 'Windows'
uses: bwoodsend/[email protected]
with:
architecture: ${{ matrix.winlib_arch }}

- name: Setup Nim
if: matrix.compiler.name == 'nim'
uses: alaviss/[email protected]
with:
path: nim
version: ${{ matrix.branch }}
version: ${{ matrix.compiler.version }}
architecture: ${{ matrix.arch }}

- name: Setup nimskull
id: nimskull
if: matrix.compiler.name == 'nimskull'
uses: nim-works/[email protected]
with:
nimskull-version: ${{ matrix.compiler.version }}

- name: Fetch nimble source for nimskull
if: matrix.compiler.name == 'nimskull'
uses: actions/[email protected]
with:
path: nimble
repository: alaviss/nimble
ref: nimskull

- name: Install nimble for nimskull
if: matrix.compiler.name == 'nimskull'
run: |
nim c -d:release -o:"$NIMSKULL_BIN/nimble" src/nimble.nim
# Add nimble binary folder to PATH
echo "$HOME/.nimble/bin" >> "$GITHUB_PATH"
working-directory: nimble
env:
NIMSKULL_BIN: ${{ steps.nimskull.outputs.bin-path }}

- name: Install dependencies
run: nimble install -y --depsOnly
run: |
nimble install -y --depsOnly
nimble install -y "https://github.com/disruptek/balls@>= 3.9.11 & < 4.0.0"
- name: Run tests
run: nimble test
run: balls

- name: Build docs
if: "!matrix.nodocs"
shell: bash
run: |
branch=${{ github.ref }}
Expand All @@ -97,7 +159,7 @@ jobs:
cp htmldocs/{the,}index.html || true
- name: Upload GitHub Pages artifact
if: matrix.builddocs
if: matrix.uploaddocs
uses: actions/[email protected]
with:
path: nim-sys/htmldocs
Expand All @@ -120,3 +182,12 @@ jobs:
- name: Deploy page
id: deployment
uses: actions/[email protected]

passed:
needs: build
if: failure() || cancelled()
name: All tests passed

runs-on: ubuntu-latest
steps:
- run: exit 1
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# An abstraction layer for common operating system services

[![CI status](https://github.com/alaviss/nim-sys/workflows/CI/badge.svg)](https://github.com/alaviss/nim-sys/actions?query=workflow%3ACI)
![Minimum supported Nim version](https://img.shields.io/badge/nim-1.5.1%2B-informational?style=flat&logo=nim)
![Minimum supported Nim version](https://img.shields.io/badge/nim-2.0.0%2B-informational?style=flat&logo=nim)
[![License](https://img.shields.io/github/license/alaviss/nim-sys?style=flat)](#license)

This package is an experiment in rewriting various parts of stdlib's `os` module.
Expand Down
11 changes: 4 additions & 7 deletions src/sys/strings.nim
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,10 @@ func toWithout*[A](w: sink Without[A], C: static set[char]): Without[C]

func filter*(s: string, C: static set[char]): Without[C] {.raises: [].} =
## Remove characters in set `C` from `s` and create a `Without[C]`.
var i = 0
result = Without[C](s)
while i < result.len:
if result[i] in C:
result.string.delete(i, i)
else:
inc i
result = Without[C]: newStringOfCap(s.len)
for chr in s.items:
if chr notin C:
result.string.add(chr)

func filter*[A](w: Without[A], C: static set[char]): Without[C]
{.raises: [].} =
Expand Down
17 changes: 4 additions & 13 deletions sys.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.1.0"
version = "0.0.1"
author = "Leorize"
description = "Abstractions for common operating system services"
license = "MIT"
Expand All @@ -9,19 +9,10 @@ srcDir = "src"

# Dependencies

requires "nim >= 1.5.1"
requires "https://github.com/disruptek/balls >= 3.9.0 & < 4.0.0"
when (NimMajor, NimMinor, NimPatch) < (1, 9, 0):
requires "https://github.com/nim-works/cps >= 0.8.0 & < 0.9.0"
else:
requires "https://github.com/nim-works/cps >= 0.9.0 & < 0.10.0"
when not defined(isNimSkull):
requires "nim >= 2.0.0"
requires "https://github.com/nim-works/cps ^= 0.10.0"
requires "https://github.com/status-im/nim-stew#3c91b8694e15137a81ec7db37c6c58194ec94a6a"

# Bundled as submodule instead since the package can only be installed on Windows.
# requires "https://github.com/khchen/winim#bffaf742b4603d1f675b4558d250d5bfeb8b6630"

task test, "Run test suite":
when defined(windows):
exec "balls.cmd"
else:
exec "balls"
1 change: 0 additions & 1 deletion tests/config.nims

This file was deleted.

1 change: 1 addition & 0 deletions tests/nim.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
path = "$config/../src"
File renamed without changes.
File renamed without changes.

0 comments on commit 5dd52f2

Please sign in to comment.