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

build: add workflow for building and testing on GitHub Actions #40

Merged
merged 2 commits into from
Sep 13, 2020
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
32 changes: 32 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Builds and tests the package on Linux.
#
# This runs after changes are pushed to a feature branch or to `develop`.
#

name: Build

on:
push:
branches:
- '**'
- '!master'

jobs:
build:
if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '12'

- name: Install Dependencies
run: npm ci

- name: Run Tests
run: npm test
2 changes: 1 addition & 1 deletion models/delay/delay.dat
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ delay a[A3]
0 3
FINAL TIME
0 10
init
init 1
0 0
init 2[A2]
0 0
Expand Down
6 changes: 3 additions & 3 deletions models/delay/delay.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SubA: A2, A3 ~~|

input = STEP(10, 0) - STEP(10, 4) ~~|
delay = 5 ~~|
init = 0 ~~|
init 1 = 0 ~~|

input a[DimA]= 10, 20, 30 ~~|
delay a[DimA] = 1, 2, 3 ~~|
Expand All @@ -17,8 +17,8 @@ init 2[SubA] = 0 ~~|
k = 42 ~~|

d1 = DELAY1(input, delay) ~~|
d2[DimA] = DELAY1I(input a[DimA], delay, init) ~~|
d3[DimA] = DELAY1I(input, delay a[DimA], init) ~~|
d2[DimA] = DELAY1I(input a[DimA], delay, init 1) ~~|
d3[DimA] = DELAY1I(input, delay a[DimA], init 1) ~~|
d4[DimA] = DELAY1I(input, delay, init a[DimA]) ~~|
d5[DimA] = DELAY1I(input a[DimA], delay a[DimA], init a[DimA]) ~~|
d6[SubA] = DELAY1I(input 2[SubA], delay 2, init 2[SubA]) ~~|
Expand Down
45 changes: 30 additions & 15 deletions src/tests/modeltests
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
#!/usr/bin/env sh
# Use the global sde command if it is available.
#!/bin/bash

set -e # fail on error

# Use the local sde command.
SDE='node ../sde.js'
if which sde >/dev/null; then SDE=sde; fi
$SDE -v &>/dev/null
if [[ $? -ne 0 ]]; then
echo 'SDEverywhere is not installed.'
echo 'Run "npm install" in the src directory to install it locally.'
echo 'You could also install it globally with "npm install sdeverywhere -g".'
echo 'Run "npm install" in the top directory to install it locally.'
exit 1
fi
# Test each model against saved Vensim data.
for MODEL in $(ls ../../models); do
echo "testing the $MODEL model"
$SDE clean --modeldir ../../models/$MODEL
CMD="$SDE test ../../models/$MODEL/$MODEL -p 1e-4"
if [[ $MODEL == 'directdata' ]]; then
CMD="$CMD --spec ../../models/$MODEL/spec.json"

function test {
MODEL=$1
echo "Testing the $MODEL model"
MODEL_DIR=../../models/$MODEL
$SDE clean --modeldir $MODEL_DIR
if [[ -f $MODEL_DIR/spec.json ]]; then
TEST_ARGS="--spec $MODEL_DIR/spec.json"
else
TEST_ARGS=
fi
$CMD
$SDE clean --modeldir ../../models/$MODEL
done
$SDE test $TEST_ARGS -p 1e-4 $MODEL_DIR/$MODEL
$SDE clean --modeldir $MODEL_DIR
echo
}

if [[ -n $1 ]]; then
# Test the given model against saved Vensim data.
test $1
else
# Test each model against saved Vensim data.
for m in $(ls ../../models); do
test $m
done
fi