Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
jachro committed Aug 8, 2023
2 parents 54d830f + 17b9f64 commit c394be7
Show file tree
Hide file tree
Showing 636 changed files with 8,334 additions and 4,810 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.7.11"
version = "3.7.12"

runner.dialect = "scala213"

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ sequenceDiagram
activate EventLog
EventLog ->> TokenRepository: fetches access token
EventLog ->> GitLab: calls the Project Details
loop if there project path is NOT the same in EventLog and GitLab
EventLog ->> CommitEventService: sends COMMIT_SYNC for the new path
EventLog ->> TriplesGenerator: sends CLEAN_UP_REQUEST for the old path
loop if the project slug is NOT the same in EventLog and GitLab
EventLog ->> CommitEventService: sends COMMIT_SYNC for the new slug
EventLog ->> TriplesGenerator: sends CLEAN_UP_REQUEST for the old slug
end
EventLog ->> TriplesGenerator: sends SYNC_REPO_METADATA
activate TriplesGenerator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CommitHistoryChangesSpec

Then("the project and its datasets should be removed from the knowledge-graph")

knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.path}", user.accessToken).status shouldBe NotFound
knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.slug}", user.accessToken).status shouldBe NotFound

project.entitiesProject.datasets foreach { dataset =>
knowledgeGraphClient
Expand All @@ -129,7 +129,7 @@ class CommitHistoryChangesSpec

private def assertProjectDataIsCorrect(project: data.Project, testProject: RenkuProject, accessToken: AccessToken) = {

val projectDetailsResponse = knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.path}", accessToken)
val projectDetailsResponse = knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.slug}", accessToken)

projectDetailsResponse.status shouldBe Ok
val projectDetails = projectDetailsResponse.jsonBody
Expand All @@ -146,14 +146,14 @@ class CommitHistoryChangesSpec

responseStatus shouldBe Ok
val foundDatasets = responseBody.as[List[Json]].value
foundDatasets should contain theSameElementsAs testProject.datasets.map(briefJson(_, project.path))
foundDatasets should contain theSameElementsAs testProject.datasets.map(briefJson(_, project.slug))
}

private def generateNewActivitiesAndDataset(projectEntities: RenkuProject): RenkuProject =
renkuProjectEntities(visibilityPublic, creatorGen = cliShapedPersons).generateOne
.copy(
version = projectEntities.version,
path = projectEntities.path,
slug = projectEntities.slug,
name = projectEntities.name,
maybeDescription = projectEntities.maybeDescription,
agent = projectEntities.agent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class FastTractEventRouteSpec

Then("the project data should exist in the KG")
eventually {
val response = knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.path}")
val response = knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.slug}")
response.status shouldBe Ok
response.jsonBody.hcursor.downField("path").as[String].value shouldBe project.path.show
response.jsonBody.hcursor.downField("path").as[String].value shouldBe project.slug.show
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ProjectReProvisioningSpec extends AcceptanceSpec with ApplicationServices

eventually {
knowledgeGraphClient
.GET(s"knowledge-graph/projects/${project.path}", accessToken)
.GET(s"knowledge-graph/projects/${project.slug}", accessToken)
.jsonBody
.as[Json]
.flatMap(_.hcursor.downField("version").as[SchemaVersion]) shouldBe project.entitiesProject.version.asRight
Expand All @@ -78,7 +78,7 @@ class ProjectReProvisioningSpec extends AcceptanceSpec with ApplicationServices
eventLogClient.sendEvent(json"""{
"categoryName": "CLEAN_UP_REQUEST",
"project": {
"path": ${project.path}
"slug": ${project.slug}
}
}""")

Expand All @@ -87,7 +87,7 @@ class ProjectReProvisioningSpec extends AcceptanceSpec with ApplicationServices

eventually {
knowledgeGraphClient
.GET(s"knowledge-graph/projects/${project.path}", accessToken)
.GET(s"knowledge-graph/projects/${project.slug}", accessToken)
.jsonBody
.as[Json]
.flatMap(_.hcursor.downField("version").as[SchemaVersion]) shouldBe newProjectVersion.asRight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import io.renku.events.CategoryName
import io.renku.generators.CommonGraphGenerators.authUsers
import io.renku.generators.Generators.Implicits._
import io.renku.graph.model.EventsGenerators.commitIds
import io.renku.graph.model.GraphModelGenerators.projectPaths
import io.renku.graph.model.GraphModelGenerators.projectSlugs
import io.renku.graph.model.testentities.cliShapedPersons
import io.renku.graph.model.testentities.generators.EntitiesGenerators.{removeMembers, renkuProjectEntities, visibilityPublic}
import org.http4s.Status.{NotFound, Ok}
Expand Down Expand Up @@ -56,13 +56,13 @@ class ProjectSyncFlowSpec extends AcceptanceSpec with ApplicationServices with T

Then("the project data should exist in the KG")
eventually {
val response = knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.path}")
val response = knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.slug}")
response.status shouldBe Ok
response.jsonBody.hcursor.downField("path").as[String] shouldBe project.path.show.asRight
response.jsonBody.hcursor.downField("path").as[String] shouldBe project.slug.show.asRight
}

