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

Single point version definition #285

Merged
merged 13 commits into from
Oct 19, 2024
19 changes: 19 additions & 0 deletions .github/scripts/check_schema_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
ONTOLOGY_VERSION=$(mvn help:evaluate -Dexpression=ontology.version -q -DforceStdout)

# Check for changes and compare versions
if git diff --quiet "main:$(git ls-tree -r --name-only main | grep 'iguana.owx')" 'src/main/resources/iguana.owx'; then
DIFF_STATUS=0
else
DIFF_STATUS=1
fi

if [ $DIFF_STATUS = '1' ] && [ "$PROJECT_VERSION" != "$ONTOLOGY_VERSION" ];
then
echo "Schema has changed, update ontology version to the project version inside the pom!"
exit 1
fi

exit 0
3 changes: 2 additions & 1 deletion .github/workflows/check_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: .github/scripts/tagcheck.sh v$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
- run: .github/scripts/tagcheck.sh v$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
- run: .github/scripts/check_schema_version.sh
17 changes: 11 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
deploy_docs:
name: Deploy Documentation
runs-on: ubuntu-latest
needs: find_version
needs: deploy_to_maven
env:
RELEASE_VERSION: ${{ needs.find_version.outputs.RELEASE_VERSION }}
steps:
Expand Down Expand Up @@ -121,15 +121,20 @@ jobs:
publish_dir: ./javadoc/${{ env.RELEASE_VERSION }}/apidocs
destination_dir: ./javadoc/latest

- name: Fetch Ontologies
run: git fetch && git checkout origin/gh-pages ontology/
- name: Find Ontology Version
run: echo "ONTOLOGY_VERSION=$(grep 'versionIRI' schema/iguana.owx | grep -Po '[0-9]+.[0-9]+.[0-9]+')" >> $GITHUB_OUTPUT
run: echo "ONTOLOGY_VERSION=$(grep 'versionIRI' artifacts/iguana.owx | grep -Po '[0-9]+.[0-9]+.[0-9]+')" >> $GITHUB_OUTPUT
id: find_ontology_version
- name: Download artifacts from previous jobs
uses: actions/download-artifact@v4
with:
path: artifacts/
merge-multiple: true

- name: Fetch Ontologies
run: git fetch && git checkout origin/gh-pages ontology/
- run: mkdir -p ontology/${{ steps.find_ontology_version.outputs.ONTOLOGY_VERSION }}
- run: cp schema/iguana.owx ontology/${{ steps.find_ontology_version.outputs.ONTOLOGY_VERSION }}/iguana.owx
- run: cp schema/iguana.owx ontology/iguana.owx
- run: cp artifacts/iguana.owx ontology/${{ steps.find_ontology_version.outputs.ONTOLOGY_VERSION }}/iguana.owx
- run: cp artifacts/iguana.owx ontology/iguana.owx

- name: Deploy Ontology to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
1 change: 1 addition & 0 deletions graalvm/generate-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fi

# Run through multiple different execution paths, so that the tracing agent can generate complete configuration files.
"$GRAALVM_HOME"/bin/java -agentlib:native-image-agent=config-merge-dir=src/main/resources/META-INF/native-image/ -jar "$TARGET_DIR"/iguana.jar --help > /dev/null
"$GRAALVM_HOME"/bin/java -agentlib:native-image-agent=config-merge-dir=src/main/resources/META-INF/native-image/ -jar "$TARGET_DIR"/iguana.jar --version > /dev/null
"$GRAALVM_HOME"/bin/java -agentlib:native-image-agent=config-merge-dir=src/main/resources/META-INF/native-image/ -jar "$TARGET_DIR"/iguana.jar --dry-run -is "$SUITE" > /dev/null
"$GRAALVM_HOME"/bin/java -agentlib:native-image-agent=config-merge-dir=src/main/resources/META-INF/native-image/ -jar "$TARGET_DIR"/iguana.jar --dry-run "$SUITE" > /dev/null

Expand Down
6 changes: 3 additions & 3 deletions graalvm/generate-profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ if [ -z "$SUITE" ]; then
fi

# Instrument the application
"$GRAALVM_HOME"/bin/native-image --pgo-instrument "$ARGUMENTS" -jar ./target/iguana.jar -o "./target/iguana-4.1.0-instrumented"
"$GRAALVM_HOME"/bin/native-image --pgo-instrument "$ARGUMENTS" -jar ./target/iguana.jar -o "./target/iguana-instrumented"
if [ $? -ne 0 ]; then
echo "Error while instrumenting the application."
exit 1
fi

