Skip to content

Commit

Permalink
e2e-test integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarponi committed Mar 5, 2024
1 parent 3673722 commit a65037a
Show file tree
Hide file tree
Showing 29 changed files with 1,361 additions and 11 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Run E2E tests

on:
push:
branches: [ fabrizio.scarponi/e2e-test ]

jobs:
run-e2e-tests:
continue-on-error: true
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
# gradle-versions: [ '5.6.4', '6.9.2', '7.6.4', '8.6', 'latest' ]
gradle-versions: [ '6.9.2', '8.6' ]
name: Gradle ${{ matrix.gradle-versions }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: gradle/gradle-build-action@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: |
8
17
distribution: 'temurin'
cache: gradle
- name: Run Gradle tests
env:
GRADLE_VERSION: ${{ matrix.gradle-versions }}
GRADLE_ENTERPRISE_KEY: ${{ secrets.GRADLE_ENTERPRISE_KEY }}
run: ./gradlew :plugin:test
- name: Upload test result
if: always()
uses: actions/upload-artifact@v4
with:
name: testResult
path: /Users/runner/work/package-search-intellij-plugin/package-search-intellij-plugin/plugin/build/testData
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ out/
*.iml
.gradle/
.gitsubmoduleinit
allure-results/

!.idea/codeStyles/*
!.idea/dictionaries/*
1 change: 1 addition & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@file:Suppress("UnstableApiUsage")

import java.lang.System.getenv
import org.jetbrains.packagesearch.gradle.getStringOrNull
import org.jetbrains.packagesearch.gradle.pkgsSpace

plugins {
Expand All @@ -26,6 +27,16 @@ allprojects {
maven("https://repo.gradle.org/gradle/libs-releases")
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://packages.jetbrains.team/maven/p/kpm/public")
maven("https://www.jetbrains.com/intellij-repository/snapshots")
maven("https://cache-redirector.jetbrains.com/intellij-dependencies")
maven("https://packages.jetbrains.team/maven/p/ij/intellij-sdk-nightly") {
credentials {
username = getenv("MAVEN_SPACE_INTELLIJ_USERNAME")
?: project.extra.getStringOrNull("space.intellij.username")
password = getenv("MAVEN_SPACE_INTELLIJ_PASSWORD")
?: project.extra.getStringOrNull("space.intellij.password")
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fun Project.configureGradleIntellijPlugin(packageSearchExtension: PackageSearchE

plugins.withId("org.jetbrains.intellij") {
extensions.withType<IntelliJPluginExtension> {
version = "LATEST-TRUNK-SNAPSHOT"
version = "LATEST-EAP-SNAPSHOT"
instrumentCode = false
downloadSources = !isCI
}
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ kotlin.native.ignoreDisabledTargets=true
org.gradle.java.installations.auto-detect=false
kotlin.incremental.useClasspathSnapshot=false
org.gradle.parallel=true
pkgsPluginId=com.jetbrains.packagesearch.intellij-plugin
pkgsPluginId=com.jetbrains.packagesearch.intellij-plugin
pkgsPluginTestOutputDir=out/pkgsTestData
Binary file added out/perf-startup/cache/7zip/7z-cmdline-15.06.zip
Binary file not shown.
7 changes: 5 additions & 2 deletions packagesearch.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ logback = "1.4.11"
nitrite = "3.4.4"
packagesearchApiModels = "3.0.0-SNAPSHOT"
jewel = "0.15.0"
intelliJJunit5 = "LATEST-EAP-SNAPSHOT"

[libraries]
assertk = { module = "com.willowtreeapps.assertk:assertk-jvm", version.ref = "assertk" }
caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version.ref = "caffeine" }
commons-codec = { module="commons-codec:commons-codec", version.ref = "commonsCodec" }
commons-codec = { module = "commons-codec:commons-codec", version.ref = "commonsCodec" }
detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
foojay-resolver-gradle-plugin = { module = "org.gradle.toolchains:foojay-resolver", version.ref = "foojay" }
Expand All @@ -44,6 +45,8 @@ junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.re
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" }
junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "junit" }
ide-starter-junit5 = { module = "com.jetbrains.intellij.tools:ide-starter-junit5", version.ref = "intelliJJunit5" }
ide-starter-squashed = { module = "com.jetbrains.intellij.tools:ide-starter-squashed", version.ref = "intelliJJunit5" }
junit4-base = { module = "junit:junit", version.ref = "junit4" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
Expand Down Expand Up @@ -80,7 +83,7 @@ compose-desktop-jvm-macos-arm64 = { module = "org.jetbrains.compose.desktop:desk
detekt-gradle-plugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlinter-gradle-plugin = { module = "org.jmailen.gradle:kotlinter-gradle", version.ref = "kotlinterGradlePlugin" }
shadow-gradle-plugin = { module="com.github.johnrengelman:shadow", version="8.1.1" }
shadow-gradle-plugin = { module = "com.github.johnrengelman:shadow", version = "8.1.1" }

[bundles]
idea = ["ij-platform-ide-core", "ij-platform-ide-impl", "ij-platform-core-ui"]
Expand Down
37 changes: 34 additions & 3 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ packagesearch {

intellij {
plugins.add("org.jetbrains.idea.reposearch")
plugins.add("com.jetbrains.performancePlugin")
}

val tooling: Configuration by configurations.creating {
Expand Down Expand Up @@ -82,10 +83,15 @@ dependencies {

testImplementation(kotlin("test-junit5"))
testImplementation(packageSearchCatalog.junit.jupiter.api)
testImplementation(packageSearchCatalog.junit.jupiter.params)
testImplementation(packageSearchCatalog.ide.starter.junit5)
testImplementation(packageSearchCatalog.ide.starter.squashed)
testImplementation(packageSearchCatalog.kotlinx.coroutines.test)
testRuntimeOnly(packageSearchCatalog.junit.jupiter.engine)
}

val pkgsPluginId: String by project
val pkgsPluginTestOutputDir: String by project

tasks {
val patchIdeSettings by registering {
Expand Down Expand Up @@ -124,6 +130,10 @@ tasks {

}

val pluginArtifactName = "packageSearch-${project.version}.zip"
.replace("-SNAPSHOT", ".$snapshotMinorVersion")
val pluginArtifactDirectory = layout.buildDirectory.dir("distributions")
val testDataDirectory = layout.buildDirectory.dir("testData")
val buildShadowPlugin by registering(Zip::class) {
group = "intellij"
from(shadowJar) {
Expand All @@ -133,9 +143,30 @@ tasks {
rename { "gradle-tooling.jar" }
}
into("$pkgsPluginId/lib")
archiveFileName = "packageSearch-${project.version}.zip"
.replace("-SNAPSHOT", ".$snapshotMinorVersion")
destinationDirectory = layout.buildDirectory.dir("distributions")
archiveFileName = pluginArtifactName
destinationDirectory = pluginArtifactDirectory
}

val testDataDirectoryPath = testDataDirectory.map { it.asFile.absolutePath }

test {
dependsOn(buildShadowPlugin)

environment("PKGS_PLUGIN_ID", pkgsPluginId)
environment("PKGS_TEST_DATA_OUTPUT_DIR", testDataDirectoryPath.get())
val pluginArtifactDirectoryPath =
pluginArtifactDirectory.map { it.file(pluginArtifactName).asFile.absolutePath }
environment("PKGS_PLUGIN_ARTIFACT_FILE", pluginArtifactDirectoryPath.get())
}

// register<Zip>("packageTestData") {
// from(testDataDirectory)
// archiveFileName.set("testData.zip")
// destinationDirectory.set(pluginArtifactDirectory)
// }

runIde {
environment("PKGS_TEST_DATA_OUTPUT_DIR", testDataDirectoryPath.get())
}

register<PublishPluginTask>("publishSnapshotPluginToTBE") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ sealed interface PackageSearchModule : IconProvider, PackageSearchModuleEditor {

interface WithVariants : PackageSearchModule {

@Serializable
data class Terminology(val singular: String, val plural: String) {
fun getForCardinality(count: Int) = if (count > 1) plural else singular

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ interface PackageSearchModuleVariant : PackageSearchDependencyManager {

val value: String

@JvmInline
@Serializable
value class StringAttribute(override val value: String) : Attribute
data class StringAttribute(override val value: String) : Attribute

@Serializable
data class NestedAttribute(override val value: String, val children: List<Attribute>) : Attribute
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.jetbrains.packagesearch.plugin.tests

import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.ui.playback.PlaybackContext
import com.intellij.openapi.ui.playback.commands.AbstractCommand
import kotlinx.coroutines.CoroutineScope
import org.jetbrains.concurrency.Promise

abstract class CoroutineAbstractCommand(text: String, line: Int) : AbstractCommand(text, line) {

@Service(Service.Level.PROJECT)
private class TestCoroutineScopeService(val coroutineScope: CoroutineScope)

final override fun _execute(context: PlaybackContext): Promise<Any> = context.project
.service<TestCoroutineScopeService>()
.coroutineScope
.promise { executeAsync(context) }

abstract suspend fun executeAsync(context: PlaybackContext)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.jetbrains.packagesearch.plugin.tests

import com.jetbrains.packagesearch.plugin.tests.dumps.DumpPackageSearchModules
import com.jetbrains.performancePlugin.CommandProvider

class PKGSCommandProvider : CommandProvider {

override fun getCommands() = mapOf(
DumpPackageSearchModules.COMMAND
)

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.jetbrains.packagesearch.plugin.tests

import com.jetbrains.packagesearch.plugin.core.data.PackageSearchModule
import kotlinx.serialization.Serializable

@Serializable
data class SerializableIdentity(
val group: String,
val path: String,
)


fun PackageSearchModule.Identity.toSerializable() = SerializableIdentity(group, path)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.jetbrains.packagesearch.plugin.tests

import com.jetbrains.packagesearch.plugin.core.extensions.DependencyDeclarationIndexes
import kotlinx.serialization.Serializable
import org.jetbrains.packagesearch.packageversionutils.normalization.NormalizedVersion

@Serializable
data class SerializablePackageSearchDeclaredPackage(
val id: String,
val displayName: String,
val coordinates: String,
val declaredVersion: NormalizedVersion?,
val declarationIndexes: DependencyDeclarationIndexes,
val declaredScope: String?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.jetbrains.packagesearch.plugin.tests

import com.jetbrains.packagesearch.plugin.core.data.PackageSearchModule
import kotlinx.serialization.Serializable
import org.jetbrains.packagesearch.api.v3.ApiRepository
import org.jetbrains.packagesearch.api.v3.search.PackagesType

@Serializable
sealed interface SerializablePackageSearchModule {

val name: String
val identity: SerializableIdentity
val buildFilePath: String?
val declaredKnownRepositories: Map<String, ApiRepository>

val compatiblePackageTypes: List<PackagesType>
val dependencyMustHaveAScope: Boolean

@Serializable
data class Base(
override val name: String,
override val identity: SerializableIdentity,
override val buildFilePath: String?,
override val declaredKnownRepositories: Map<String, ApiRepository>,
override val compatiblePackageTypes: List<PackagesType>,
override val dependencyMustHaveAScope: Boolean,
val declaredDependencies: List<SerializablePackageSearchDeclaredPackage>,
val availableScopes: List<String>,
val defaultScope: String?,
) : SerializablePackageSearchModule

@Serializable
data class WithVariants(
override val name: String,
override val identity: SerializableIdentity,
override val buildFilePath: String?,
override val declaredKnownRepositories: Map<String, ApiRepository>,
override val compatiblePackageTypes: List<PackagesType>,
override val dependencyMustHaveAScope: Boolean,
val variants: Map<String, SerializablePackageSearchModuleVariant>,
val variantTerminology: PackageSearchModule.WithVariants.Terminology,
val mainVariantName: String,
) : SerializablePackageSearchModule

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.jetbrains.packagesearch.plugin.tests

import com.jetbrains.packagesearch.plugin.core.data.PackageSearchModule
import com.jetbrains.packagesearch.plugin.core.data.PackageSearchModuleVariant
import kotlinx.serialization.Serializable
import org.jetbrains.packagesearch.api.v3.search.PackagesType

@Serializable
data class SerializablePackageSearchModuleVariant(
val name: String,
val variantTerminology: PackageSearchModule.WithVariants.Terminology?,
val declaredDependencies: List<SerializablePackageSearchDeclaredPackage>,
val attributes: List<PackageSearchModuleVariant.Attribute>,
val compatiblePackageTypes: List<PackagesType>,
val isPrimary: Boolean,
val dependencyMustHaveAScope: Boolean,
val availableScopes: List<String>,
val defaultScope: String?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.jetbrains.packagesearch.plugin.tests

import kotlinx.serialization.Serializable

@Serializable
data class TestResult<T>(
val value: T? = null,
val error: SerializableThrowable? = null,
)

@Serializable
data class SerializableThrowable(
val typeName: String? = null,
val message: String,
val stackTrace: List<String>,
val cause: SerializableThrowable? = null,
)
Loading

0 comments on commit a65037a

Please sign in to comment.