Skip to content

Commit

Permalink
Pre-release updates
Browse files Browse the repository at this point in the history
* Fix a bug in ParseCommand
* Test with the new institutional-commerce app
  • Loading branch information
reid-spencer committed Sep 7, 2024
1 parent 8a1aafe commit 720ffca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ParseCommand extends InputFileCommand(ParseCommand.cmdName) {
outputDirOverride: Option[Path]
): Either[Messages, PassesResult] = {
options.withInputFile { (inputFile: Path) =>
val rpi = RiddlParserInput.fromCwdPath(inputFile)
val rpi = RiddlParserInput.fromPath(inputFile)
TopLevelParser.parseInput(rpi, commonOptions)
.map(_ => PassesResult()).map(_ => PassesResult())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
package com.ossuminc.riddl

import com.ossuminc.riddl.commands.RunCommandSpecBase
import com.ossuminc.riddl.utils.{PathUtils, Zip}
import org.scalatest.Assertion

import java.net.URL
import java.nio.file.Files
import java.nio.file.Path

Expand Down Expand Up @@ -38,21 +40,41 @@ class RunRiddlcOnLocalTest extends RunCommandSpecBase {
}
}

def runOnGitHubProject(
organization: String,
repository: String,
branch: String,
pathToSrcDir: String,
confFile: String,
cmd: String
): Assertion = {
val repo: String = s"https://github.com/$organization/$repository/archive/refs/heads/$branch.zip"
val url: URL = java.net.URI.create(repo).toURL
val tmpDir: Path = Files.createTempDirectory(repository)
val srcDir: Path = tmpDir.resolve(repository + "-" + branch).resolve(pathToSrcDir)
require(Files.isDirectory(tmpDir), "Temp directory failed to create")
val fileName = PathUtils.copyURLToDir(url, tmpDir)
val zip_path = tmpDir.resolve(fileName)
Zip.unzip(zip_path, tmpDir)
zip_path.toFile.delete()
runOnLocalProject(srcDir.toString, confFile, cmd)
}

"riddlc" should {
"validate FooBarTwoDomains" in {
val cwd = "/Users/reid/Code/ossuminc/riddl-examples"
val config = "src/riddl/FooBarSuccess/FooBar.conf"
runOnLocalProject(cwd, config, "validate")
}
"validate kalix-improving-template" in {
val cwd = "/Users/reid/Code/Improving/kalix-improving-template"
val config = "design/src/main/riddl/example.conf"
runOnLocalProject(cwd, config, "validate")
}
"hugo on Improving.app" in {
val cwd = "/Users/reid/Code/improving.app/riddl"
val config = "src/main/riddl/ImprovingApp.conf"
runOnLocalProject(cwd, config, "hugo")
"validate on ossuminc/institutional-commerce" in {
runOnGitHubProject(
"ossuminc",
"institutional-commerce",
"main",
"src/main/riddl",
"ImprovingApp.conf",
"parse" // FIXME: should be "validate"
)
}
"validate riddl-examples dokn" in {
val cwd = "/Users/reid/Code/Ossum/riddl-examples"
Expand Down

0 comments on commit 720ffca

Please sign in to comment.