Skip to content

Commit

Permalink
chore: pull changes from plugin template (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
SirYwell committed Jul 9, 2023
1 parent 2f31062 commit a66bf59
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 80 deletions.
114 changes: 80 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@ 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)
push:
branches: [main]
branches: [ main ]
# Trigger the workflow on any pull request
pull_request:

jobs:

# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
# Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
# Build plugin and provide the artifact for the next workflow jobs
# Prepare environment and build the plugin
build:
name: Build
runs-on: ubuntu-latest
outputs:
version: ${{ steps.properties.outputs.version }}
changelog: ${{ steps.properties.outputs.changelog }}
pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }}
steps:

# Free GitHub Actions Environment Disk Space
Expand All @@ -48,12 +47,9 @@ jobs:
- name: Gradle Wrapper Validation
uses: gradle/[email protected]

# Setup Java 11 environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

# Set environment variables
- name: Export Properties
Expand All @@ -62,11 +58,9 @@ jobs:
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "name=$NAME" >> $GITHUB_OUTPUT
echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
echo "changelog<<EOF" >> $GITHUB_OUTPUT
Expand All @@ -75,6 +69,43 @@ jobs:
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
# Build plugin
- name: Build plugin
run: ./gradlew buildPlugin

# Prepare plugin archive content for creating artifact
- name: Prepare Plugin Artifact
id: artifact
shell: bash
run: |
cd ${{ github.workspace }}/build/distributions
FILENAME=`ls *.zip`
unzip "$FILENAME" -d content
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
# Store already-built plugin as an artifact for downloading
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifact.outputs.filename }}
path: ./build/distributions/content/*/*

# Run tests and upload a code coverage report
test:
name: Test
needs: build
runs-on: ubuntu-latest
steps:

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

# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

# Run tests
- name: Run Tests
run: ./gradlew check
Expand All @@ -93,16 +124,31 @@ jobs:
with:
files: ${{ github.workspace }}/build/reports/kover/xml/report.xml

# Run plugin structure verification along with IntelliJ Plugin Verifier
verify:
name: Verify plugin
needs: build
runs-on: ubuntu-latest
steps:

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

# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

# Cache Plugin Verifier IDEs
- name: Setup Plugin Verifier IDEs Cache
uses: actions/cache@v3
with:
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}

# Run Verify Plugin task and IntelliJ Plugin Verifier tool
- name: Run Plugin Verification tasks
run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}

# Collect Plugin Verifier Result
- name: Collect Plugin Verifier Result
Expand All @@ -112,34 +158,34 @@ jobs:
name: pluginVerifier-result
path: ${{ github.workspace }}/build/reports/pluginVerifier

# Run Qodana inspections
- name: Qodana - Code Inspection
uses: JetBrains/[email protected]

# Prepare plugin archive content for creating artifact
- name: Prepare Plugin Artifact
id: artifact
shell: bash
run: |
cd ${{ github.workspace }}/build/distributions
FILENAME=`ls *.zip`
unzip "$FILENAME" -d content
# Run Qodana inspections and provide report
inspectCode:
name: Inspect code
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
checks: write
pull-requests: write
steps:

echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3

# Store already-built plugin as an artifact for downloading
- name: Upload artifact
uses: actions/upload-artifact@v3
# Run Qodana inspections
- name: Qodana - Code Inspection
uses: JetBrains/[email protected]
with:
name: ${{ steps.artifact.outputs.filename }}
path: ./build/distributions/content/*/*
post-pr-comment: false
cache-default-branch-only: true

# Prepare a draft release for GitHub Releases page for the manual verification
# If accepted and published, release workflow would be triggered
releaseDraft:
name: Release Draft
name: Release draft
if: github.event_name != 'pull_request'
needs: build
needs: [ build, test, verify, inspectCode ]
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ jobs:
with:
ref: ${{ github.event.release.tag_name }}

# Setup Java 11 environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

