Skip to content

Commit

Permalink
Merge pull request #149 from fpco/feature/github-actions
Browse files Browse the repository at this point in the history
Switched travis to github-actions
  • Loading branch information
junjihashimoto authored Sep 25, 2023
2 parents 9cd9557 + f6e0ee8 commit 91667de
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 134 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
jobs:
build:
name: ${{ matrix.os }}-stack-${{ matrix.stackage }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest']
stackage: ['nightly', 'lts-21', 'lts-20']
steps:
- uses: actions/checkout@v4
- uses: haskell/actions/setup@v2
with:
enable-stack: true
stack-no-global: true
- name: Install packages
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ] ; then
sudo apt-get update -qq && sudo apt-get install -y gobjc++ libgnustep-base-dev libgsl-dev
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install gsl || true
fi
- uses: actions/cache@v3
with:
path: ~/.stack
key: stack-${{ matrix.os }}-${{ matrix.stackage }}-${{ hashFiles('stack.yaml') }}
- name: Build
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ] ; then
stack build --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c:gsl-example --flag inline-c-cpp:std-vector-example
else
stack build --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c-cpp:std-vector-example
fi
- name: Test
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ] ; then
stack test --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c:gsl-example --flag inline-c-cpp:std-vector-example
else
stack test --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c-cpp:std-vector-example
fi
78 changes: 0 additions & 78 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[![Build Status](https://travis-ci.org/fpco/inline-c.svg?branch=master)](https://travis-ci.org/fpco/inline-c)
[![Build Status](https://github.com/fpco/inline-c/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/fpco/inline-c/actions)

See READMEs for `inline-c` and `inline-c-cpp`.

## Authors

`inline-c` was written by [Francesco Mazzoli](https://github.com/bitonic), with contributions from Mathieu Boespflug, [Junji Hashimoto](https://github.com/junjihashimoto), and [Robert Hensing](https://github.com/roberth).

It is now maintained by [Junji Hashimoto](https://github.com/junjihashimoto).
It is now maintained by [Junji Hashimoto](https://github.com/junjihashimoto).
3 changes: 3 additions & 0 deletions inline-c-objc/inline-c-objc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ test-suite tests
default-language: Haskell2010
if os(darwin)
frameworks: Foundation
buildable: True
else
buildable: False
14 changes: 7 additions & 7 deletions inline-c/examples/gsl-ode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE MultiWayIf #-}
import Data.Coerce (coerce)
import Unsafe.Coerce (unsafeCoerce)
import Data.Monoid ((<>))
import qualified Data.Vector.Storable as V
import qualified Data.Vector.Storable.Mutable as VM
import Foreign.C.Types
import Foreign.ForeignPtr (newForeignPtr_)
import Foreign.Ptr (Ptr)
import Foreign.Storable (Storable)
import qualified Graphics.Rendering.Chart.Backend.Cairo as Chart
import qualified Graphics.Rendering.Chart.Easy as Chart
import qualified Language.C.Inline as C
import qualified Language.C.Inline.Unsafe as CU
import System.IO.Unsafe (unsafePerformIO)
import Control.Monad (forM_)
import System.IO (withFile, hPutStrLn, IOMode(..))

C.context (C.baseCtx <> C.vecCtx <> C.funCtx)

Expand Down Expand Up @@ -94,7 +94,7 @@ solveOde
-> Either String (V.Vector Double)
-- ^ Solution at end point, or error.
solveOde fun x0 f0 xend =
coerce $ solveOdeC (coerce fun) (coerce x0) (coerce f0) (coerce xend)
unsafeCoerce $ solveOdeC (unsafeCoerce fun) (unsafeCoerce x0) (unsafeCoerce f0) (unsafeCoerce xend)

lorenz
:: Double
Expand All @@ -121,9 +121,9 @@ lorenz x0 f0 xend = solveOde fun x0 f0 xend
]

main :: IO ()
main = Chart.toFile Chart.def "lorenz.png" $ do
Chart.layout_title Chart..= "Lorenz"
Chart.plot $ Chart.line "curve" [pts]
main = withFile "lorenz.csv" WriteMode $ \h ->
forM_ pts $ \(x,y) ->
hPutStrLn h $ show x ++ ", " ++ show y
where
pts = [(f V.! 0, f V.! 2) | (_x, f) <- go 0 (V.fromList [10.0 , 1.0 , 1.0])]

Expand Down
2 changes: 0 additions & 2 deletions inline-c/inline-c.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,5 @@ executable gsl-ode
build-depends: base >=4 && <5
, inline-c
, vector
, Chart >= 1.3
, Chart-cairo
else
buildable: False
8 changes: 0 additions & 8 deletions stack-lts-12.26.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions stack-lts-14.27.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions stack-lts-16.15.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions stack-lts-20.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resolver: lts-20.26
packages:
- inline-c
- inline-c-cpp
- inline-c-objc
- sample-cabal-project
6 changes: 6 additions & 0 deletions stack-lts-21.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resolver: lts-21.13
packages:
- inline-c
- inline-c-cpp
- inline-c-objc
- sample-cabal-project
9 changes: 0 additions & 9 deletions stack-nightly-2021-01-01.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions stack-nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resolver: nightly-2023-09-24
packages:
- inline-c
- inline-c-cpp
- inline-c-objc
- sample-cabal-project
10 changes: 0 additions & 10 deletions stack.yaml

This file was deleted.

1 change: 1 addition & 0 deletions stack.yaml

0 comments on commit 91667de

Please sign in to comment.