diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a96ab6d..a2b3bc7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,15 +1,13 @@ # GitHub Actions Workflow created for testing and preparing the plugin release in following steps: # - validate Gradle Wrapper, -# - run test and verifyPlugin tasks, -# - run buildPlugin task and prepare artifact for the further tests, -# - run IntelliJ Plugin Verifier, +# - run 'test' and 'verifyPlugin' tasks, +# - run 'buildPlugin' task and prepare artifact for the further tests, +# - run 'runPluginVerifier' task, # - create a draft release. # # Workflow is triggered on push and pull_request events. # -# Docs: -# - GitHub Actions: https://help.github.com/en/actions -# - IntelliJ Plugin Verifier GitHub Action: https://github.com/ChrisCarini/intellij-platform-plugin-verifier-action +# GitHub Actions reference: https://help.github.com/en/actions # ## JBIJPPTPL @@ -24,30 +22,24 @@ on: jobs: # Run Gradle Wrapper Validation Action to verify the wrapper's checksum - gradleValidation: - name: Gradle Wrapper + # Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks + # Build plugin and provide the artifact for the next workflow jobs + build: + name: Build runs-on: ubuntu-latest + outputs: + version: ${{ steps.properties.outputs.version }} + changelog: ${{ steps.properties.outputs.changelog }} steps: # Check out current repository - name: Fetch Sources - uses: actions/checkout@v3.0.1 + uses: actions/checkout@v3 # Validate wrapper - name: Gradle Wrapper Validation uses: gradle/wrapper-validation-action@v1.0.4 - # Run verifyPlugin and test Gradle tasks - test: - name: Test - needs: gradleValidation - runs-on: ubuntu-latest - steps: - - # Check out current repository - - name: Fetch Sources - uses: actions/checkout@v3.0.1 - # Setup Java 11 environment for the next steps - name: Setup Java uses: actions/setup-java@v3 @@ -62,80 +54,68 @@ jobs: shell: bash run: | PROPERTIES="$(./gradlew properties --console=plain -q)" - IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)" + 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)" + CHANGELOG="${CHANGELOG//'%'/'%25'}" + CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" + CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" - echo "::set-output name=ideVersions::$IDE_VERSIONS" + echo "::set-output name=version::$VERSION" + echo "::set-output name=name::$NAME" + echo "::set-output name=changelog::$CHANGELOG" echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier" - # Cache Plugin Verifier IDEs - - name: Setup Plugin Verifier IDEs Cache - uses: actions/cache@v3.0.2 - with: - path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides - key: ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }} + ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier # Run tests - name: Run Tests run: ./gradlew test - # Run verifyPlugin Gradle task - - name: Verify Plugin - run: ./gradlew verifyPlugin - - # Run IntelliJ Plugin Verifier action using GitHub Action - - name: Run Plugin Verifier - run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }} + # Collect Tests Result of failed tests + - name: Collect Tests Result + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: tests-result + path: ${{ github.workspace }}/build/reports/tests - # Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs - # Requires test job to be passed - build: - name: Build - needs: test - runs-on: ubuntu-latest - outputs: - version: ${{ steps.properties.outputs.version }} - changelog: ${{ steps.properties.outputs.changelog }} - steps: + # Cache Plugin Verifier IDEs + - name: Setup Plugin Verifier IDEs Cache + uses: actions/cache@v3 + with: + path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides + key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} - # Check out current repository - - name: Fetch Sources - uses: actions/checkout@v3.0.1 + # Run Verify Plugin task and IntelliJ Plugin Verifier tool + - name: Run Plugin Verification tasks + run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }} - # Setup Java 11 environment for the next steps - - name: Setup Java - uses: actions/setup-java@v3 + # Collect Plugin Verifier Result + - name: Collect Plugin Verifier Result + if: ${{ always() }} + uses: actions/upload-artifact@v3 with: - distribution: zulu - java-version: 11 - cache: gradle + name: pluginVerifier-result + path: ${{ github.workspace }}/build/reports/pluginVerifier - # Set environment variables - - name: Export Properties - id: properties + # Prepare plugin archive content for creating artifact + - name: Prepare Plugin Artifact + id: artifact shell: bash 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)" - CHANGELOG="${CHANGELOG//'%'/'%25'}" - CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" - CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" - - echo "::set-output name=version::$VERSION" - echo "::set-output name=name::$NAME" - echo "::set-output name=changelog::$CHANGELOG" + cd ${{ github.workspace }}/build/distributions + FILENAME=`ls *.zip` + unzip "$FILENAME" -d content - # Build artifact using buildPlugin Gradle task - - name: Build Plugin - run: ./gradlew buildPlugin + echo "::set-output name=filename::${FILENAME:0:-4}" - # Store built plugin as an artifact for downloading - - name: Upload artifacts - uses: actions/upload-artifact@v3.0.0 + # Store already-built plugin as an artifact for downloading + - name: Upload artifact + uses: actions/upload-artifact@v3 with: - name: "${{ steps.properties.outputs.name }} - ${{ steps.properties.outputs.version }}" - path: ./build/distributions/* + name: ${{ steps.artifact.outputs.filename }} + path: ./build/distributions/content/*/* # Prepare a draft release for GitHub Releases page for the manual verification # If accepted and published, release workflow would be triggered @@ -144,11 +124,13 @@ jobs: if: github.event_name != 'pull_request' needs: build runs-on: ubuntu-latest + permissions: + contents: write steps: # Check out current repository - name: Fetch Sources - uses: actions/checkout@v3.0.1 + uses: actions/checkout@v3 # Remove old release drafts by using the curl request for the available releases with draft flag - name: Remove Old Release Drafts @@ -167,4 +149,7 @@ jobs: gh release create v${{ needs.build.outputs.version }} \ --draft \ --title "v${{ needs.build.outputs.version }}" \ - --notes "${{ needs.build.outputs.changelog }}" + --notes "$(cat << 'EOM' + ${{ needs.build.outputs.changelog }} + EOM + )" \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dbabe27..048908c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,11 +12,14 @@ jobs: release: name: Publish Plugin runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write steps: # Check out current repository - name: Fetch Sources - uses: actions/checkout@v3.0.1 + uses: actions/checkout@v3 with: ref: ${{ github.event.release.tag_name }} @@ -28,12 +31,29 @@ jobs: java-version: 11 cache: gradle + # Set environment variables + - name: Export Properties + id: properties + shell: bash + run: | + CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d' + ${{ github.event.release.body }} + EOM + )" + + CHANGELOG="${CHANGELOG//'%'/'%25'}" + CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" + CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" + + echo "::set-output name=changelog::$CHANGELOG" + # Update Unreleased section with the current release note - name: Patch Changelog + if: ${{ steps.properties.outputs.changelog != '' }} + env: + CHANGELOG: ${{ steps.properties.outputs.changelog }} run: | - ./gradlew patchChangelog --release-note="`cat << EOM - ${{ github.event.release.body }} - EOM`" + ./gradlew patchChangelog --release-note="$CHANGELOG" # Publish the plugin to the Marketplace - name: Publish Plugin @@ -49,6 +69,7 @@ jobs: # Create pull request - name: Create Pull Request + if: ${{ steps.properties.outputs.changelog != '' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | diff --git a/.github/workflows/run-ui-tests.yml b/.github/workflows/run-ui-tests.yml index 62a9bb0..add3f2a 100644 --- a/.github/workflows/run-ui-tests.yml +++ b/.github/workflows/run-ui-tests.yml @@ -1,9 +1,9 @@ -# GitHub Actions Workflow created for launching UI tests on Linux, Windows, and Mac in the following steps: -# - prepare and launch Idea with your plugin and robot-server plugin, which is need to interact with UI -# - wait for the Idea started +# 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 # -# Please check https://github.com/JetBrains/intellij-ui-test-robot for information about UI tests with IntelliJ IDEA. +# Please check https://github.com/JetBrains/intellij-ui-test-robot for information about UI tests with IntelliJ Platform # # Workflow is triggered manually. @@ -33,7 +33,7 @@ jobs: # Check out current repository - name: Fetch Sources - uses: actions/checkout@v3.0.1 + uses: actions/checkout@v3 # Setup Java 11 environment for the next steps - name: Setup Java diff --git a/CHANGELOG.md b/CHANGELOG.md index a7ee830..4aef0a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,11 @@ # collections-intellij Changelog ## [Unreleased] +### Removed +- Removed type provider for higher order collections as it seemed unstable ## [0.3.5] -### Fixed +### Fixed - Fixed immutable php type issues ## [0.3.4] diff --git a/build.gradle.kts b/build.gradle.kts index 2fec918..89218d1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,4 @@ import org.jetbrains.changelog.markdownToHTML -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile fun properties(key: String) = project.findProperty(key).toString() @@ -12,8 +11,6 @@ plugins { id("org.jetbrains.intellij") version "1.5.3" // Gradle Changelog Plugin id("org.jetbrains.changelog") version "1.3.1" - // Gradle Qodana Plugin - id("org.jetbrains.qodana") version "0.1.13" } group = properties("pluginGroup") @@ -29,8 +26,6 @@ intellij { pluginName.set(properties("pluginName")) version.set(properties("platformVersion")) type.set(properties("platformType")) - downloadSources.set(properties("platformDownloadSources").toBoolean()) - updateSinceUntilBuild.set(true) // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) @@ -42,26 +37,8 @@ changelog { groups.set(emptyList()) } -// 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) -} tasks { - // Set the JVM compatibility versions - properties("javaVersion").let { - withType { - sourceCompatibility = it - targetCompatibility = it - } - withType { - kotlinOptions.jvmTarget = it - } - } - wrapper { gradleVersion = properties("gradleVersion") } @@ -92,19 +69,6 @@ tasks { }) } - runPluginVerifier { - ideVersions.set(properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty)) - } - - // Configure UI tests plugin - // Read more: https://github.com/JetBrains/intellij-ui-test-robot - runIdeForUiTests { - systemProperty("robot-server.port", "8082") - systemProperty("ide.mac.message.dialogs.as.sheets", "false") - systemProperty("jb.privacy.policy.text", "") - systemProperty("jb.consents.confirmation.enabled", "false") - } - signPlugin { certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) privateKey.set(System.getenv("PRIVATE_KEY")) diff --git a/detekt-config.yml b/detekt-config.yml deleted file mode 100644 index 6c4f830..0000000 --- a/detekt-config.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Default detekt configuration: -# https://github.com/detekt/detekt/blob/master/detekt-cli/src/main/resources/default-detekt-config.yml - -formatting: - Indentation: - active: true -style: - ReturnCount: - max: 10 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 05dbc5c..28564bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,28 +3,20 @@ pluginGroup = dev.nybroe.collector pluginName = Collector -pluginVersion = 0.3.5 +pluginVersion = 0.4.0 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. pluginSinceBuild = 212 pluginUntilBuild = -# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl -# See https://jb.gg/intellij-platform-builds-list for available build versions -pluginVerifierIdeVersions = PS-2021.2.2 - platformType = IU platformVersion = 2021.2.2 -platformDownloadSources = true # Get latest version from https://plugins.jetbrains.com/plugin/6610-php/versions # Get latest version from https://plugins.jetbrains.com/plugin/7569-blade/versions platformPlugins = com.jetbrains.php:212.5284.49, com.jetbrains.php.blade:212.5080.8 -# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3 -javaVersion = 11 - -gradleVersion = 7.2 +gradleVersion = 7.4 # Opt-out flag for bundling Kotlin standard library. # See https://kotlinlang.org/docs/reference/using-gradle.html#dependency-on-the-standard-library for details. diff --git a/qodana.yml b/qodana.yml deleted file mode 100644 index 8b73731..0000000 --- a/qodana.yml +++ /dev/null @@ -1,6 +0,0 @@ -# Qodana configuration: -# https://www.jetbrains.com/help/qodana/qodana-yaml.html - -version: 1.0 -profile: - name: qodana.recommended \ No newline at end of file diff --git a/src/main/kotlin/dev/nybroe/collector/types/HigherOrderTypeProvider.kt b/src/main/kotlin/dev/nybroe/collector/types/HigherOrderTypeProvider.kt deleted file mode 100644 index 196762c..0000000 --- a/src/main/kotlin/dev/nybroe/collector/types/HigherOrderTypeProvider.kt +++ /dev/null @@ -1,74 +0,0 @@ -package dev.nybroe.collector.types - -import com.intellij.openapi.project.DumbService -import com.intellij.openapi.project.Project -import com.intellij.psi.PsiElement -import com.jetbrains.php.PhpIndex -import com.jetbrains.php.lang.psi.elements.FieldReference -import com.jetbrains.php.lang.psi.elements.MethodReference -import com.jetbrains.php.lang.psi.elements.PhpNamedElement -import com.jetbrains.php.lang.psi.resolve.types.PhpType -import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider4 -import dev.nybroe.collector.collectionType -import dev.nybroe.collector.isHigherOrderCollection -import gnu.trove.THashSet - -class HigherOrderTypeProvider : PhpTypeProvider4 { - override fun getKey(): Char { - return '\u0171' - } - - override fun getType(psiElement: PsiElement): PhpType? { - if (DumbService.isDumb(psiElement.project)) return null - - // Check that our current element is a field or method reference - // $collection->map->data, $collection->map->data() - val fieldOrMethodReference = psiElement as? FieldReference - ?: psiElement as? MethodReference - ?: return null - - // Check that parent is a field reference. - // $collection->map - val parentField = fieldOrMethodReference.classReference as? FieldReference ?: return null - - return PhpType().add("#${this.key}${parentField.type}") - } - - override fun complete(s: String, project: Project): PhpType? { - return null - } - - /** - * Here you can extend the signature lookups - * @param expression Signature expression to decode. use PhpIndex.getBySignature() to look up expression internals. - * @param visited Recursion guard: Pass this on into any phpIndex calls having same parameter - * @param depth Recursion guard: Pass this on into any phpIndex calls having same parameter - * @param project well so you can reach the PhpIndex - * @return null if no match - */ - override fun getBySignature( - expression: String, - visited: MutableSet, - depth: Int, - project: Project - ): MutableCollection? { - // Remove key from signature - val signature = expression.removePrefix("#${key}") - - // Resolve type of the signature. - val type = PhpIndex.getInstance(project) - .getBySignature(signature.split('|')[0]) - .map { PhpType.builder().add(it.type) } - .reduceOrNull { acc, phpType -> acc.merge(phpType) } - ?.build() - ?.global(project) - - if (type === null) return null - - if (!type.isHigherOrderCollection(project)) return null - - return collectionType.types - .flatMap { PhpIndex.getInstance(project).getClassesByFQN(it.toString()) } - .toCollection(THashSet()) - } -} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 98e8c3a..56ab6a1 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -92,7 +92,7 @@ - + diff --git a/src/test/kotlin/dev/nybroe/collector/types/HigherOrderTypeProviderTest.kt b/src/test/kotlin/dev/nybroe/collector/types/HigherOrderTypeTest.kt similarity index 83% rename from src/test/kotlin/dev/nybroe/collector/types/HigherOrderTypeProviderTest.kt rename to src/test/kotlin/dev/nybroe/collector/types/HigherOrderTypeTest.kt index 6f3d3b3..51c08a2 100644 --- a/src/test/kotlin/dev/nybroe/collector/types/HigherOrderTypeProviderTest.kt +++ b/src/test/kotlin/dev/nybroe/collector/types/HigherOrderTypeTest.kt @@ -1,8 +1,10 @@ package dev.nybroe.collector.types import dev.nybroe.collector.BaseCollectTestCase +import org.junit.Ignore -internal class HigherOrderTypeProviderTest : BaseCollectTestCase() { +@Ignore(value = "Ignored until solution found for type provider") +internal class HigherOrderTypeTest : BaseCollectTestCase() { fun testHigherOrderPropertyReturnsCollection() { myFixture.configureByFile( "types/HigherOrderMethodsTypeProvider/higherOrderProperty.php"