Skip to content

Commit

Permalink
Add ci build for jvm modules (MarquezProject#915)
Browse files Browse the repository at this point in the history
* Define submodules in settings.gradle

Signed-off-by: wslulciuc <[email protected]>

* Fix wrk dir for build-client-java job

Signed-off-by: wslulciuc <[email protected]>

* Add common build config to subprojects

Signed-off-by: wslulciuc <[email protected]>

* Add experimental marquez-spark to build

Signed-off-by: wslulciuc <[email protected]>

* Revert to jdk11 for java client

Signed-off-by: wslulciuc <[email protected]>

* Update build cmd for marquez-spark in ci

Signed-off-by: wslulciuc <[email protected]>

* continued: Update build cmd for marquez-spark in ci

Signed-off-by: wslulciuc <[email protected]>

* Ignore spotbugs globally

Signed-off-by: wslulciuc <[email protected]>

* Fix SparkAgentIntegrationTest

Signed-off-by: wslulciuc <[email protected]>

* Define projects in base build.gradle

Signed-off-by: wslulciuc <[email protected]>

* Push and build marquez-web image

Signed-off-by: wslulciuc <[email protected]>

* Fix shadow jar file name

Signed-off-by: wslulciuc <[email protected]>

* Update gradle cmds in CONTRIBUTING.md

Signed-off-by: wslulciuc <[email protected]>

* Update gradle cmds in README.md

Signed-off-by: wslulciuc <[email protected]>

* Update gradle cmds in Dockerfile

Signed-off-by: wslulciuc <[email protected]>

* Update api.jar location in README.md

Signed-off-by: wslulciuc <[email protected]>

* Update build step in README.md

Signed-off-by: wslulciuc <[email protected]>

* Add api as a module in README.md

Signed-off-by: wslulciuc <[email protected]>

* Add airflow as an example integration

Signed-off-by: wslulciuc <[email protected]>

* continued: Add airflow as an example integration

Signed-off-by: wslulciuc <[email protected]>
  • Loading branch information
wslulciuc authored Feb 2, 2021
1 parent 5da945b commit 9824cc0
Show file tree
Hide file tree
Showing 24 changed files with 490 additions and 1,303 deletions.
20 changes: 9 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
- v1-api-{{ .Branch }}
- run: ./.circleci/get-jdk11.sh
- run: echo "checks.disable=true" > ~/.testcontainers.properties
- run: ./gradlew --no-daemon --stacktrace build
- run: ./gradlew --no-daemon jacocoTestReport
- run: ./gradlew --no-daemon --stacktrace api:build
- run: ./gradlew --no-daemon api:jacocoTestReport
- run: bash <(curl -s https://codecov.io/bash)
- store_test_results:
path: build/test-results/test
Expand Down Expand Up @@ -56,17 +56,16 @@ jobs:
key: v1-web-{{ .Branch }}-{{ .Revision }}

build-client-java:
working_directory: ~/marquez/clients/java
machine: true
<<: *machine
steps:
- *checkout_project_root
- checkout
- restore_cache:
keys:
- v1-client-java-{{ .Branch }}-{{ .Revision }}
- v1-client-java-{{ .Branch }}
- run: ../../.circleci/get-jdk11.sh
- run: ./gradlew --no-daemon --stacktrace build
- run: ./gradlew --no-daemon jacocoTestReport
- run: ./.circleci/get-jdk11.sh
- run: ./gradlew --no-daemon --stacktrace clients:java:build
- run: ./gradlew --no-daemon clients:java:jacocoTestReport
- run: bash <(curl -s https://codecov.io/bash)
- store_test_results:
path: build/test-results/test
Expand Down Expand Up @@ -95,12 +94,12 @@ jobs:
docker:
- image: circleci/openjdk:8-jdk
steps:
- *checkout_project_root
- checkout
- restore_cache:
keys:
- v1-integration-spark-{{ .Branch }}-{{ .Revision }}
- v1-integration-spark-{{ .Branch }}
- run: ./gradlew --no-daemon --stacktrace build
- run: ./gradlew --no-daemon --stacktrace :experimental:integrations:marquez-spark-agent:build
- save_cache:
key: v1-integration-spark-{{ .Branch }}-{{ .Revision }}
paths:
Expand Down Expand Up @@ -131,7 +130,6 @@ jobs:
<<: *machine
steps:
- checkout
- run: ./.circleci/get-jdk11.sh
- run: ./docker/login.sh
- run: ./docker/build-and-push.sh $CIRCLE_TAG

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ out/*

# Marquez configuration
marquez.yml

# jenv
.java-version
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ To run the entire test suite:
$ ./gradlew test
```

You can also run individual tests using the flag `--tests`:
You can also run individual tests for a [submodule](https://github.com/MarquezProject/marquez#modules) using the `--tests` flag:

```bash
$ ./gradlew test --tests marquez.api.DatasetResourceTest
$ ./gradlew test --tests marquez.service.DatasetServiceTest
$ ./gradlew test --tests marquez.db.DatasetDaoTest
$ ./gradlew :api:test --tests marquez.api.DatasetResourceTest
$ ./gradlew :api:test --tests marquez.service.DatasetServiceTest
$ ./gradlew :api:test --tests marquez.db.DatasetDaoTest
```

Or run tests by category:

```bash
$ ./gradlew testUnit # run only unit tests
$ ./gradlew testIntegration # run only integration tests
$ ./gradlew testDataAccess # run only data access tests
$ ./gradlew :api:testUnit # run only unit tests
$ ./gradlew :api:testIntegration # run only integration tests
$ ./gradlew :api:testDataAccess # run only data access tests
```

We use [spotless](https://github.com/diffplug/spotless) to format our code. This ensures `.java` files are formatted to comply with [Google Java Style](https://google.github.io/styleguide/javaguide.html). Make sure your code is formatted before pushing any changes, otherwise CI will fail:
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ RUN ./gradlew --version

FROM base AS build
WORKDIR /usr/src/app
COPY api/src ./api/src
COPY build.gradle build.gradle
RUN ./gradlew --no-daemon shadowJar
COPY api ./api
COPY api/build.gradle ./api/build.gradle
COPY clients/java ./clients/java
RUN ./gradlew --no-daemon :api:shadowJar

FROM openjdk:11-jre
RUN apt-get update && apt-get install -y --no-install-recommends postgresql-client
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/build/libs/marquez-*.jar /usr/src/app
COPY --from=build /usr/src/app/api/build/libs/marquez-*.jar /usr/src/app
COPY marquez.dev.yml marquez.dev.yml
COPY docker/entrypoint.sh entrypoint.sh
EXPOSE 5000 5001
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ We invite everyone to help us improve and keep documentation up to date. Documen

Marquez uses a _multi_-project structure and contains the following modules:

* [`api`](https://github.com/MarquezProject/marquez/tree/main/api): core API used to collect metadata
* [`web`](https://github.com/MarquezProject/marquez/tree/main/web): web UI used to view metadata
* [`clients`](https://github.com/MarquezProject/marquez/tree/main/clients): clients that implement the HTTP [API](https://marquezproject.github.io/marquez/openapi.html)
* [`integrations`](https://github.com/MarquezProject/marquez/tree/main/integrations): integrations with other systems
* [`integrations`](https://github.com/MarquezProject/marquez/tree/main/integrations): integrations with other systems (ex: [`Airflow`](https://github.com/MarquezProject/marquez/tree/feature/ci-build-jvm-modules/examples/airflow))
* [`chart`](https://github.com/MarquezProject/marquez/tree/main/chart): helm chart

## Requirements
Expand All @@ -64,13 +65,13 @@ Marquez uses a _multi_-project structure and contains the following modules:
## Building

To build the entire project run:
To build the [`api`](https://github.com/MarquezProject/marquez/tree/main/api) module run:

```
$ ./gradlew shadowJar
$ ./gradlew :api:shadowJar
```

The executable can be found under `build/libs/`
The executable can be found under `api/build/libs/`

## Configuration

Expand Down Expand Up @@ -104,7 +105,7 @@ By default, Marquez uses the following ports:
## Running the [Application](https://github.com/MarquezProject/marquez/blob/main/src/main/java/marquez/MarquezApp.java)

```bash
$ ./gradlew runShadow
$ ./gradlew :api:runShadow
```

Then browse to the admin interface: http://localhost:8081
Expand Down
163 changes: 163 additions & 0 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer
import org.apache.tools.ant.filters.*

plugins {
id 'maven-publish'
id 'signing'
id 'net.researchgate.release' version '2.8.1'
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

ext {
dropwizardVersion = '2.0.15'
jdbi3Version = '3.17.0'
lombokVersion = '1.18.12'
prometheusVersion = '0.9.0'
}

dependencies {
compile "io.dropwizard:dropwizard-core:${dropwizardVersion}"
compile "io.dropwizard:dropwizard-jdbi3:${dropwizardVersion}"
compile "io.dropwizard:dropwizard-json-logging:${dropwizardVersion}"
compile "io.dropwizard:dropwizard-http2:${dropwizardVersion}"
compile "io.prometheus:simpleclient:${prometheusVersion}"
compile "io.prometheus:simpleclient_dropwizard:${prometheusVersion}"
compile "io.prometheus:simpleclient_hotspot:${prometheusVersion}"
compile "io.prometheus:simpleclient_servlet:${prometheusVersion}"
compile "org.jdbi:jdbi3-postgres:${jdbi3Version}"
compile "org.jdbi:jdbi3-sqlobject:${jdbi3Version}"
compile 'com.google.guava:guava:30.0-jre'
compile 'org.flywaydb:flyway-core:6.3.0'
compile 'org.postgresql:postgresql:42.2.5'
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"

testCompile project(':clients:java')
testCompile "io.dropwizard:dropwizard-testing:${dropwizardVersion}"
testCompile "org.jdbi:jdbi3-testing:${jdbi3Version}"
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:3.11.1'
testCompile 'org.mockito:mockito-core:3.3.3'
testCompile 'org.testcontainers:postgresql:1.13.0'
}

task testUnit(type: Test) {
useJUnit {
includeCategories 'marquez.UnitTests'
}
}

task testIntegration(type: Test) {
useJUnit {
includeCategories 'marquez.IntegrationTests'
}
}

task testDataAccess(type: Test) {
useJUnit {
includeCategories 'marquez.DataAccessTests'
}
}

release {
git {
requireBranch = 'main'
}
}

publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'io.github.marquezproject'
artifactId = 'marquez-api'

from components.java

artifact sourceJar
artifact javadocJar

pom {
name = 'marquez'
description = 'Collect, aggregate, and visualize a data ecosystem\'s metadata'
url = 'https://github.com/MarquezProject/marquez'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'marquezproject'
name = 'Marquez Project'
}
}
scm {
connection = 'scm:git:git://github.com/MarquezProject/marquez.git'
developerConnection = 'scm:git:ssh://github.com:MarquezProject/marquez.git'
url = 'https://github.com/MarquezProject/marquez'
}
}
}
}

processResources {
filter ReplaceTokens, tokens: [
"version": project.property("version")
]
}

repositories {
maven {
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
credentials {
username = System.getenv('SONATYPE_NEXUS_USERNAME')
password = System.getenv('SONATYPE_NEXUS_PASSWORD')
}
}
}
}

signing {
required { isReleaseVersion }
sign publishing.publications.mavenJava
}


mainClassName = 'marquez.MarquezApp'

shadowJar {
classifier = ''
transform(ServiceFileTransformer)
manifest {
attributes(
'Created-By': "Gradle ${gradle.gradleVersion}",
'Built-By': System.getProperty('user.name'),
'Build-Jdk': System.getProperty('java.version'),
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Main-Class': mainClassName)
}
}

runShadow {
args = ['server', '../marquez.yml']
}
2 changes: 1 addition & 1 deletion api/src/test/java/marquez/SparkAgentIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class SparkAgentIntegrationTest extends BaseIntegrationTest {
@Parameters(name = "{0}")
public static List<Path> data() throws IOException {
String prefix = "experimental/integrations/marquez-spark-agent/integrations";
String prefix = "../experimental/integrations/marquez-spark-agent/integrations";
List<Path> paths = Files.list(Paths.get(prefix + "/sparkrdd")).collect(Collectors.toList());
List<Path> sql = Files.list(Paths.get(prefix + "/sparksql")).collect(Collectors.toList());
paths.addAll(sql);
Expand Down
Loading

0 comments on commit 9824cc0

Please sign in to comment.