Skip to content

Commit c80f8a5

Browse files
authored
Add CI (#4)
* Add CI * Fix test dir * Fix typo * Fix test CI * Point to corrct branch * Fix CI * Add gradle dir * Add jar * Use Java 17
1 parent ab3079a commit c80f8a5

14 files changed

+128
-117
lines changed

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Run Java Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v3
19+
with:
20+
distribution: 'temurin'
21+
java-version: '17'
22+
23+
- name: Grant execute permission for gradlew
24+
run: chmod +x gradlew
25+
26+
- name: Run tests
27+
run: ./gradlew test
28+

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.gitattributes
2-
gradle/
3-
out/
42

53
.gradle/
64
.idea/
@@ -18,7 +16,6 @@ out/
1816
.mtj.tmp/
1917

2018
# Package Files #
21-
*.jar
2219
*.war
2320
*.nar
2421
*.ear

build.gradle

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,19 @@ dependencies {
2424

2525
java {
2626
toolchain {
27-
languageVersion = JavaLanguageVersion.of(16)
27+
languageVersion = JavaLanguageVersion.of(17)
2828
}
2929
}
3030

31+
test {
32+
testLogging {
33+
events "passed", "skipped", "failed"
34+
exceptionFormat "full"
35+
showCauses true
36+
showExceptions true
37+
showStackTraces true
38+
}
39+
}
40+
41+
42+

gradle/wrapper/gradle-wrapper.jar

61.9 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

src/test/java/collect/TestCollect.java

Lines changed: 0 additions & 97 deletions
This file was deleted.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package tslib.collect;
2+
3+
import org.junit.Test;
4+
import tslib.model.expsmoothing.SingleExpSmoothing;
5+
import tslib.model.expsmoothing.TripleExpSmoothing;
6+
import tslib.movingaverage.*;
7+
import tslib.tests.AugmentedDickeyFuller;
8+
import tslib.transform.Transform;
9+
import tslib.util.Util;
10+
11+
import java.util.List;
12+
13+
import static org.junit.Assert.*;
14+
15+
public class CollectTest {
16+
17+
private final String pathToData = "data/hotel.txt";
18+
private final int lag = 1;
19+
private final double lambda = 1.6;
20+
21+
@Test
22+
public void testForecastAndStatsRun() throws Exception {
23+
List<Double> file = Util.readFile(pathToData);
24+
assertNotNull(file);
25+
assertFalse(file.isEmpty());
26+
27+
Collect collect = new Collect(pathToData, lag, lag);
28+
29+
// Basic statistical checks
30+
assertTrue(collect.getAverage() > 0);
31+
assertTrue(collect.getVariance() > 0);
32+
33+
// Transformations
34+
List<Double> fileBoxCox = Transform.boxCox(file, lambda);
35+
assertEquals(file.size(), fileBoxCox.size());
36+
37+
// ADF Test
38+
AugmentedDickeyFuller adf = new AugmentedDickeyFuller(file);
39+
assertNotNull(adf);
40+
assertTrue(adf.getLag() >= 1);
41+
42+
// SMA
43+
SimpleMovingAverage sma = new SimpleMovingAverage(2);
44+
List<Double> smaResult = sma.compute(file);
45+
assertEquals(file.size(), smaResult.size());
46+
47+
// CMA
48+
CumulativeMovingAverage cma = new CumulativeMovingAverage();
49+
List<Double> cmaResult = cma.compute(file);
50+
assertEquals(file.size(), cmaResult.size());
51+
52+
// EMA
53+
ExponentialMovingAverage ema = new ExponentialMovingAverage(0.3);
54+
List<Double> emaResult = ema.compute(file);
55+
assertEquals(file.size(), emaResult.size());
56+
57+
// SES
58+
SingleExpSmoothing ses = new SingleExpSmoothing(0.5);
59+
List<Double> sesForecast = ses.forecast(file, 2);
60+
assertEquals(file.size() + 2, sesForecast.size());
61+
62+
// TES
63+
TripleExpSmoothing tes = new TripleExpSmoothing(0.5411, 0.0086, 1e-04, 12, false);
64+
List<Double> tesForecast = tes.forecast(file, 2);
65+
assertEquals(file.size() + 2, tesForecast.size());
66+
}
67+
}

src/test/java/model/TestDoubleExpSmoothing.java renamed to src/test/java/tslib/model/DoubleExpSmoothingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package model;
1+
package tslib.model;
22

33
import org.junit.Test;
44
import tslib.model.expsmoothing.DoubleExpSmoothing;
@@ -8,7 +8,7 @@
88

99
import static org.junit.Assert.*;
1010

11-
public class TestDoubleExpSmoothing {
11+
public class DoubleExpSmoothingTest {
1212

1313
@Test
1414
public void forecastNISTData() {

src/test/java/model/TestSingleExpSmoothing.java renamed to src/test/java/tslib/model/SingleExpSmoothingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package model;
1+
package tslib.model;
22

33
import tslib.model.expsmoothing.SingleExpSmoothing;
44
import org.junit.Test;
@@ -8,7 +8,7 @@
88

99
import static org.junit.Assert.*;
1010

11-
public class TestSingleExpSmoothing {
11+
public class SingleExpSmoothingTest {
1212

1313
@Test
1414
public void forecastNISTData() {

src/test/java/model/TestTripleExpSmoothing.java renamed to src/test/java/tslib/model/TripleExpSmoothingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package model;
1+
package tslib.model;
22

33
import org.junit.Test;
44
import tslib.model.expsmoothing.TripleExpSmoothing;
@@ -8,7 +8,7 @@
88

99
import static org.junit.Assert.*;
1010

11-
public class TestTripleExpSmoothing {
11+
public class TripleExpSmoothingTest {
1212

1313
@Test
1414
public void forecastNISTData() {

0 commit comments

Comments
 (0)