Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add basic CI using github actions #6

Merged
merged 2 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: scinim CI
on:
push:
paths:
- 'tests/**'
- '**'
- 'scinim.nimble'
- '.github/workflows/ci.yml'
pull_request:
paths:
- 'tests/**'
- '**'
- 'scinim.nimble'
- '.github/workflows/ci.yml'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
nim:
- '1.6.x'
- '2.0.x'
- 'stable'
os:
- ubuntu-latest
- windows-latest
- macOS-latest
name: '${{ matrix.nim }} (${{ matrix.os }})'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: scinim

- name: Setup nim
uses: jiro4989/setup-nim-action@v1
with:
nim-version: ${{ matrix.nim }}
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup MSYS2 (Windows)
if: ${{matrix.target == 'windows'}}
uses: msys2/setup-msys2@v2
with:
path-type: inherit
update: true
install: base-devel git mingw-w64-x86_64-toolchain

- name: Install dependencies (Ubuntu)
if: ${{matrix.target == 'linux'}}
run: |
sudo apt-get update
sudo apt-get install -y python-numpy python3-numpy

- name: Install dependencies (OSX)
if: ${{matrix.target == 'macos'}}
run: |
brew install numpy

- name: Install dependencies (Windows)
if: ${{matrix.target == 'windows'}}
shell: msys2 {0}
run: |
pacman -Syu --noconfirm
pacman -S --needed --noconfirm mingw-w64-x86_64-lapack
pacman -S --needed --noconfirm mingw-w64-x86_64-python-numpy

- name: Setup nimble & deps
shell: bash
run: |
cd scinim
nimble refresh -y
nimble install -y

- name: Run tests (Linux & OSX)
if: ${{matrix.target != 'windows'}}
shell: bash
run: |
cd scinim
nimble -y test

- name: Run tests (Windows)
if: ${{matrix.target == 'windows'}}
shell: msys2 {0}
run: |
cd scinim
nimble -y test

- name: Build docs
if: >
github.event_name == 'push' && github.ref == 'refs/heads/master' &&
matrix.target == 'linux' && matrix.branch == 'devel'
shell: bash
run: |
cd scinim
branch=${{ github.ref }}
branch=${branch##*/}
nimble doc --project --outdir:docs \
'--git.url:https://github.com/${{ github.repository }}' \
'--git.commit:${{ github.sha }}' \
"--git.devel:$branch" \
scinim.nim
# Ignore failures for older Nim
cp docs/{the,}index.html || true

- name: Publish docs
if: >
github.event_name == 'push' && github.ref == 'refs/heads/master' &&
matrix.target == 'linux' && matrix.branch == 'devel'
uses: crazy-max/ghaction-github-pages@v1
with:
build_dir: scinim/docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions scinim.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ requires "threading"
requires "arraymancer >= 0.7.3"
requires "polynumeric >= 0.2.0"
requires "nimpy >= 0.2.0"

task test, "Run all tests":
exec "nim c -r tests/tnumpyarrays.nim"
exec "nim c -r --gc:orc tests/tnumpyarrays.nim"
exec "nim cpp -r tests/tnumpyarrays.nim"
exec "nim cpp -r --gc:orc tests/tnumpyarrays.nim"
Loading