Skip to content

Commit

Permalink
Merge pull request #156 from yusufugurozbek/next
Browse files Browse the repository at this point in the history
v1.1.2
  • Loading branch information
yusufugurozbek committed Aug 18, 2023
2 parents 5b32cd2 + 1978b7c commit 883dd6f
Show file tree
Hide file tree
Showing 21 changed files with 954 additions and 50 deletions.
61 changes: 37 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps:
# - validate Gradle Wrapper,
# - run 'test' and 'verifyPlugin' tasks,
# - run Qodana inspections,
# - run 'buildPlugin' task and prepare artifact for the further tests,
# - run 'runPluginVerifier' task,
# - create a draft release.
# - Validate Gradle Wrapper.
# - Run 'test' and 'verifyPlugin' tasks.
# - Run Qodana inspections.
# - Run the 'buildPlugin' task and prepare artifact for further tests.
# - Run the 'runPluginVerifier' task.
# - Create a draft release.
#
# Workflow is triggered on push and pull_request events.
# The workflow is triggered on push and pull_request events.
#
# GitHub Actions reference: https://help.github.com/en/actions
#
## JBIJPPTPL

name: Build
on:
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests)
push:
branches: [ main ]
# Trigger the workflow on any pull request
Expand All @@ -32,13 +32,6 @@ jobs:
pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }}
steps:

# Free GitHub Actions Environment Disk Space
- name: Maximize Build Space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3
Expand All @@ -47,7 +40,7 @@ jobs:
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1.1.0

# Setup Java environment for the next steps
# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -57,6 +50,8 @@ jobs:
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

# Set environment variables
- name: Export Properties
Expand Down Expand Up @@ -109,7 +104,7 @@ jobs:
- name: Fetch Sources
uses: actions/checkout@v3

# Setup Java environment for the next steps
# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -119,6 +114,8 @@ jobs:
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

# Run tests
- name: Run Tests
Expand All @@ -132,11 +129,11 @@ jobs:
name: tests-result
path: ${{ github.workspace }}/build/reports/tests

# Upload Kover report to CodeCov
# Upload the Kover report to CodeCov
- name: Upload Code Coverage Report
uses: codecov/codecov-action@v3
with:
files: ${{ github.workspace }}/build/reports/kover/xml/report.xml
files: ${{ github.workspace }}/build/reports/kover/report.xml

# Run Qodana inspections and provide report
inspectCode:
Expand All @@ -149,11 +146,18 @@ jobs:
pull-requests: write
steps:

# Free GitHub Actions Environment Disk Space
- name: Maximize Build Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
large-packages: false

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3

# Setup Java environment for the next steps
# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -169,15 +173,22 @@ jobs:
# Run plugin structure verification along with IntelliJ Plugin Verifier
verify:
name: Verify plugin
needs: [ build, test, inspectCode ]
needs: [ build ]
runs-on: ubuntu-latest
steps:

# Free GitHub Actions Environment Disk Space
- name: Maximize Build Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
large-packages: false

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3

# Setup Java environment for the next steps
# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -187,6 +198,8 @@ jobs:
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

# Cache Plugin Verifier IDEs
- name: Setup Plugin Verifier IDEs Cache
Expand All @@ -212,7 +225,7 @@ jobs:
releaseDraft:
name: Release draft
if: github.event_name != 'pull_request'
needs: [ build, verify ]
needs: [ build, test, inspectCode, verify ]
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -222,7 +235,7 @@ jobs:
- name: Fetch Sources
uses: actions/checkout@v3

# Setup Java environment for the next steps
# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:

# Prepare and publish the plugin to the Marketplace repository
# Prepare and publish the plugin to JetBrains Marketplace repository
release:
name: Publish Plugin
runs-on: ubuntu-latest
Expand All @@ -24,7 +24,7 @@ jobs:
with:
ref: ${{ github.event.release.tag_name }}

# Setup Java environment for the next steps
# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -34,6 +34,8 @@ jobs:
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

# Set environment variables
- name: Export Properties
Expand All @@ -57,7 +59,7 @@ jobs:
run: |
./gradlew patchChangelog --release-note="$CHANGELOG"
# Publish the plugin to the Marketplace
# Publish the plugin to JetBrains Marketplace
- name: Publish Plugin
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
Expand All @@ -72,7 +74,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*

# Create pull request
# Create a pull request
- name: Create Pull Request
if: ${{ steps.properties.outputs.changelog != '' }}
env:
Expand All @@ -91,6 +93,7 @@ jobs:
gh label create "$LABEL" \
--description "Pull requests with release changelog update" \
--force \
|| true
gh pr create \
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/run-ui-tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# GitHub Actions Workflow for launching UI tests on Linux, Windows, and Mac in the following steps:
# - prepare and launch IDE with your plugin and robot-server plugin, which is needed to interact with UI
# - wait for IDE to start
# - run UI tests with separate Gradle task
# - Prepare and launch IDE with your plugin and robot-server plugin, which is needed to interact with the UI.
# - Wait for IDE to start.
# - Run UI tests with a separate Gradle task.
#
# Please check https://github.com/JetBrains/intellij-ui-test-robot for information about UI tests with IntelliJ Platform
# Please check https://github.com/JetBrains/intellij-ui-test-robot for information about UI tests with IntelliJ Platform.
#
# Workflow is triggered manually.

Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Fetch Sources
uses: actions/checkout@v3

