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

docs(api): get openapi files from dependencies repository #1402

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/publish-swaggerhub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ jobs:
run: |
./gradlew resolve

- name: Download upstream API specs
run: |
curl -X GET https://eclipse-edc.github.io/Connector/openapi/management-api/management-api.yaml > resources/openapi/yaml/upstream-management-api.yaml
curl -X GET https://eclipse-edc.github.io/Connector/openapi/control-api/control-api.yaml > resources/openapi/yaml/upstream-control-api.yaml
- name: Download upstream API specs for control-plane and data-plane
run: |
./gradlew :edc-controlplane:edc-controlplane-base:downloadOpenapi
cp edc-controlplane/edc-controlplane-base/build/docs/openapi/* resources/openapi/yaml/

./gradlew :edc-dataplane:edc-dataplane-base:downloadOpenapi
cp edc-dataplane/edc-dataplane-base/build/docs/openapi/* resources/openapi/yaml/

- name: Merge API specs
run: |
Expand Down
457 changes: 235 additions & 222 deletions DEPENDENCIES

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,43 @@ nexusPublishing {
tasks.check {
dependsOn(tasks.named<JacocoReport>("testCodeCoverageReport"))
}

tasks.register("downloadOpenapi") {
outputs.dir(project.layout.buildDirectory.dir("docs/openapi"))
doLast {
val destinationDirectory = layout.buildDirectory.asFile.get().toPath()
.resolve("docs").resolve("openapi")

configurations.asMap.values
.asSequence()
.filter { it.isCanBeResolved }
.map { it.resolvedConfiguration.firstLevelModuleDependencies }.flatten()
.map { childrenDependencies(it) }.flatten()
.distinct()
.forEach { dep ->
downloadYamlArtifact(dep, "management-api", destinationDirectory);
downloadYamlArtifact(dep, "observability-api", destinationDirectory);
downloadYamlArtifact(dep, "public-api", destinationDirectory);
}
}
}

fun childrenDependencies(dependency: ResolvedDependency): List<ResolvedDependency> {
return listOf(dependency) + dependency.children.map { child -> childrenDependencies(child) }.flatten()
}

fun downloadYamlArtifact(dep: ResolvedDependency, classifier: String, destinationDirectory: java.nio.file.Path) {
try {
val managementApi = dependencies.create(dep.moduleGroup, dep.moduleName, dep.moduleVersion, classifier = classifier, ext = "yaml")
configurations
.detachedConfiguration(managementApi)
.resolve()
.forEach { file ->
destinationDirectory
.resolve("${dep.moduleName}.yaml")
.toFile()
.let(file::copyTo)
}
} catch (_: Exception) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ dependencies {
// so we need to add PG support explicitly
// https://documentation.red-gate.com/flyway/release-notes-and-older-versions/release-notes-for-flyway-engine
runtimeOnly(libs.flyway.database.postgres)

testImplementation(testFixtures(libs.edc.sql.core))
}
3 changes: 3 additions & 0 deletions edc-tests/edc-controlplane/catalog-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ dependencies {
testImplementation(libs.edc.junit)
testImplementation(libs.restAssured)
testImplementation(libs.awaitility)

testCompileOnly(project(":edc-tests:runtime:runtime-memory"))
testCompileOnly(project(":edc-tests:runtime:runtime-postgresql"))
}

// do not publish
Expand Down
7 changes: 3 additions & 4 deletions edc-tests/edc-controlplane/fixtures/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ dependencies {
testFixturesImplementation(libs.edc.identity.trust.sts.embedded)
testFixturesImplementation(libs.edc.core.token)
testFixturesImplementation(libs.edc.spi.identity.did)
testFixturesImplementation(testFixtures(libs.edc.sql.core))
testFixturesImplementation(libs.postgres)
testFixturesImplementation(libs.testcontainers.postgres)

testCompileOnly(project(":edc-tests:runtime:runtime-memory"))

testFixturesImplementation(libs.assertj)
testFixturesImplementation(libs.junit.jupiter.api)
testFixturesImplementation(project(":edc-extensions:bpn-validation:bpn-validation-spi"))

testCompileOnly(project(":edc-tests:runtime:runtime-memory"))
testCompileOnly(project(":edc-tests:runtime:runtime-postgresql"))
}

// do not publish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.eclipse.tractusx.edc.tests.runtimes;

import org.eclipse.edc.junit.extensions.EmbeddedRuntime;
import org.eclipse.edc.junit.extensions.RuntimePerClassExtension;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
Expand All @@ -40,10 +39,6 @@ public ParticipantRuntimeExtension(String moduleName, String runtimeName, String
}
}

public ParticipantRuntimeExtension(EmbeddedRuntime embeddedRuntime) {
super(embeddedRuntime);
}

@Override
public void afterEach(ExtensionContext extensionContext) {
((ParticipantRuntime) runtime).getWiper().clearPersistence();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

package org.eclipse.tractusx.edc.tests.runtimes;

import org.eclipse.edc.sql.testfixtures.PostgresqlLocalInstance;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.wait.strategy.Wait;

import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -45,7 +46,7 @@ public class PgRuntimeExtension extends ParticipantRuntimeExtension {
private final String dbName;

public PgRuntimeExtension(String moduleName, String runtimeName, String bpn, Map<String, String> properties) {
super(new ParticipantRuntime(moduleName, runtimeName, bpn, properties));
super(moduleName, runtimeName, bpn, properties, null);
this.dbName = runtimeName.toLowerCase();
postgreSqlContainer = new PostgreSQLContainer<>(POSTGRES_IMAGE_NAME)
.withLabel("runtime", dbName)
Expand All @@ -62,8 +63,7 @@ public void beforeAll(ExtensionContext context) {
postgreSqlContainer.waitingFor(Wait.forHealthcheck());
var config = postgresqlConfiguration(dbName);
config.forEach(System::setProperty);
PostgresqlLocalInstance helper = new PostgresqlLocalInstance(postgreSqlContainer.getUsername(), postgreSqlContainer.getPassword(), baseJdbcUrl(), postgreSqlContainer.getDatabaseName());
helper.createDatabase();
createDatabase();
super.beforeAll(context);
}

Expand Down Expand Up @@ -95,6 +95,14 @@ public String jdbcUrl(String name) {
return baseJdbcUrl() + name + "?currentSchema=" + DB_SCHEMA_NAME;
}

private void createDatabase() {
try (var connection = DriverManager.getConnection(baseJdbcUrl() + "postgres", postgreSqlContainer.getUsername(), postgreSqlContainer.getPassword())) {
connection.createStatement().execute(String.format("create database %s;", postgreSqlContainer.getDatabaseName()));
} catch (SQLException ignored) {

}
}

public String baseJdbcUrl() {
return format("jdbc:postgresql://%s:%s/", postgreSqlContainer.getHost(), postgreSqlContainer.getFirstMappedPort());
}
Expand Down
1 change: 1 addition & 0 deletions edc-tests/runtime/runtime-postgresql/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies {
implementation(libs.edc.core.controlplane)
// for the controller
implementation(libs.jakarta.rsApi)
runtimeOnly(libs.edc.transaction.local)
}

application {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
format.version = "1.1"

[versions]
edc = "0.7.2-20240704-SNAPSHOT"
edc = "0.7.2-20240709-SNAPSHOT"
assertj = "3.26.0"
awaitility = "4.2.1"
aws = "2.26.14"
Expand Down
Loading