Skip to content
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
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: CI

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and test
run: make test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
lib/
64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
IJ_VERSION := 1.54p
IJ_JAR := lib/ij-$(IJ_VERSION).jar
IJ_URL := https://repo1.maven.org/maven2/net/imagej/ij/$(IJ_VERSION)/ij-$(IJ_VERSION).jar

BUILD_DIR := build/classes
DIST_DIR := build/dist
JAVA_SOURCES := $(wildcard *.java)
TEST_SOURCES := $(wildcard tests/*.java)
TEST_MARKER := $(BUILD_DIR)/.tests-compiled
TEST_CLASSES := $(basename $(notdir $(TEST_SOURCES)))

ifeq ($(OS),Windows_NT)
CP_SEP := ;
else
CP_SEP := :
endif

CLASSPATH := $(IJ_JAR)
CLASSPATH_WITH_CLASSES := $(CLASSPATH)$(CP_SEP)$(BUILD_DIR)

.PHONY: all build clean test download-deps

all: build

$(IJ_JAR):
@mkdir -p $(dir $@)
@echo "Downloading ImageJ runtime to $(IJ_JAR)"
@curl -L -o $@ $(IJ_URL)

$(BUILD_DIR)/.compiled: $(IJ_JAR) $(JAVA_SOURCES)
@mkdir -p $(BUILD_DIR)
@javac -cp "$(CLASSPATH)" -d $(BUILD_DIR) $(JAVA_SOURCES)
@touch $@

$(DIST_DIR)/OpenComet_.jar: $(BUILD_DIR)/.compiled
@mkdir -p $(DIST_DIR)
@jar cf $@ -C $(BUILD_DIR) .

build: $(DIST_DIR)/OpenComet_.jar

ifeq ($(strip $(TEST_SOURCES)),)
$(TEST_MARKER): $(BUILD_DIR)/.compiled
@touch $@
else
$(TEST_MARKER): $(TEST_SOURCES) $(BUILD_DIR)/.compiled
@javac -cp "$(CLASSPATH_WITH_CLASSES)" -d $(BUILD_DIR) $(TEST_SOURCES)
@touch $@
endif

test: $(BUILD_DIR)/.compiled $(TEST_MARKER)
@if [ -z "$(strip $(TEST_CLASSES))" ]; then \
echo "No tests to run."; \
else \
for cls in $(TEST_CLASSES); do \
echo "Running $$cls"; \
java -cp "$(CLASSPATH_WITH_CLASSES)" $$cls || exit $$?; \
done; \
fi

clean:
@rm -rf build

download-deps: $(IJ_JAR)
@true
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ The open-access publication on OpenComet is available at
comet assay image analysis", Redox Biology, 2:457-465,
2014.](http://www.sciencedirect.com/science/article/pii/S2213231714000032)

The easiest way to build and package the plugin is to download and extract
[Fiji](http://imagej.net/Fiji/Downloads) and
For more information including downloads, documentation and tutorials, visit https://cometbio.org/.

javac -classpath "<path_to_fiji>/Fiji.app/jars/*" *.java
jar cf OpenComet_.jar *.class
## Building locally

For more information including downloads, documentation and tutorials, visit http://opencomet.org.
The plugin jar file can be built using
```sh
make build
```

The compiled plugin will be written to `build/dist/OpenComet_.jar`
65 changes: 65 additions & 0 deletions tests/TestRunner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import ij.gui.Roi;

/**
* Minimal sanity checks that can run headlessly in CI.
*/
public class TestRunner {
public static void main(String[] args) {
testMeasurementString();
System.out.println("All tests passed.");
}

private static void testMeasurementString() {
Comet comet = new Comet(new Roi(0, 0, 5, 5));
comet.id = 42;

comet.status = Comet.INVALID;
if (!comet.getMeasurementString(",").isEmpty()) {
throw new AssertionError("Invalid comet should not produce output");
}

comet.status = Comet.VALID;
comet.cometArea = 10.0;
comet.cometIntensity = 20.0;
comet.cometLength = 30.0;
comet.cometDNA = 40.0;
comet.headArea = 50.0;
comet.headIntensity = 60.0;
comet.headLength = 70.0;
comet.headDNA = 80.0;
comet.headDNAPercent = 90.0;
comet.tailArea = 12.0;
comet.tailIntensity = 22.0;
comet.tailLength = 32.0;
comet.tailDNA = 42.0;
comet.tailDNApercent = 52.0;
comet.tailMoment = 62.0;
comet.tailOliveMoment = 72.0;

String expected = String.join(",",
"42",
"normal",
"10.0",
"20.0",
"30.0",
"40.0",
"50.0",
"60.0",
"70.0",
"80.0",
"90.0",
"12.0",
"22.0",
"32.0",
"42.0",
"52.0",
"62.0",
"72.0");

String actual = comet.getMeasurementString(",");
if (!expected.equals(actual)) {
throw new AssertionError("Unexpected measurement string:\nexpected: "
+ expected + "\nactual: " + actual);
}
}
}