Skip to content

Commit

Permalink
Remove Oviva bits and vendor spicegen binary
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrichner-oviva committed May 17, 2024
1 parent 9fe267c commit f0376c8
Show file tree
Hide file tree
Showing 25 changed files with 236 additions and 6,120 deletions.
22 changes: 3 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
run: |
echo "updating version to '$VERSION'"
mvn -B versions:set "-DnewVersion=$VERSION"
- name: Make AST preprocessor
working-directory: parser
run: make build
- name: Publish package
run: mvn --batch-mode deploy
env:
Expand All @@ -45,24 +48,5 @@ jobs:
workdir: ./parser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: ${{ steps.version.outputs.version }}
body: |
The spice must flow!
files: |
README.md
parser/dist/spicegen_Darwin_arm64.tar.gz
parser/dist/spicegen_Darwin_x86_64.tar.gz
parser/dist/spicegen_Linux_arm64.tar.gz
parser/dist/spicegen_Linux_i386.tar.gz
parser/dist/spicegen_Linux_x86_64.tar.gz
parser/dist/spicegen_darwin_amd64_v1/spicegen_darwin_amd64_v1
parser/dist/spicegen_darwin_arm64/spicegen_darwin_arm64
parser/dist/spicegen_linux_386/spicegen_linux_386
parser/dist/spicegen_linux_amd64_v1/spicegen_linux_amd64_v1
parser/dist/spicegen_linux_arm64/spicegen_linux_arm64


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ target/
.java-version
generator/gen/
generator/out/src
.flattened-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
import com.oviva.spicegen.generator.Options;
import com.oviva.spicegen.generator.internal.SpiceDbClientGeneratorImpl;
import com.oviva.spicegen.parser.SpiceDbSchemaParser;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
Expand All @@ -38,8 +34,7 @@ public class SpicegenMojo extends AbstractMojo {
MavenProject project;

@Parameter(
defaultValue = "${project.basedir}/src/main/resources/schema_ast.json",
// defaultValue = "${project.basedir}/src/main/resources/schema.zed",
defaultValue = "${project.basedir}/src/main/resources/schema.zed",
property = "schemaPath")
String schemaPath;

Expand All @@ -55,29 +50,17 @@ public void execute() throws MojoExecutionException {
var log = getLog();

log.info("reading schema from '" + schemaPath + "'");
var specInputStream = readSchema();

var generator = new SpiceDbClientGeneratorImpl(new Options(outputDirectory, packageName));
var parser = new SpiceDbSchemaParser();

log.info("parsing schema");

// TODO parse direct zed schema
var spec = parser.parse(specInputStream);
var spec = parser.parse(Path.of(schemaPath));

log.info("generating SpiceDB sources and writing to '" + outputDirectory + "'");
generator.generate(spec);

project.addCompileSourceRoot(outputDirectory);
}

private InputStream readSchema() throws MojoExecutionException {

try {
return Files.newInputStream(Path.of(schemaPath), StandardOpenOption.READ);
} catch (IOException e) {
throw new MojoExecutionException(
"cannot find asyncapi specification at: '" + schemaPath + "'", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.oviva.spicegen.generator.Options;
import com.oviva.spicegen.model.Schema;
import com.oviva.spicegen.parser.SpiceDbSchemaParser;
import java.nio.file.Path;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

Expand All @@ -12,24 +13,19 @@ class SpiceDbClientGeneratorImplTest {
private static final String sourcePackageName = "com.oviva.spicegen";

@ParameterizedTest
@ValueSource(
strings = {
// "files",
"oviva",
})
void test() {
@ValueSource(strings = {"files"})
void test(String schemaName) {

var generator = new SpiceDbClientGeneratorImpl(new Options(sourceDirectory, sourcePackageName));
var schema = loadSchema("oviva");
var schema = loadSchema(schemaName);
generator.generate(schema);
}

private Schema loadSchema(String name) {

var astInputStream =
this.getClass().getResourceAsStream("/fixtures/%s_ast.json".formatted(name));
var astInput = Path.of("./src/test/resources/fixtures/%s_ast.json".formatted(name));
var parser = new SpiceDbSchemaParser();

return parser.parse(astInputStream);
return parser.parse(astInput);
}
}
Empty file.
Loading

0 comments on commit f0376c8

Please sign in to comment.