From abfc897aafb8904d4c0a717169eaef80ac606a92 Mon Sep 17 00:00:00 2001 From: phY <17324780+pwnyprod@users.noreply.github.com> Date: Fri, 8 Jul 2022 19:43:00 +0200 Subject: [PATCH] #1 adding build action (#14) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * #1 adding build action Co-authored-by: Patrick Schönfeld --- .github/workflows/main.yml | 98 +++++++++++++ .gitignore | 1 + build.gradle.kts | 20 ++- build_twig_cache.sh | 3 + gradle.properties | 2 +- src/main/resources/template-map-v2.json | 179 ------------------------ src/main/resources/template-map.json | 140 ------------------ src/test/java/mock/ProjectMock.java | 50 ++++++- 8 files changed, 166 insertions(+), 327 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100755 build_twig_cache.sh delete mode 100644 src/main/resources/template-map-v2.json delete mode 100644 src/main/resources/template-map.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..045f564 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,98 @@ +name: 'Main' + +# **What it does**: Renders the content of every page and check all internal links. +# **Why we have it**: To make sure all links connect correctly. +# **Who does it impact**: Docs content. + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + # Needed for the 'trilom/file-changes-action' action + pull-requests: read + +# This allows a subsequently queued workflow run to interrupt previous runs +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: set gradle opts + uses: allenevans/set-env@v2.0.0 + with: + GRADLE_OPTS: '-Dorg.gradle.daemon=false' + - name: set gradle user home + run: export GRADLE_USER_HOME=`pwd`/.gradle + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + - name: create chain credentials + uses: finnp/create-file-action@1.0.0 + env: + FILE_NAME: ".ssl-keys/chain.crt" + FILE_DATA: $CHAIN_CERT + - name: create chain credentials + uses: finnp/create-file-action@1.0.0 + env: + FILE_NAME: ".ssl-keys/private.pem" + FILE_DATA: $PRIVATE_PEM + - name: create chain credentials + uses: finnp/create-file-action@1.0.0 + env: + FILE_NAME: ".ssl-keys/password.txt" + FILE_DATA: $PASSWORD_TXT + - name: Build with Gradle + run: ./gradlew --build-cache clean buildPlugin + - name: upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: build + path: build/distributions + tests: + runs-on: ubuntu-latest + needs: + - build + steps: + - name: install tree + run: sudo apt update && sudo apt install tree -y + - name: set gradle opts + uses: allenevans/set-env@v2.0.0 + with: + GRADLE_OPTS: '-Dorg.gradle.daemon=false' + - name: set gradle user home + run: export GRADLE_USER_HOME=`pwd`/.gradle + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + - name: create chain credentials + uses: finnp/create-file-action@1.0.0 + env: + FILE_NAME: ".ssl-keys/chain.crt" + FILE_DATA: $CHAIN_CERT + - name: create chain credentials + uses: finnp/create-file-action@1.0.0 + env: + FILE_NAME: ".ssl-keys/private.pem" + FILE_DATA: $PRIVATE_PEM + - name: create chain credentials + uses: finnp/create-file-action@1.0.0 + env: + FILE_NAME: ".ssl-keys/password.txt" + FILE_DATA: $PASSWORD_TXT + - name: build twig cache + run: ./build_twig_cache.sh + - name: Run tests + run: ./gradlew test \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9532aed..7774184 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build .ssl-keys/chain.crt .ssl-keys/password.txt .ssl-keys/private.pem +src/main/resources/template-map.json \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 0d0a6f0..eb13a58 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { // Kotlin support id("org.jetbrains.kotlin.jvm") version "1.6.10" // Gradle IntelliJ Plugin - id("org.jetbrains.intellij") version "1.5.3" + id("org.jetbrains.intellij") version "1.7.0" // Gradle Changelog Plugin id("org.jetbrains.changelog") version "1.3.1" // Gradle Qodana Plugin @@ -17,7 +17,7 @@ plugins { // detekt linter - read more: https://detekt.github.io/detekt/gradle.html id("io.gitlab.arturbosch.detekt") version "1.14.2" // ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle - id("org.jlleitschuh.gradle.ktlint") version "9.4.1" + //id("org.jlleitschuh.gradle.ktlint") version "10.3.0" // id("com.x5dev.chunk.templates") version "3.5.0" } @@ -50,7 +50,7 @@ intellij { version.set(properties("platformVersion")) type.set(properties("platformType")) - //localPath.set("/home/patrickjaja/.local/share/JetBrains/Toolbox/apps/PhpStorm/ch-0/213.6777.58") + // localPath.set("/home/patrickjaja/.local/share/JetBrains/Toolbox/apps/PhpStorm/ch-0/213.6777.58") // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) } @@ -113,8 +113,7 @@ tasks { runIde { jvmArgs("-Xmx2024m", "-Xms512m", "-XX:MaxPermSize=500m", "-ea") - ideDir.set(file(properties("platformIdeDir"))) - + //ideDir.set(file(properties("platformIdeDir"))) } // Configure UI tests plugin @@ -141,4 +140,13 @@ tasks { // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first())) } -} + + buildPlugin { + doFirst { + exec { + workingDir(".") + executable("./build_twig_cache.sh") + } + } + } +} \ No newline at end of file diff --git a/build_twig_cache.sh b/build_twig_cache.sh new file mode 100755 index 0000000..017923e --- /dev/null +++ b/build_twig_cache.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cd ./src/main/resources +tree -J templates/ > template-map.json \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index c7d2d83..be16509 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ pluginGroup = com.github.patrickjaja.intellijsprykerplugin pluginName = intellij_spryker_plugin -pluginVersion = 1.0.5 +pluginVersion = 1.0.6 pluginSinceBuild = 213 pluginUntilBuild = 222.* # pluginUntilBuild = 221.* diff --git a/src/main/resources/template-map-v2.json b/src/main/resources/template-map-v2.json deleted file mode 100644 index 1f27372..0000000 --- a/src/main/resources/template-map-v2.json +++ /dev/null @@ -1,179 +0,0 @@ -{ - "map" : { - "Client" : { - "ClientInterface.php.twig" : {}, - "ClientDependencyProvider.php.twig" : {}, - "ClientConfig.php.twig" : {}, - "ClientFactory.php.twig" : {}, - "Client.php.twig" : {} - }, - "CONTRIBUTING.md.twig" : {}, - "travis.yml.twig" : {}, - "Common" : { - "InterfaceMethod.php.twig" : {}, - "Method.php.twig" : {} - }, - "tooling.yml.twig" : {}, - "Service" : { - "ServiceInterface.php.twig" : {}, - "Service.php.twig" : {}, - "ServiceDependencyProvider.php.twig" : {}, - "ServiceFactory.php.twig" : {} - }, - "Yves" : { - "YvesDependencyProvider.php.twig" : {}, - "Dependency" : { - "YvesDependencyBridgeMethod.php.twig" : {}, - "Client" : { - "YvesDependencyClientFactoryMethod.php.twig" : {}, - "YvesDependencyClientInterface.php.twig" : {}, - "YvesDependencyClientBridge.php.twig" : {}, - "YvesDependencyClientDependencyProviderMethod.php.twig" : {} - }, - "Service" : { - "YvesDependencyServiceFactoryMethod.php.twig" : {}, - "YvesDependencyServiceDependencyProviderMethod.php.twig" : {}, - "YvesDependencyServiceInterface.php.twig" : {}, - "YvesDependencyServiceBridge.php.twig" : {} - }, - "YvesDependencyBridgeInterfaceMethod.php.twig" : {} - }, - "YvesFactory.php.twig" : {}, - "YvesConfig.php.twig" : {} - }, - "LICENSE.twig" : {}, - "Glue" : { - "Plugin" : { - "GlueApplication" : { - "FormatRequestPlugin.php.twig" : {}, - "ValidateHttpRequestPlugin.php.twig" : {}, - "ControllerAfterActionPlugin.php.twig" : {}, - "FormatResponseHeadersPlugin.php.twig" : {}, - "RestRequestValidatorPlugin.php.twig" : {}, - "GlueResourceRoutePlugin.php.twig" : {}, - "FormatResponseDataPlugin.php.twig" : {}, - "GlueResourceRelationshipPlugin.php.twig" : {}, - "ControllerBeforeActionPlugin.php.twig" : {} - } - }, - "Validation" : { - "AddGlueValidation.yml.twig" : {} - }, - "GlueRouteResource.php.twig" : {}, - "GlueResource.php.twig" : {}, - "GlueResourceInterface.php.twig" : {}, - "Controller" : { - "MethodGetGlueController.php.twig" : {}, - "MethodPostGlueController.php.twig" : {}, - "MethodDeleteGlueController.php.twig" : {}, - "MethodPatchGlueController.php.twig" : {}, - "GlueController.php.twig" : {} - }, - "Dependency" : { - "GlueDependencyBridgeMethod.php.twig" : {}, - "Client" : { - "GlueDependencyClientDependencyProviderMethod.php.twig" : {}, - "GlueDependencyClientBridge.php.twig" : {}, - "GlueDependencyClientToDependencyProvider.php.twig" : {}, - "GlueDependencyClientInterface.php.twig" : {}, - "GlueDependencyClientFactoryMethod.php.twig" : {} - }, - "GlueDependencyBridgeInterfaceMethod.php.twig" : {} - }, - "GlueFactory.php.twig" : {}, - "Processor" : { - "Mapper" : { - "GlueResourceMapperMethod.php.twig" : {}, - "GlueResourceMapperInterfaceMethod.php.twig" : {} - }, - "GlueProcessorModelInterface.php.twig" : {}, - "GlueProcessorModel.php.twig" : {} - }, - "GlueDependencyProvider.php.twig" : {}, - "GlueFactoryMethod.php.twig" : {}, - "GlueConfig.php.twig" : {} - }, - "gitignore.twig" : {}, - "phpstan.neon.twig" : {}, - "scrutinizer.yml.twig" : {}, - "template-map-v2.json" : {}, - "gitattributes.twig" : {}, - "codeception.yml.twig" : {}, - "Shared" : { - "SharedConstantsInterface.php.twig" : {}, - "transfer.xml.twig" : {} - }, - "CHANGELOG.md.twig" : {}, - "phpstan.json.twig" : {}, - "Zed" : { - "Dependency" : { - "Service" : { - "ZedDependencyServiceDependencyProviderMethod.php.twig" : {}, - "ZedDependencyServiceBridge.php.twig" : {}, - "ZedDependencyServiceBusinessFactoryMethod.php.twig" : {}, - "ZedDependencyServiceInterface.php.twig" : {} - }, - "ZedDependencyBridgeMethod.php.twig" : {}, - "Facade" : { - "ZedDependencyFacadeDependencyProviderMethod.php.twig" : {}, - "ZedDependencyFacadeBusinessFactoryMethod.php.twig" : {}, - "ZedDependencyFacadeBridge.php.twig" : {}, - "ZedDependencyFacadeInterface.php.twig" : {} - }, - "ZedDependencyBridgeInterfaceMethod.php.twig" : {}, - "Client" : { - "ZedDependencyClientBusinessFactoryMethod.php.twig" : {}, - "ZedDependencyClientBridge.php.twig" : {}, - "ZedDependencyClientInterface.php.twig" : {}, - "ZedDependencyClientDependencyProviderMethod.php.twig" : {} - } - }, - "Business" : { - "ZedBusinessFacadeInterface.php.twig" : {}, - "Model" : { - "ZedBusinessModel.php.twig" : {}, - "ZedBusinessModelInterface.php.twig" : {} - }, - "MethodBusinessFactory.php.twig" : {}, - "ZedBusinessFactory.php.twig" : {}, - "ZedBusinessFacadeTest.php.twig" : {}, - "ZedBusinessTestSuiteCodeceptionConfiguration.yml.twig" : {}, - "ZedBusinessFacade.php.twig" : {} - }, - "Communication" : { - "navigation.xml.twig" : {}, - "ZedCommunicationConsoleTest.php.twig" : {}, - "ZedCommunicationFactory.php.twig" : {}, - "ZedCommunicationTestSuiteCodeceptionConfiguration.yml.twig" : {}, - "ZedCommunicationController.php.twig" : {}, - "ZedCommunicationConsole.php.twig" : {}, - "MethodZedCommunicationController.php.twig" : {} - }, - "ZedDependencyProvider.php.twig" : {}, - "ZedConfig.php.twig" : {}, - "Persistence" : { - "ZedPersistenceEntityManagerInterface.php.twig" : {}, - "Propel" : { - "Schema" : { - "schema.xml.twig" : {} - }, - "AbstractQuery.php.twig" : {}, - "AbstractEntity.php.twig" : {} - }, - "ZedPersistenceFactory.php.twig" : {}, - "ZedPersistenceRepositoryInterface.php.twig" : {}, - "ZedPersistenceRepository.php.twig" : {}, - "ZedPersistenceEntityManager.php.twig" : {} - }, - "ZedTestCodeceptionConfiguration.yml.twig" : {}, - "Presentation" : { - "ZedPresentationTwig.twig" : {} - } - }, - "editorconfig.twig" : {}, - "coveralls.yml.twig" : {}, - "composer.json.twig" : {}, - "tree2json2.pl" : {}, - "README.md.twig" : {} - } -} diff --git a/src/main/resources/template-map.json b/src/main/resources/template-map.json deleted file mode 100644 index c58a39c..0000000 --- a/src/main/resources/template-map.json +++ /dev/null @@ -1,140 +0,0 @@ -[ - {"type":"directory","name":"templates/","contents":[ - {"type":"file","name":"CHANGELOG.md.twig"}, - {"type":"file","name":"ci.yml.twig"}, - {"type":"directory","name":"Client","contents":[ - {"type":"file","name":"ClientInterface.php.twig"}, - {"type":"file","name":"Client.php.twig"}, - {"type":"file","name":"Config.php.twig"}, - {"type":"file","name":"DependencyProvider.php.twig"}, - {"type":"file","name":"Factory.php.twig"} - ]}, - {"type":"file","name":"codeception.yml.twig"}, - {"type":"file","name":"composer.json.twig"}, - {"type":"file","name":"CONTRIBUTING.md.twig"}, - {"type":"file","name":"editorconfig.twig"}, - {"type":"file","name":"gitattributes.twig"}, - {"type":"file","name":"gitignore.twig"}, - {"type":"directory","name":"Glue","contents":[ - {"type":"file","name":"Config.php.twig"}, - {"type":"directory","name":"Controller","contents":[ - {"type":"file","name":"Controller.php.twig"} - ]}, - {"type":"file","name":"DependencyProvider.php.twig"}, - {"type":"file","name":"Factory.php.twig"}, - {"type":"directory","name":"Plugin","contents":[ - {"type":"directory","name":"GlueApplication","contents":[ - {"type":"file","name":"ControllerAfterActionPlugin.php.twig"}, - {"type":"file","name":"ControllerBeforeActionPlugin.php.twig"}, - {"type":"file","name":"FormatRequestPlugin.php.twig"}, - {"type":"file","name":"FormatResponseDataPlugin.php.twig"}, - {"type":"file","name":"FormatResponseHeadersPlugin.php.twig"}, - {"type":"file","name":"GlueResourceRoutePlugin.php.twig"}, - {"type":"file","name":"ResourceRelationshipPlugin.php.twig"}, - {"type":"file","name":"RestRequestValidatorPlugin.php.twig"}, - {"type":"file","name":"ValidateHttpRequestPlugin.php.twig"} - ]} - ]}, - {"type":"directory","name":"Validation","contents":[ - {"type":"file","name":"Validation.yml.twig"} - ]} - ]}, - {"type":"file","name":"LICENSE.twig"}, - {"type":"file","name":"phpstan.neon.twig"}, - {"type":"file","name":"README.md.twig"}, - {"type":"file","name":"scrutinizer.yml.twig"}, - {"type":"directory","name":"Service","contents":[ - {"type":"file","name":"Config.php.twig"}, - {"type":"file","name":"DependencyProvider.php.twig"}, - {"type":"file","name":"Factory.php.twig"}, - {"type":"file","name":"ServiceInterface.php.twig"}, - {"type":"file","name":"Service.php.twig"} - ]}, - {"type":"directory","name":"Shared","contents":[ - {"type":"file","name":"Constants.php.twig"}, - {"type":"directory","name":"Transfer","contents":[ - {"type":"file","name":"transfer.xml.twig"} - ]} - ]}, - {"type":"file","name":"tooling.yml.twig"}, - {"type":"directory","name":"Yves","contents":[ - {"type":"file","name":"Config.php.twig"}, - {"type":"directory","name":"Controller","contents":[ - {"type":"file","name":"Controller.php.twig"} - ]}, - {"type":"file","name":"DependencyProvider.php.twig"}, - {"type":"file","name":"Factory.php.twig"}, - {"type":"directory","name":"Plugin","contents":[ - {"type":"directory","name":"Router","contents":[ - {"type":"file","name":"RouteProviderPlugin.php.twig"} - ]} - ]}, - {"type":"directory","name":"Theme","contents":[ - {"type":"file","name":"ViewTwig.twig"}, - {"type":"file","name":"WidgetViewTwig.twig"} - ]}, - {"type":"directory","name":"Widget","contents":[ - {"type":"file","name":"Widget.php.twig"} - ]} - ]}, - {"type":"directory","name":"Zed","contents":[ - {"type":"directory","name":"Business","contents":[ - {"type":"file","name":"BusinessFactory.php.twig"}, - {"type":"directory","name":"Exception","contents":[ - {"type":"file","name":"$CustomException.php.twig"} - ]}, - {"type":"file","name":"FacadeInterface.php.twig"}, - {"type":"file","name":"Facade.php.twig"}, - {"type":"directory","name":"Model","contents":[ - {"type":"file","name":"$CustomBusinessModelInterface.php.twig"}, - {"type":"file","name":"$CustomBusinessModel.php.twig"} - ]}, - {"type":"directory","name":"Reader","contents":[ - {"type":"file","name":"ReaderInterface.php.twig"}, - {"type":"file","name":"Reader.php.twig"} - ]} - ]}, - {"type":"directory","name":"Communication","contents":[ - {"type":"file","name":"CommunicationFactory.php.twig"}, - {"type":"directory","name":"Console","contents":[ - {"type":"file","name":"Console.php.twig"} - ]}, - {"type":"directory","name":"Controller","contents":[ - {"type":"file","name":"$EditController.php.twig"}, - {"type":"file","name":"$GatewayController.php.twig"}, - {"type":"file","name":"$IndexController.php.twig"}, - {"type":"file","name":"$ViewController.php.twig"} - ]}, - {"type":"file","name":"navigation.xml.twig"}, - {"type":"directory","name":"Plugin","contents":[ - {"type":"directory","name":"Command","contents":[ - {"type":"file","name":"CommandPlugin.php.twig"} - ]}, - {"type":"directory","name":"Queue","contents":[ - {"type":"file","name":"QueueMessageProcessorPlugin.php.twig"}, - {"type":"file","name":"QueueMessageRetryProcessorPlugin.php.twig"} - ]} - ]} - ]}, - {"type":"file","name":"Config.php.twig"}, - {"type":"file","name":"DependencyProvider.php.twig"}, - {"type":"directory","name":"Persistence","contents":[ - {"type":"file","name":"EntityManagerInterface.php.twig"}, - {"type":"file","name":"EntityManager.php.twig"}, - {"type":"file","name":"PersistenceFactory.php.twig"}, - {"type":"directory","name":"Propel","contents":[ - {"type":"directory","name":"Schema","contents":[ - {"type":"file","name":"schema.xml.twig"} - ]} - ]}, - {"type":"file","name":"RepositoryInterface.php.twig"}, - {"type":"file","name":"Repository.php.twig"} - ]}, - {"type":"directory","name":"Presentation","contents":[ - {"type":"file","name":"index.twig"} - ]} - ]} - ]} -, - {"type":"report","directories":30,"files":74} -] diff --git a/src/test/java/mock/ProjectMock.java b/src/test/java/mock/ProjectMock.java index 90921b0..6f91aca 100644 --- a/src/test/java/mock/ProjectMock.java +++ b/src/test/java/mock/ProjectMock.java @@ -1,13 +1,21 @@ package mock; +import com.intellij.diagnostic.ActivityCategory; +import com.intellij.openapi.extensions.PluginDescriptor; +import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.messages.MessageBus; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.SystemIndependent; import org.picocontainer.PicoContainer; +import java.util.Map; + public class ProjectMock implements Project { public T serviceToReturn; @@ -16,7 +24,7 @@ public ProjectMock(T serviceToReturn) { this.serviceToReturn = serviceToReturn; } - public T getService(Class theClass) { + public T getService(@NotNull Class theClass) { return this.serviceToReturn; } @@ -82,11 +90,21 @@ public T getComponent(@org.jetbrains.annotations.NotNull Class interfaceC return null; } + @Override + public T @NotNull [] getComponents(@NotNull Class baseClass) { + return null; + } + @Override public @org.jetbrains.annotations.NotNull PicoContainer getPicoContainer() { return null; } + @Override + public boolean isInjectionForExtensionSupported() { + return false; + } + @Override public @org.jetbrains.annotations.NotNull MessageBus getMessageBus() { return null; @@ -102,6 +120,36 @@ public boolean isDisposed() { return null; } + @Override + public T instantiateClassWithConstructorInjection(@NotNull Class aClass, @NotNull Object key, @NotNull PluginId pluginId) { + return null; + } + + @Override + public @NotNull RuntimeException createError(@NotNull Throwable error, @NotNull PluginId pluginId) { + return new RuntimeException(); + } + + @Override + public @NotNull RuntimeException createError(@NotNull @NonNls String message, @NotNull PluginId pluginId) { + return new RuntimeException(); + } + + @Override + public @NotNull RuntimeException createError(@NotNull @NonNls String message, @Nullable Throwable error, @NotNull PluginId pluginId, @Nullable Map attachments) { + return new RuntimeException(); + } + + @Override + public @NotNull Class loadClass(@NotNull String className, @NotNull PluginDescriptor pluginDescriptor) throws ClassNotFoundException { + return (Class) ProjectMock.class.getClassLoader().loadClass(className); + } + + @Override + public @NotNull ActivityCategory getActivityCategory(boolean isExtension) { + return null; + } + @Override public void dispose() {