When("project_path changes in GitLab")
val updatedProject = project.copy(entitiesProject = testProject.copy(path = projectPaths.generateOne))
val updatedProject = project.copy(entitiesProject = testProject.copy(slug = projectSlugs.generateOne))
gitLabStub.replaceProject(updatedProject)
givenAccessTokenPresentFor(updatedProject, user.accessToken)
resetTriplesGenerator()
Expand All @@ -74,13 +74,13 @@ class ProjectSyncFlowSpec extends AcceptanceSpec with ApplicationServices with T

Then("the updated project data should exist in the KG")
eventually {
val response = knowledgeGraphClient.GET(s"knowledge-graph/projects/${updatedProject.path}")
val response = knowledgeGraphClient.GET(s"knowledge-graph/projects/${updatedProject.slug}")
response.status shouldBe Ok
response.jsonBody.hcursor.downField("path").as[String] shouldBe updatedProject.path.show.asRight
response.jsonBody.hcursor.downField("path").as[String] shouldBe updatedProject.slug.show.asRight
}

And("the old project data should be removed")
knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.path}").status shouldBe NotFound
knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.slug}").status shouldBe NotFound
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ReProvisioningSpec extends AcceptanceSpec with ApplicationServices with TS

`data in the Triples Store`(project, commitId, accessToken)

val projectDetailsResponse = knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.path}", accessToken)
val projectDetailsResponse = knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.slug}", accessToken)

projectDetailsResponseIsValid(projectDetailsResponse, initialProjectSchemaVersion)

Expand All @@ -83,7 +83,7 @@ class ReProvisioningSpec extends AcceptanceSpec with ApplicationServices with TS

eventually {
val updatedProjectDetailsResponse =
knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.path}", accessToken)
knowledgeGraphClient.GET(s"knowledge-graph/projects/${project.slug}", accessToken)
projectDetailsResponseIsValid(updatedProjectDetailsResponse, newSchemaVersion)
}(PatienceConfig(timeout = Span(20, Minutes), interval = Span(10, Seconds)),
Retrying.retryingNatureOfT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ class ZombieEventDetectionSpec
}