# Set environment variables
- name: Export Properties
Expand Down Expand Up @@ -93,4 +90,4 @@ jobs:
--title "Changelog update - \`$VERSION\`" \
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
--label "$LABEL" \
--head $BRANCH
--head $BRANCH
7 changes: 4 additions & 3 deletions .github/workflows/run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ jobs:
- name: Fetch Sources
uses: actions/checkout@v3

# Setup Java 11 environment for the next steps
# Setup Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
java-version: 17
cache: gradle

# Run IDEA prepared for UI testing
- name: Run IDE
Expand All @@ -56,4 +57,4 @@ jobs:

# Run tests
- name: Tests
run: ./gradlew test
run: ./gradlew test
59 changes: 28 additions & 31 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,11 @@ fun properties(key: String) = project.findProperty(key).toString()
plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.8.10"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.13.3"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "2.0.0"
// Gradle Qodana Plugin
id("org.jetbrains.qodana") version "0.1.13"
// Gradle Kover Plugin
id("org.jetbrains.kotlinx.kover") version "0.6.1"
alias(libs.plugins.kotlin) // Kotlin support
alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
alias(libs.plugins.kover) // Gradle Kover Plugin
}

group = properties("pluginGroup")
Expand All @@ -31,38 +26,40 @@ repositories {

// Set the JVM language level used to compile sources and generate files - Java 11 is required since 2020.3
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
jvmToolchain(17)
}

// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
pluginName = properties("pluginName")
version = properties("platformVersion")
type = properties("platformType")

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
plugins = properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)
}

// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.empty()
repositoryUrl.set(properties("pluginRepositoryUrl"))
repositoryUrl = properties("pluginRepositoryUrl")
}

// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
qodana {
cachePath.set(projectDir.resolve(".qodana").canonicalPath)
reportPath.set(projectDir.resolve("build/reports/inspections").canonicalPath)
saveReport.set(true)
showReport.set(System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false)
cachePath = projectDir.resolve(".qodana").canonicalPath
reportPath = projectDir.resolve("build/reports/inspections").canonicalPath
saveReport = true
showReport = System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false
}

// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
kover.xmlReport {
onCheck.set(true)
koverReport {
defaults {
xml {
onCheck = true
}
}
}

tasks {
Expand Down Expand Up @@ -90,7 +87,7 @@ tasks {

val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes.set(properties("pluginVersion").also { pluginVersion ->
changeNotes = properties("pluginVersion").also { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
Expand All @@ -99,7 +96,7 @@ tasks {
Changelog.OutputType.HTML,
)
}
})
}
}

// Configure UI tests plugin
Expand All @@ -112,18 +109,18 @@ tasks {
}

signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
certificateChain = System.getenv("CERTIFICATE_CHAIN")
privateKey = System.getenv("PRIVATE_KEY")
password = System.getenv("PRIVATE_KEY_PASSWORD")
}

publishPlugin {
dependsOn("patchChangelog")
token.set(System.getenv("PUBLISH_TOKEN"))
token = System.getenv("PUBLISH_TOKEN")
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()))
channels = listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first())
}

test {
Expand Down
16 changes: 13 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,34 @@

pluginGroup = de.sirywell.methodhandleplugin
pluginName = HandleHints
pluginRepositoryUrl = https://github.com/SirYwell/HandleHints
# SemVer format -> https://semver.org
pluginVersion = 0.0.1

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 222
pluginUntilBuild = 231.*
pluginUntilBuild = 232.*

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

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = com.intellij.java

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.1.1
gradleVersion = 8.2

# Opt-out flag for bundling Kotlin standard library -> https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library
# suppress inspection "UnusedProperty"
kotlin.stdlib.default.dependency = false

# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
# TODO figure out configuration caching with test sdk download
org.gradle.configuration-cache = false
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
org.gradle.caching = true

# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
systemProp.org.gradle.unsafe.kotlin.assignment = true
Loading

0 comments on commit a66bf59

Please sign in to comment.