Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/IJ-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Latest IJ
on:
schedule:
- cron: "0 0 * * *"

jobs:

build:
Expand All @@ -23,7 +23,12 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build --continue -PideaVersion=LATEST-EAP-SNAPSHOT
run: >
./gradlew build
--continue
-PideaVersion=LATEST-EAP-SNAPSHOT
-Pgpr.username=${{ github.actor }}
-Pgpr.token=${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v2
if: always()
with:
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/IJ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew buildPlugin -PideaVersion=${{ matrix.IJ }}
run: >
./gradlew buildPlugin
-PideaVersion=${{ matrix.IJ }}
-Pgpr.username=${{ github.actor }}
-Pgpr.token=${{ secrets.GITHUB_TOKEN }}

verify:
runs-on: ubuntu-latest
Expand All @@ -44,7 +48,11 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew runPluginVerifier -PideaVersion=IC-2022.1
run: >
./gradlew runPluginVerifier
-PideaVersion=IC-2022.1
-Pgpr.username=${{ github.actor }}
-Pgpr.token=${{ secrets.GITHUB_TOKEN }}
- name: Upload report
uses: actions/upload-artifact@v2
if: always()
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew test
run: >
./gradlew test
-Pgpr.username=${{ github.actor }}
-Pgpr.token=${{ secrets.GITHUB_TOKEN }}

build-macos:
runs-on: macos-latest
Expand All @@ -40,7 +43,10 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew test
run: >
./gradlew test
-Pgpr.username=${{ github.actor }}
-Pgpr.token=${{ secrets.GITHUB_TOKEN }}

build-windows:
runs-on: windows-latest
Expand All @@ -56,5 +62,7 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew test

5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew buildPlugin
run: >
./gradlew buildPlugin
-Pgpr.username=${{ github.actor }}
-Pgpr.token=${{ secrets.GITHUB_TOKEN }}
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ jobs:
- name: Build plugin with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: buildPlugin
arguments: |
buildPlugin
-Pgpr.username=${{ github.actor }}
-Pgpr.token=${{ secrets.GITHUB_TOKEN }}

- name: Upload distribution archive as artifact
uses: actions/upload-artifact@v3
Expand Down
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ repositories {
dirs buildDir
}
maven { url 'https://jitpack.io' }
maven {
url 'https://maven.pkg.github.com/RHEcosystemAppEng/crda-java-api'
credentials {
username = project.findProperty("gpr.username") ?: System.getenv("GITHUB_USERNAME")
password = project.findProperty("gpr.token") ?: System.getenv("GITHUB_TOKEN")
}
}
}

apply plugin: 'idea'
Expand Down Expand Up @@ -48,6 +55,7 @@ dependencies {
}
implementation 'org.kohsuke:github-api:1.314'
implementation 'org.apache.commons:commons-compress:1.21'
implementation 'com.redhat.crda:crda-java-api:0.0.1-SNAPSHOT'
testImplementation('junit:junit:4.13.1')
}

Expand Down
60 changes: 60 additions & 0 deletions src/main/java/org/jboss/tools/intellij/crda/ApiService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.jboss.tools.intellij.crda;

import com.intellij.openapi.components.Service;
import com.redhat.crda.Api;
import com.redhat.crda.impl.CrdaApi;
import com.redhat.crda.tools.Ecosystem;
import org.jboss.tools.intellij.analytics.TelemetryService;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.ExecutionException;

@Service(Service.Level.PROJECT)
public final class ApiService {
enum TelemetryKeys {
MANIFEST, ECOSYSTEM, PLATFORM;

@Override
public String toString() {
return this.name().toLowerCase();
}
}

private final Api crdaApi;

public ApiService() {
this(new CrdaApi());
}

ApiService(Api crdaApi) {
this.crdaApi = crdaApi;
}

public Path getStackAnalysis(
final Ecosystem.PackageManager packageManager,
final String manifestName,
final String manifestPath
) throws RuntimeException {

var telemetryMsg = TelemetryService.instance().action("stack-analysis");
telemetryMsg.property(TelemetryKeys.ECOSYSTEM.toString(), packageManager.toString());
telemetryMsg.property(TelemetryKeys.PLATFORM.toString(), System.getProperty("os.name"));
telemetryMsg.property(TelemetryKeys.MANIFEST.toString(), manifestName);

try {
var htmlContent = crdaApi.stackAnalysisHtmlAsync(manifestPath);
var tmpFile = Files.createTempFile("crda_", ".html");
Files.write(tmpFile, htmlContent.get());

telemetryMsg.send();
return tmpFile;

} catch (IOException | InterruptedException | ExecutionException exc) {
telemetryMsg.error(exc);
telemetryMsg.send();
throw new RuntimeException(exc);
}
}
}
23 changes: 20 additions & 3 deletions src/main/java/org/jboss/tools/intellij/stackanalysis/SaAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,27 @@
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;

import org.jboss.tools.intellij.crda.ApiService;
import com.redhat.crda.tools.Ecosystem;
import org.jboss.tools.intellij.analytics.Platform;
import org.jetbrains.annotations.NotNull;


public class SaAction extends AnAction {
private static final Logger logger = Logger.getInstance(SaAction.class);

private final ApiService apiService;

public SaAction() {
apiService = ServiceManager.getService(ApiService.class);
}

/**
* <p>Intellij Plugin Action implementation for triggering SA.</p>
*
Expand All @@ -43,15 +51,24 @@ public void actionPerformed(@NotNull AnActionEvent event) {
VirtualFile manifestFile = event.getData(PlatformDataKeys.VIRTUAL_FILE);

// Get SA report for given manifest file.
JsonObject saReportJson = saUtils.getReport(manifestFile.getPath());
String reportLink;
if ("pom.xml".equals(manifestFile.getName())) {
reportLink = apiService.getStackAnalysis(
Ecosystem.PackageManager.MAVEN,
manifestFile.getName(),
manifestFile.getPath()
).toUri().toString();
} else {
reportLink = saUtils.getReport(manifestFile.getPath()).get("report_link").getAsString();
}

// Manifest file details to be saved in temp file which will be used while opening Report tab
JsonObject manifestDetails = new JsonObject();
manifestDetails.addProperty("showParent", false);
manifestDetails.addProperty("manifestName", manifestFile.getName());
manifestDetails.addProperty("manifestPath", manifestFile.getPath());
manifestDetails.addProperty("manifestFileParent", manifestFile.getParent().getName());
manifestDetails.addProperty("report_link", saReportJson.get("report_link").getAsString());
manifestDetails.addProperty("report_link", reportLink);
manifestDetails.addProperty("manifestNameWithoutExtension", manifestFile.getNameWithoutExtension());

// Open custom editor window which will load SA Report in browser attached to it.
Expand Down