private def insertProjectToDB(project: data.Project, eventDate: EventDate): Int = EventLog.execute { session =>
val query: Command[GitLabId *: Path *: EventDate *: EmptyTuple] =
sql"""INSERT INTO project (project_id, project_path, latest_event_date)
VALUES ($projectIdEncoder, $projectPathEncoder, $eventDateEncoder)
ON CONFLICT (project_id)
DO UPDATE SET latest_event_date = excluded.latest_event_date WHERE excluded.latest_event_date > project.latest_event_date
""".command
val query: Command[GitLabId *: Slug *: EventDate *: EmptyTuple] =
sql"""INSERT INTO project (project_id, project_slug, latest_event_date)
VALUES ($projectIdEncoder, $projectSlugEncoder, $eventDateEncoder)
ON CONFLICT (project_id)
DO UPDATE SET latest_event_date = excluded.latest_event_date WHERE excluded.latest_event_date > project.latest_event_date
""".command
session
.prepare(query)
.flatMap(_.execute(project.id *: project.path *: eventDate *: EmptyTuple))
.flatMap(_.execute(project.id *: project.slug *: eventDate *: EmptyTuple))
.flatMap {
case Completion.Insert(n) => n.pure[IO]
case completion =>
Expand Down Expand Up @@ -143,10 +143,10 @@ class ZombieEventDetectionSpec
eventDate *:
BatchDate(eventDate.value) *:
EventBody(json"""{
"id": ${commitId.value},
"id": $commitId,
"project": {
"id": ${project.id.value},
"path": ${project.path.value}
"id": ${project.id},
"slug": ${project.slug}
},
"parents": []
}""".noSpaces) *:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import io.renku.graph.model.events.CommitId
object GitLab {

def pushEvent(project: Project, commitId: CommitId): Json = json"""{
"after": ${commitId.value},
"user_id": ${positiveInts().generateOne.value},
"after": $commitId,
"user_id": ${positiveInts().generateOne.value},
"user_username": ${nonEmptyStrings().generateOne},
"user_email": ${personEmails.generateOne.value},
"user_email": ${personEmails.generateOne},
"project": {
"id": ${project.id.value},
"path_with_namespace": ${project.path.value}
"id": ${project.id},
"path_with_namespace": ${project.slug}
}
}"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import eu.timepit.refined.collection.NonEmpty
import eu.timepit.refined.numeric.Positive
import io.renku.graph.acceptancetests.data.Project._
import io.renku.graph.model.entities.Project.ProjectMember
import io.renku.graph.model.projects.{GitLabId, Name, Path}
import io.renku.graph.model.projects.{GitLabId, Name, Slug}
import io.renku.graph.model.testentities
import io.renku.tinytypes._
import io.renku.tinytypes.constraints._
Expand All @@ -42,7 +42,7 @@ final case class Project(entitiesProject: testentities.RenkuProject,
permissions: Permissions,
statistics: Statistics
) {
val path: Path = entitiesProject.path
val slug: Slug = entitiesProject.slug
val name: Name = entitiesProject.name
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ package object data extends TSData with ProjectFunctions {
private lazy val starsCounts: Gen[StarsCount] = nonNegativeInts() map (v => StarsCount(v.value))
private lazy val sshUrls: Gen[SshUrl] = for {
hostParts <- nonEmptyList(nonBlankStrings())
projectPath <- projectPaths
} yield SshUrl(s"git@${hostParts.toList.mkString(".")}:$projectPath.git")
projectSlug <- projectSlugs
} yield SshUrl(s"git@${hostParts.toList.mkString(".")}:$projectSlug.git")

private lazy val httpUrls: Gen[HttpUrl] = for {
url <- urls()
projectPath <- projectPaths
} yield HttpUrl(s"$url/$projectPath.git")
projectSlug <- projectSlugs
} yield HttpUrl(s"$url/$projectSlug.git")

private lazy val readmeUrls: Gen[ReadmeUrl] = for {
url <- urls()
projectPath <- projectPaths
} yield ReadmeUrl(s"$url/$projectPath/blob/master/README.md")
projectSlug <- projectSlugs
} yield ReadmeUrl(s"$url/$projectSlug/blob/master/README.md")

private lazy val webUrls: Gen[WebUrl] = urls() map WebUrl.apply

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import tooling.{AcceptanceSpec, ApplicationServices}

class EventsResourceSpec extends AcceptanceSpec with ApplicationServices with TSProvisioning {

Feature("GET /events?project-path=<path> to return info about all the project events") {
Feature("GET /events?project-slug=<slug> to return info about all the project events") {

Scenario("As a user I would like to see all events from the project with the given path") {
Scenario("As a user I would like to see all events from the project with the given slug") {

val commits = commitIds.generateNonEmptyList(max = 6)
val user = authUsers.generateOne
Expand All @@ -50,7 +50,7 @@ class EventsResourceSpec extends AcceptanceSpec with ApplicationServices with TS
.generateOne

Given("there are no events for the given project in EL")
val noEventsResponse = eventLogClient.GET(s"events?project-path=${urlEncode(project.path.show)}")
val noEventsResponse = eventLogClient.GET(s"events?project-slug=${urlEncode(project.slug.show)}")
noEventsResponse.status shouldBe Ok
noEventsResponse.jsonBody.as[List[Json]] shouldBe Nil.asRight

Expand All @@ -64,7 +64,7 @@ class EventsResourceSpec extends AcceptanceSpec with ApplicationServices with TS

eventually {
Then("the user can see the events on the endpoint")
val eventsResponse = eventLogClient.GET(s"events?project-path=${urlEncode(project.path.show)}")
val eventsResponse = eventLogClient.GET(s"events?project-slug=${urlEncode(project.slug.show)}")
eventsResponse.status shouldBe Ok
val Right(events) = eventsResponse.jsonBody.as[List[EventInfo]]
events.size shouldBe commits.size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ trait DatasetsApiEncoders extends ImageApiEncoders {

def briefJson(dataset: Dataset[Dataset.Provenance.Modified],
originalDs: Dataset[Dataset.Provenance],
projectPath: projects.Path
projectSlug: projects.Slug
)(implicit
encoder: Encoder[(Dataset[Dataset.Provenance], Option[Dataset[Dataset.Provenance]], projects.Path)]
): Json = encoder((dataset, Some(originalDs), projectPath))
encoder: Encoder[(Dataset[Dataset.Provenance], Option[Dataset[Dataset.Provenance]], projects.Slug)]
): Json = encoder((dataset, Some(originalDs), projectSlug))

def briefJson(dataset: Dataset[Dataset.Provenance], projectPath: projects.Path)(implicit
encoder: Encoder[(Dataset[Dataset.Provenance], Option[Dataset[Dataset.Provenance]], projects.Path)]
): Json = encoder((dataset, Option.empty, projectPath))
def briefJson(dataset: Dataset[Dataset.Provenance], projectSlug: projects.Slug)(implicit
encoder: Encoder[(Dataset[Dataset.Provenance], Option[Dataset[Dataset.Provenance]], projects.Slug)]
): Json = encoder((dataset, Option.empty, projectSlug))

implicit def datasetEncoder[P <: Dataset.Provenance](implicit
provenanceEncoder: Encoder[P]
): Encoder[(Dataset[P], Option[Dataset[Dataset.Provenance]], projects.Path)] = Encoder.instance {
case (dataset, maybeOriginalDs, projectPath) =>
): Encoder[(Dataset[P], Option[Dataset[Dataset.Provenance]], projects.Slug)] = Encoder.instance {
case (dataset, maybeOriginalDs, projectSlug) =>
json"""{
"identifier": ${dataset.identification.identifier.value},
"versions": {
Expand All @@ -60,14 +60,14 @@ trait DatasetsApiEncoders extends ImageApiEncoders {
"title": ${dataset.identification.title.value},
"name": ${dataset.identification.name.value},
"slug": ${dataset.identification.name.value},
"images": ${dataset.additionalInfo.images -> projectPath}
"images": ${dataset.additionalInfo.images -> projectSlug}
}"""
.deepMerge(
_links(
Rel("details") -> Href(renkuApiUrl / "datasets" / dataset.identification.identifier),
Rel("initial-version") -> Href(renkuApiUrl / "datasets" / dataset.provenance.originalIdentifier),
Rel("tags") -> Href(
renkuApiUrl / "projects" / projectPath / "datasets" / dataset.identification.name / "tags"
renkuApiUrl / "projects" / projectSlug / "datasets" / dataset.identification.name / "tags"
)
)
)
Expand Down Expand Up @@ -106,7 +106,7 @@ trait DatasetsApiEncoders extends ImageApiEncoders {

def searchResultJson[P <: Dataset.Provenance](dataset: Dataset[P],
projectsCount: Int,
projectPath: projects.Path,
projectSlug: projects.Slug,
actualResults: List[Json]
): Json = {
val actualIdentifier = actualResults
Expand All @@ -124,7 +124,7 @@ trait DatasetsApiEncoders extends ImageApiEncoders {
"date": ${dataset.provenance.date.instant},
"projectsCount": $projectsCount,
"keywords": ${dataset.additionalInfo.keywords.sorted.map(_.value)},
"images": ${dataset.additionalInfo.images -> projectPath}
"images": ${dataset.additionalInfo.images -> projectSlug}
}"""
.addIfDefined("description" -> dataset.additionalInfo.maybeDescription)
.deepMerge {
Expand Down
Loading

0 comments on commit c394be7

Please sign in to comment.