Skip to content

Commit

Permalink
chore: run tests on multiple java versions (#164)
Browse files Browse the repository at this point in the history
* chore: run tests on multiple java versions

* fix typo

* Use a higher release version for basic-math

* Make assertions stronger

* Set source and target to 17

* Write logical assert statements

* Remove MacOS on CI until https://github.com/orgs/community/discussions/111013 is resolved

* Does order matter?

* Use native maven instead of maven invoker

* Add back macOS

* Let's look at PATH

* Revert

* Remove macOS and Windows for now
  • Loading branch information
algomaster99 authored Mar 6, 2024
1 parent 79c2bcd commit 695e987
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
java-version: [ 17, 21 ]
os: [ ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Setup JDK 17
- name: Setup JDK${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: '17'
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
- name: Build project
# We need to build the agent first, because the tests depend on it
run: mvn clean install -DskipTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

Expand All @@ -19,21 +20,25 @@ void runtimeIndexShouldBeDeterministic(@TempDir Path tempDir) throws IOException
// act
String[] jdk_argsFirst = {"jdk", "-o", indexFile.toString()};
Index.main(jdk_argsFirst);
List<String> jdkIndex = Files.readAllLines(indexFile);

String[] runtime_argsFirst = {
"runtime", "-p", project.toString(), "-i", indexFile.toString(), "-mj", "basic-math", "--cleanup"
};
Index.main(runtime_argsFirst);
String contentFirst = Files.readString(indexFile);
List<String> first = Files.readAllLines(indexFile);

String[] jdk_argsSecond = {"jdk", "-o", indexFile.toString()};
Index.main(jdk_argsSecond);
String[] runtime_argsSecond = {
"runtime", "-p", project.toString(), "-i", indexFile.toString(), "-mj", "basic-math", "--cleanup"
};
Index.main(runtime_argsSecond);
String contentSecond = Files.readString(indexFile);
List<String> second = Files.readAllLines(indexFile);

// assert
assertThat(contentFirst).isEqualTo(contentSecond);
// This ensures that the project compiles
assertThat(first).size().isGreaterThan(jdkIndex.size());
assertThat(first).isEqualTo(second);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<artifactId>basic-math</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<build>
<plugins>
<plugin>
Expand Down

0 comments on commit 695e987

Please sign in to comment.