Skip to content

Commit

Permalink
Adding in Java example generate/test to github actions; DRYing out re…
Browse files Browse the repository at this point in the history
…trieval of information from git.properties file.
  • Loading branch information
ialarmedalien committed Jun 16, 2020
1 parent 7e58f55 commit 835b9cc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/kb_sdk-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:

docker_build_and_test:
kb_sdk_build:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -15,14 +15,22 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Add bin to $PATH
run: |
env
echo "::add-path::$GITHUB_WORKSPACE/bin"
- name: Build with Ant
run: |
make
env
- name: Upload kb-sdk build
uses: actions/upload-artifact@v2
with:
name: kb-sdk_build
path: bin/kb-sdk

- name: checking kb-sdk functions
env:
KBASE_TEST_TOKEN: ${{ secrets.KBASE_TEST_TOKEN }}
Expand All @@ -39,8 +47,12 @@ jobs:
kb-sdk test
cd ..
rm -rf PerlExample
kb-sdk init -l python -u user --example MyContigFilter
cd MyContigFilter
kb-sdk init -l python -u user --example PythonExample
cd PythonExample
make
kb-sdk test
cd ..
rm -rf PythonExample
kb-sdk init -l java -u user --example JavaExample
cd JavaExample
kb-sdk test
28 changes: 10 additions & 18 deletions src/java/us/kbase/mobu/ModuleBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,37 +359,29 @@ private static int runTestCommand(TestCommandArgs testArgs, JCommander jc) {
}

private static void printVersion() {
String gitCommit = getGitCommit();
String timestamp = getBuildTimestamp();
String gitCommit = getGitProp("commit");
String timestamp = getGitProp("build_timestamp");
System.out.println("KBase SDK version " + VERSION
+ (timestamp == null ? "" : ("_" + timestamp))
+ (gitCommit == null ? "" : (" (commit " + gitCommit + ")")));
}

public static String getBuildTimestamp() {
String buildTimestamp = null;
try {
Properties gitProps = new Properties();
InputStream is = ModuleBuilder.class.getResourceAsStream("git.properties");
gitProps.load(is);
is.close();
buildTimestamp = gitProps.getProperty("build_timestamp");
} catch (Exception ignore) {}
return buildTimestamp;
}

public static String getGitCommit() {
String gitCommit = null;
public static String getGitProp(String propertyToGet) {
String propertyValue = null;
try {
Properties gitProps = new Properties();
InputStream is = ModuleBuilder.class.getResourceAsStream("git.properties");
gitProps.load(is);
is.close();
gitCommit = gitProps.getProperty("commit");
} catch (Exception ignore) {}
return gitCommit;
propertyValue = gitProps.getProperty(propertyToGet);
} catch (Exception e) {
showError("Error while retrieving version information", e.getMessage());
}
return propertyValue;
}


private static int runVersionCommand(VersionCommandArgs testArgs, JCommander jc) {
printVersion();
return 0;
Expand Down
18 changes: 9 additions & 9 deletions src/java/us/kbase/mobu/compiler/report/CompilationReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
public class CompilationReporter {

public static void prepareCompileReport(File codeDir, List<KbService> services,
boolean perlServerSide, String perlImplName, boolean pyServerSide,
boolean perlServerSide, String perlImplName, boolean pyServerSide,
String pyImplName, boolean rServerSide, String rImplName,
boolean javaServerSide, String javaPackageParent, String javaSrcPath,
boolean javaServerSide, String javaPackageParent, String javaSrcPath,
JavaData javaParsingData, List<SpecFile> specFiles, File reportFile) throws Exception {
String sdkVersion = ModuleBuilder.VERSION;
String sdkGitCommit = ModuleBuilder.getGitCommit();
String sdkGitCommit = ModuleBuilder.getGitProp("commit");
String moduleName = null;
KbModule module = null;
for (KbService srv : services)
Expand Down Expand Up @@ -74,11 +74,11 @@ public static void prepareCompileReport(File codeDir, List<KbService> services,
FileSaver javaSrcDir = new DiskFileSaver(javaSrc);
for (JavaModule jmodule : javaParsingData.getModules()) {
if (jmodule.getOriginal().getModuleName().equals(moduleName)) {
String moduleDir = JavaTypeGenerator.sub(javaPackageParent,
String moduleDir = JavaTypeGenerator.sub(javaPackageParent,
jmodule.getModulePackage()).replace('.', '/');
String serverClassName = TextUtils.capitalize(jmodule.getModuleName()) +
String serverClassName = TextUtils.capitalize(jmodule.getModuleName()) +
"Server";
implFile = javaSrcDir.getAsFileOrNull(moduleDir + "/" +
implFile = javaSrcDir.getAsFileOrNull(moduleDir + "/" +
serverClassName + ".java");
}
}
Expand All @@ -102,7 +102,7 @@ public static void prepareCompileReport(File codeDir, List<KbService> services,

public static Report createReport(List<SpecFile> specFiles,
String sdkVersion, String sdkGitCommit, String moduleName,
KbModule module, String implFilePath, String implCommentPrefix,
KbModule module, String implFilePath, String implCommentPrefix,
String implText) throws Exception, IOException {
Map<String, FunctionPlace> funcPositions = new LinkedHashMap<String, FunctionPlace>();
String commentPrefix = Pattern.quote(implCommentPrefix);
Expand All @@ -111,8 +111,8 @@ public static Report createReport(List<SpecFile> specFiles,
if (comp instanceof KbFuncdef) {
KbFuncdef func = (KbFuncdef)comp;
String funcName = func.getName();
Pattern p = Pattern.compile(MessageFormat.format(".*" + commentPrefix +
"BEGIN {0}\n(.*\n)?[ \t]*" + commentPrefix + "END {0}\n.*",
Pattern p = Pattern.compile(MessageFormat.format(".*" + commentPrefix +
"BEGIN {0}\n(.*\n)?[ \t]*" + commentPrefix + "END {0}\n.*",
funcName), Pattern.DOTALL);
FunctionPlace place = checkMatch(funcPositions, p, implText);
if (place != null)
Expand Down

0 comments on commit 835b9cc

Please sign in to comment.