Skip to content

Commit

Permalink
CI, start tests
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Oct 26, 2024
1 parent 9f9da35 commit 97ed80a
Show file tree
Hide file tree
Showing 13 changed files with 370 additions and 109 deletions.
4 changes: 3 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

- [ ] All [tests](https://github.com/attiasas/ois-core/actions/workflows/test.yml) passed. If this feature is not already covered by the tests, I added new tests.
- [ ] If this feature effect users, update the [documentation](../README.md) and the [wiki](https://github.com/attiasas/ois-core/wiki)
- [ ] This feature was validated on all supported platforms
-----
20 changes: 20 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
changelog:
exclude:
labels:
- ignore for release
categories:
- title: Breaking Changes 🚨
labels:
- breaking change
- title: Exciting New Features 🎉
labels:
- new feature
- title: Improvements 🌱
labels:
- improvement
- title: Bug Fixes 🛠
labels:
- bug
- title: Other Changes 📚
labels:
- "*"
42 changes: 42 additions & 0 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Static Analysis"

on:
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:

permissions:
checks: write

jobs:
spotbugs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
# Install required tools
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: "corretto"
java-version: "11"

# Run tests
- name: Run Spotbugs
run: ./gradlew clean spotbugs

# Show Spotbugs report
- name: Show Spotbugs report
uses: jwgmeligmeyling/spotbugs-github-action@master
with:
path: "build/reports/spotbugs/main/spotbugs.xml"
if: failure()

# Stop Gradle daemon
- name: Stop Gradle
run: ./gradlew --stop
if: always()
51 changes: 51 additions & 0 deletions .github/workflows/reflection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "Test HTML Reflection not broken"
# Some classes may not reflect, to make sure we are not breaking the runners we search for known blacklist imports

on:
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:

jobs:
check-blacklist-imports:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

# Install required tools
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: "corretto"
java-version: "11"

- name: Define blacklisted packages and directories
run: |
# List of forbidden imports (blacklisted packages)
BLACKLIST=("java.nio.file")
# List of relative directories to search (after java/)
RELATIVE_SEARCH_DIRS=("runner" "state" "project" "tools" "utils/io/data" "utils/log")
# Base directory
BASE_DIR="src/main/java/org/ois/core"
# Loop over the blacklist
for forbidden_pkg in "${BLACKLIST[@]}"; do
# Search for forbidden imports in the specified relative directories
for dir in "${RELATIVE_SEARCH_DIRS[@]}"; do
FULL_PATH="$BASE_DIR/$dir"
if grep -rnw "$FULL_PATH" -e "import $forbidden_pkg" --include \*.java; then
echo "Error: Found forbidden import: $forbidden_pkg in $dir"
exit 1
fi
done
done
echo "No forbidden imports found."
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Test"

on:
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:

jobs:
unit-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macOS-latest ]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
# Install required tools
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: "corretto"
java-version: "11"
# Run tests
- name: Tests on macOS, Linux
run: ./gradlew clean test
if: runner.os != 'Windows'
- name: Tests on Windows
run: ./gradlew.bat clean test
if: runner.os == 'Windows'
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ dependencies {
if(enableGraalNative == 'true') {
implementation "io.github.berstanio:gdx-svmhelper-annotations:$graalHelperVersion"
}

testImplementation group: 'org.testng', name: 'testng', version: '7.7.0'
}

test {
useTestNG() {
useDefaultListeners = true
}
testLogging {
exceptionFormat "full"
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
minGranularity 0
}
}

publishing {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/ois/core/OIS.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package org.ois.core;

import org.ois.core.runner.SimulationEngine;
import org.ois.core.state.StateManager;

/**
* Static access to OIS utilities and shared objects
*/
public class OIS {
/** The active OIS engine that runs the simulation. **/
public static SimulationEngine engine;
/** The State managers of the simulation **/
public static StateManager stateManager;
}
10 changes: 9 additions & 1 deletion src/main/java/org/ois/core/project/Assets.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package org.ois.core.project;

/**
* Static access to resources
*/
public class Assets {

/** The directory name inside the simulation directory that holds all the project assets for the simulation **/
public static final String ASSETS_DIRECTORY = "assets";

/**
* Return the path to a project asset
* @param pathRelativeToAssetsDir - a path relative from the project simulation/assets directory.
* @return - the path to an asset
*/
public static String get(String pathRelativeToAssetsDir) {
return ASSETS_DIRECTORY + "/" + pathRelativeToAssetsDir;
}
Expand Down
Loading

0 comments on commit 97ed80a

Please sign in to comment.