# Generate the profile
./target/iguana-4.1.0-instrumented -XX:ProfilesDumpFile=custom.iprof "$SUITE"
./target/iguana-instrumented -XX:ProfilesDumpFile=custom.iprof "$SUITE"
if [ $? -ne 0 ]; then
echo "Error while generating the profile."
exit 1
fi

# Compile the application with the profile
"$GRAALVM_HOME"/bin/native-image --pgo=custom.iprof "$ARGUMENTS" -jar ./target/iguana.jar -o "./target/iguana-4.1.0-pgo"
"$GRAALVM_HOME"/bin/native-image --pgo=custom.iprof "$ARGUMENTS" -jar ./target/iguana.jar -o "./target/iguana-pgo"
if [ $? -ne 0 ]; then
echo "Error while compiling the application."
exit 1
Expand Down
17 changes: 17 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
<minor.version>1</minor.version>
<build.version>0</build.version>

<ontology.version>4.1.0</ontology.version>

<java.version>17</java.version>
<jena.version>5.1.0</jena.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -146,6 +148,20 @@
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes><include>version.properties</include></includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>version.properties</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -227,6 +243,7 @@
<directory>${project.basedir}/src/main/resources/</directory>
<includes>
<include>start-iguana.sh</include>
<include>iguana.owx</include>
nck-mlcnv marked this conversation as resolved.
Show resolved Hide resolved
nck-mlcnv marked this conversation as resolved.
Show resolved Hide resolved
</includes>
<filtering>true</filtering>
</resource>
Expand Down
26 changes: 25 additions & 1 deletion src/main/java/org/aksw/iguana/cc/controller/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.io.IOException;
import java.nio.file.Path;
import java.util.Objects;


/**
Expand Down Expand Up @@ -36,6 +37,9 @@ public Path convert(String value) {

@Parameter(description = "suite file {yml,yaml,json}", arity = 1, required = true, converter = PathConverter.class)
private Path suitePath;

@Parameter(names = {"--version", "-v"}, description = "Outputs the version number of the program and result ontology.")
private boolean version;
}

private static final Logger LOGGER = LoggerFactory.getLogger(MainController.class);
Expand All @@ -45,7 +49,7 @@ public Path convert(String value) {
*
* @param argc The command line arguments that are passed to the program.
*/
public static void main(String[] argc) {
public static void main(String[] argc) throws IOException {
// Configurator.reconfigure(URI.create("log4j2.yml"));

var args = new Args();
Expand All @@ -55,6 +59,13 @@ public static void main(String[] argc) {
try {
jc.parse(argc);
} catch (ParameterException e) {
// The exception is also thrown when no suite file is provided. In the case where only the version option
// is provided, this would still throw. Therefore, we need to check if the version option is provided.
if (args.version) {
outputVersion();
System.exit(0);
}

System.err.println(e.getLocalizedMessage());
jc.usage();
System.exit(0);
Expand All @@ -63,6 +74,10 @@ public static void main(String[] argc) {
jc.usage();
System.exit(1);
}
if (args.version) {
outputVersion();
System.exit(0);
}

try {
Suite parse = IguanaSuiteParser.parse(args.suitePath, !args.ignoreShema);
Expand All @@ -74,4 +89,13 @@ public static void main(String[] argc) {
System.exit(0);
}

private static void outputVersion() throws IOException {
ClassLoader classloader = MainController.class.getClassLoader();
String properties = new String(Objects.requireNonNull(classloader.getResourceAsStream("version.properties")).readAllBytes());
nck-mlcnv marked this conversation as resolved.
Show resolved Hide resolved
String[] lines = properties.split("\\n");
String projectVersion = lines[0].split("=")[1].trim();
String ontologyVersion = lines[1].split("=")[1].trim();
System.out.printf("IGUANA version: %s (result ontology version: %s)%n", projectVersion, ontologyVersion);
}

}
4 changes: 2 additions & 2 deletions schema/iguana.owx → src/main/resources/iguana.owx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
ontologyIRI="https://vocab.dice-research.org/iguana/"
versionIRI="https://vocab.dice-research.org/iguana/4.1.0/">
versionIRI="https://vocab.dice-research.org/iguana/${ontology.version}/">
<Prefix name="dc" IRI="http://purl.org/dc/elements/1.1/"/>
<Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
<Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
Expand Down Expand Up @@ -48,7 +48,7 @@
</Annotation>
<Annotation>
<AnnotationProperty abbreviatedIRI="owl:versionInfo"/>
<Literal>4.1.0</Literal>
<Literal>${ontology.version}</Literal>
</Annotation>
<Declaration>
<Class abbreviatedIRI="iont:Connection"/>
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version=${project.version}
ontology_version=${ontology.version}
Loading