# Setup Java environment for the next steps
# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand All @@ -45,6 +45,8 @@ jobs:
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

# Run IDEA prepared for UI testing
- name: Run IDE
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Testcontainers Port Updater Changelog

## [Unreleased]
- Introduce JSON logging format / Now you can change the logging format via settings
- Support latest IntelliJ 2023.2
- Bump dependencies to their latest versions
- Bump Gradle version to 8.2.1
- Migrate latest changes of intellij-platform-plugin-template v1.9.0
- Bump Gradle version to 8.3
- Migrate latest changes of intellij-platform-plugin-template v1.11.1

## [1.1.1] - 2023-04-06
- Bump dependencies to their latest versions
Expand Down
8 changes: 0 additions & 8 deletions detekt-config.yml

This file was deleted.

4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ pluginUntilBuild = 232.*

# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = IU
platformVersion = 2022.2
platformVersion = 2022.3.3

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
platformPlugins = com.intellij.database

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.2.1
gradleVersion = 8.3
org.gradle.jvmargs=-Xmx1g

# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
3 changes: 2 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,26 @@ import com.github.yusufugurozbek.testcontainers.port.updater.DataSourceUrlExtrac
import com.github.yusufugurozbek.testcontainers.port.updater.api.DataSourceUpdater
import com.github.yusufugurozbek.testcontainers.port.updater.common.TpuNotifier
import com.github.yusufugurozbek.testcontainers.port.updater.equalsIgnoringPort
import com.github.yusufugurozbek.testcontainers.port.updater.settings.LoggingFormat
import com.github.yusufugurozbek.testcontainers.port.updater.settings.MatchMode
import com.github.yusufugurozbek.testcontainers.port.updater.settings.TpuSettingsState
import com.intellij.database.dataSource.LocalDataSource
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.thisLogger
import com.intellij.openapi.project.Project
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive

class DataSourceUpdaterImpl(private var project: Project) : DataSourceUpdater {

private var urlExtractor: DataSourceUrlExtractor = DataSourceUrlExtractor()
private var settingsState: TpuSettingsState = project.service()

override fun update(localDataSources: List<LocalDataSource>, logEntryText: String) {
val splitLogEntry = logEntryText.split(settingsState.logEntryPrefix)
val logEntry = getLogMessage(logEntryText)

val splitLogEntry = logEntry.split(settingsState.logEntryPrefix)
if (splitLogEntry.size == 2) {
urlExtractor.extract(splitLogEntry[1])?.let { logEntryDataSourceUrl ->
localDataSources
Expand All @@ -27,6 +34,17 @@ class DataSourceUpdaterImpl(private var project: Project) : DataSourceUpdater {
}
}

private fun getLogMessage(logEntryText: String): String {
if (settingsState.loggingFormat == LoggingFormat.JSON && logEntryText.contains(settingsState.logEntryPrefix)) {
try {
return Json.parseToJsonElement(logEntryText).jsonObject["message"]!!.jsonPrimitive.content
} catch (e: Exception) {
thisLogger().warn("JSON log message cannot be extracted", e)
}
}
return logEntryText
}

private fun update(localDataSource: LocalDataSource, logEntryDataSourceUrl: DataSourceUrl) {
val localDataSourceUrl = urlExtractor.toDataSourceUrl(localDataSource) ?: return

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.github.yusufugurozbek.testcontainers.port.updater.settings

enum class LoggingFormat {
JSON,
SIMPLE_TEXT
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ class TpuSettingsComponent(private val tpuSettingsState: TpuSettingsState) {
}
}.bind(tpuSettingsState::matchMode)

buttonsGroup(TpuBundle.message("settings.loggingFormat")) {

Check warning on line 44 in src/main/kotlin/com/github/yusufugurozbek/testcontainers/port/updater/settings/TpuSettingsComponent.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Incorrect string capitalization

String 'Select logging format:' is not properly capitalized. It should have title capitalization
row {
radioButton(TpuBundle.message("settings.loggingFormatSimpleText"), LoggingFormat.SIMPLE_TEXT)

Check warning on line 46 in src/main/kotlin/com/github/yusufugurozbek/testcontainers/port/updater/settings/TpuSettingsComponent.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Incorrect string capitalization

String 'Simple Text' is not properly capitalized. It should have sentence capitalization
}
row {
radioButton(TpuBundle.message("settings.loggingFormatJson"), LoggingFormat.JSON)
}
}.bind(tpuSettingsState::loggingFormat)

group {
row {
text(TpuBundle.message("settings.giveAStar"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.yusufugurozbek.testcontainers.port.updater.settings

import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil
Expand All @@ -9,6 +10,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil
name = "com.github.yusufugurozbek.testcontainers.port.updater.settings.TpuSettingsState",
storages = [Storage("TestcontainersPortUpdaterPlugin.xml")]
)
@Service(Service.Level.PROJECT)
class TpuSettingsState : PersistentStateComponent<TpuSettingsState?> {
var isNotificationsEnabled: Boolean = true
var logEntryPrefix: String = "Database:"
Expand All @@ -18,6 +20,7 @@ class TpuSettingsState : PersistentStateComponent<TpuSettingsState?> {
}
}
var matchMode: MatchMode = MatchMode.EXACT
var loggingFormat: LoggingFormat = LoggingFormat.SIMPLE_TEXT

override fun getState(): TpuSettingsState {
return this
Expand Down
Loading

0 comments on commit 883dd6f

Please sign in to comment.