From 0db0dd4279e0422dbb42b95e37ba128ca04ed517 Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Wed, 1 Jan 2025 15:29:16 +0200 Subject: [PATCH 01/16] refactor --- .github/workflows/ci.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c73d8bc..e3282bf2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,23 +84,27 @@ jobs: # Check out current repository - name: Fetch Sources uses: actions/checkout@v4 + # Setup Java 11 environment for the next steps - name: Setup Java uses: actions/setup-java@v3.13.0 with: distribution: zulu java-version: 11 + # Perform clean before testing - name: Clean run: ./gradlew clean - # Run tests - - name: Tests - run: ./gradlew test -i --tests com.checkmarx.intellij.standard* - # Save report if tests fail - - name: Save fails report - if: ${{ failure() }} + + # Run tests and generate coverage report + - name: Tests with Coverage + run: ./gradlew test jacocoTestReport -i --tests com.checkmarx.intellij.standard* + + # Save coverage report as an artifact + - name: Upload Coverage Report uses: actions/upload-artifact@v4 with: - name: test-fails-report-integration + name: coverage-report path: | - build/reports + build/reports/jacoco/test/html/ + From f5ec56557509989f0cdb813b5eb5b43c2c839986 Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Wed, 1 Jan 2025 15:33:39 +0200 Subject: [PATCH 02/16] try add jaCoCo --- build.gradle | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e1c9abd0..d045bd3f 100644 --- a/build.gradle +++ b/build.gradle @@ -20,6 +20,23 @@ repositories { } } +plugins { + id 'java' + id 'jacoco' +} + +jacoco { + toolVersion = "0.8.12" // Specify the JaCoCo version +} + +tasks.jacocoTestReport { + dependsOn test // Ensure tests run before generating the report + reports { + xml.required.set(true) + html.required.set(true) + } +} + dependencies { testImplementation 'com.intellij.remoterobot:remote-robot:' + remoteRobotVersion testImplementation('com.intellij.remoterobot:remote-fixtures:' + remoteRobotVersion) { @@ -28,7 +45,7 @@ dependencies { testImplementation 'com.squareup.okio:okio:3.8.0' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.1' testImplementation 'com.squareup.okhttp3:okhttp:4.9.2' - testImplementation 'junit:junit:4.11-redhat-1' + testokhttp:4.12.0okhttp:4.12.0Implementation 'junit:junit:4.11-redhat-1' testImplementation 'junit:junit:4.13.1' // Video Recording From 8c0f6c129eb8cf62c929815c4b870b4ac335f170 Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Wed, 1 Jan 2025 15:33:52 +0200 Subject: [PATCH 03/16] try add jaCoCo --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index d045bd3f..ad905de3 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ plugins { } jacoco { - toolVersion = "0.8.12" // Specify the JaCoCo version + toolVersion = "0.8.8" // Specify the JaCoCo version } tasks.jacocoTestReport { @@ -45,7 +45,7 @@ dependencies { testImplementation 'com.squareup.okio:okio:3.8.0' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.1' testImplementation 'com.squareup.okhttp3:okhttp:4.9.2' - testokhttp:4.12.0okhttp:4.12.0Implementation 'junit:junit:4.11-redhat-1' + testImplementation 'junit:junit:4.11-redhat-1' testImplementation 'junit:junit:4.13.1' // Video Recording From 5f32e38ab6f2367bce4aa2dc79a935d6ad6e183d Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Wed, 1 Jan 2025 15:36:03 +0200 Subject: [PATCH 04/16] fix compilation --- build.gradle | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index ad905de3..e1cf0e0a 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'io.freefair.lombok' version '8.6' id 'org.jetbrains.intellij' version '1.17.4' id 'java' + id 'jacoco' } group 'com.checkmarx' @@ -20,11 +21,6 @@ repositories { } } -plugins { - id 'java' - id 'jacoco' -} - jacoco { toolVersion = "0.8.8" // Specify the JaCoCo version } From aacff5a36a63453f43351e3a35cda2b1213645f3 Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Wed, 1 Jan 2025 15:38:13 +0200 Subject: [PATCH 05/16] fix compilation --- .github/workflows/ci.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3282bf2..daa47fbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,15 +96,18 @@ jobs: - name: Clean run: ./gradlew clean - # Run tests and generate coverage report - - name: Tests with Coverage - run: ./gradlew test jacocoTestReport -i --tests com.checkmarx.intellij.standard* + # Run tests + - name: Run Tests + run: ./gradlew test -i --tests com.checkmarx.intellij.standard* + + # Generate coverage report + - name: Generate Coverage Report + run: ./gradlew jacocoTestReport -i # Save coverage report as an artifact - name: Upload Coverage Report uses: actions/upload-artifact@v4 with: name: coverage-report - path: | - build/reports/jacoco/test/html/ - + path: build/reports/jacoco/test/html/ + From a0bbe07f5faa29bfa6264b1d7f5c8601b3540e6c Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Thu, 2 Jan 2025 09:37:46 +0200 Subject: [PATCH 06/16] check --- .github/workflows/ci.yml | 13 ++++++++++--- build.gradle | 8 +++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index daa47fbc..b8d51b8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,9 +96,11 @@ jobs: - name: Clean run: ./gradlew clean - # Run tests - - name: Run Tests - run: ./gradlew test -i --tests com.checkmarx.intellij.standard* + # Run tests and capture exit code + - name: Run Tests with coverage report + id: test_results + run: | + ./gradlew test --tests "com.checkmarx.intellij.standard*" jacocoTestReport || echo "TESTS_FAILED=true" >> $GITHUB_ENV # Generate coverage report - name: Generate Coverage Report @@ -111,3 +113,8 @@ jobs: name: coverage-report path: build/reports/jacoco/test/html/ + # Fail the pipeline if tests failed + - name: Fail Pipeline if Tests Failed + if: env.TESTS_FAILED == 'true' + run: exit 1 + diff --git a/build.gradle b/build.gradle index e1cf0e0a..19ee78bf 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,13 @@ repositories { } jacoco { - toolVersion = "0.8.8" // Specify the JaCoCo version + toolVersion = "0.8.12" // Specify the JaCoCo version +} + +tasks.test { + useJUnitPlatform() // Ensure you're using the correct test framework + include "com.checkmarx.intellij.standard*" // Adjust the path to match the folder structure + finalizedBy jacocoTestReport } tasks.jacocoTestReport { From f9196c54c42209f53c49e4e42e9cca8b11688a2e Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Thu, 2 Jan 2025 09:43:48 +0200 Subject: [PATCH 07/16] check --- .github/workflows/ci.yml | 4 ---- build.gradle | 6 ------ 2 files changed, 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8d51b8b..e3460d2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,10 +102,6 @@ jobs: run: | ./gradlew test --tests "com.checkmarx.intellij.standard*" jacocoTestReport || echo "TESTS_FAILED=true" >> $GITHUB_ENV - # Generate coverage report - - name: Generate Coverage Report - run: ./gradlew jacocoTestReport -i - # Save coverage report as an artifact - name: Upload Coverage Report uses: actions/upload-artifact@v4 diff --git a/build.gradle b/build.gradle index 19ee78bf..738614a0 100644 --- a/build.gradle +++ b/build.gradle @@ -25,12 +25,6 @@ jacoco { toolVersion = "0.8.12" // Specify the JaCoCo version } -tasks.test { - useJUnitPlatform() // Ensure you're using the correct test framework - include "com.checkmarx.intellij.standard*" // Adjust the path to match the folder structure - finalizedBy jacocoTestReport -} - tasks.jacocoTestReport { dependsOn test // Ensure tests run before generating the report reports { From 435d3cc1e316bdd3389185a82f5e8754f0861543 Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Sun, 5 Jan 2025 11:10:54 +0200 Subject: [PATCH 08/16] check --- build.gradle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 738614a0..738ed87d 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,10 @@ repositories { } jacoco { - toolVersion = "0.8.12" // Specify the JaCoCo version + toolVersion = "0.8.12" + append = true + includes = ['com.checkmarx.intellij.*'] + // Specify the JaCoCo version } tasks.jacocoTestReport { From 1d1c61e383be9eed1e6a6b51ee26152f99f98e51 Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Sun, 5 Jan 2025 11:34:20 +0200 Subject: [PATCH 09/16] check --- build.gradle | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 738ed87d..58282ca9 100644 --- a/build.gradle +++ b/build.gradle @@ -23,9 +23,6 @@ repositories { jacoco { toolVersion = "0.8.12" - append = true - includes = ['com.checkmarx.intellij.*'] - // Specify the JaCoCo version } tasks.jacocoTestReport { @@ -101,6 +98,15 @@ runIdeForUiTests { systemProperty 'jb.consents.confirmation.enabled', 'false' } +jacocoTestReport { + additionalSourceDirs.setFrom(files(sourceSets.main.allSource.srcDirs)) + classDirectories.setFrom( + fileTree(dir: "$buildDir/classes/java/main", excludes: []) + ) + executionData.setFrom(fileTree(dir: "$buildDir", includes: ["jacoco/test.exec"])) +} + + publishPlugin { token.set System.getenv("PUBLISH_TOKEN") if (project.hasProperty("rchannels")) { From 17cb009e73db282218dc680de73332167f635aac Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Sun, 5 Jan 2025 11:35:34 +0200 Subject: [PATCH 10/16] make test run faster --- .../com/checkmarx/intellij/standard/commands/TestScan.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java b/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java index 49864b0b..3cf865f8 100644 --- a/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java +++ b/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java @@ -27,7 +27,11 @@ public void testGetList() { String msg = String.format("project: %s branch: %s scans: %d", project.getId(), Environment.BRANCH_NAME, scans.size()); Assertions.assertTrue(scans.size() > 0, msg); Assertions.assertTrue(scans.size() <= 10000, msg); + int i = 0; for (com.checkmarx.ast.scan.Scan scan : scans) { + if (i++ > 10) { + break; + } Assertions.assertEquals("Completed", scan.getStatus()); Assertions.assertEquals(Environment.BRANCH_NAME, scan.getBranch()); Assertions.assertEquals(getEnvProject().getId(), scan.getProjectId()); From 62f53e2925511a05855f76d180078068006a9613 Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Sun, 5 Jan 2025 12:12:35 +0200 Subject: [PATCH 11/16] make test run faster --- .../checkmarx/intellij/standard/commands/TestScan.java | 10 +--------- .../intellij/standard/commands/TestScanAsca.java | 4 ++++ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java b/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java index 3cf865f8..6edd6fa7 100644 --- a/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java +++ b/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java @@ -27,15 +27,7 @@ public void testGetList() { String msg = String.format("project: %s branch: %s scans: %d", project.getId(), Environment.BRANCH_NAME, scans.size()); Assertions.assertTrue(scans.size() > 0, msg); Assertions.assertTrue(scans.size() <= 10000, msg); - int i = 0; - for (com.checkmarx.ast.scan.Scan scan : scans) { - if (i++ > 10) { - break; - } - Assertions.assertEquals("Completed", scan.getStatus()); - Assertions.assertEquals(Environment.BRANCH_NAME, scan.getBranch()); - Assertions.assertEquals(getEnvProject().getId(), scan.getProjectId()); - } + Assertions.assertTrue(scans.stream().allMatch(scan -> scan.getProjectId().equals(project.getId()) && scan.getBranch().equals(Environment.BRANCH_NAME) && scan.getStatus().equals("Completed"))); } @Test diff --git a/src/test/java/com/checkmarx/intellij/standard/commands/TestScanAsca.java b/src/test/java/com/checkmarx/intellij/standard/commands/TestScanAsca.java index c941c408..cb3ef6cc 100644 --- a/src/test/java/com/checkmarx/intellij/standard/commands/TestScanAsca.java +++ b/src/test/java/com/checkmarx/intellij/standard/commands/TestScanAsca.java @@ -13,6 +13,7 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class TestScanAsca extends BaseTest { AscaService ascaService = new AscaService(); @@ -43,6 +44,7 @@ private PsiFile createPsiFileFromPath(String filePath) { return psiFile; } + @Test public void testRunAscaScan_FileWithVulnerabilities_Success() { PsiFile psiFile = createPsiFileFromPath("src/test/java/com/checkmarx/intellij/standard/data/python-vul-file.py"); Project project = ProjectManager.getInstance().getDefaultProject(); @@ -55,6 +57,7 @@ public void testRunAscaScan_FileWithVulnerabilities_Success() { }); } + @Test public void testRunAscaScan_FileWithNoVulnerabilities_Success() { PsiFile psiFile = createPsiFileFromPath("src/test/java/com/checkmarx/intellij/standard/data/csharp-no-vul.cs"); Project project = ProjectManager.getInstance().getDefaultProject(); @@ -66,6 +69,7 @@ public void testRunAscaScan_FileWithNoVulnerabilities_Success() { }); } + @Test public void testRunAscaScan_FileWithoutExtension_Fail() { PsiFile psiFile = createPsiFileFromPath("src/test/java/com/checkmarx/intellij/standard/data/file"); Project project = ProjectManager.getInstance().getDefaultProject(); From b73aa4dcffcffcc116dbbab57d21e5241536bdc8 Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Sun, 5 Jan 2025 12:24:09 +0200 Subject: [PATCH 12/16] revert ci.yml changes --- .github/workflows/ci.yml | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3460d2c..a00b68ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,5 @@ name: Checkmarx One Jetbrains Plugin CI - on: [ pull_request, workflow_dispatch ] - env: CX_BASE_URI: ${{ secrets.CX_BASE_URI }} CX_APIKEY: ${{ secrets.CX_APIKEY }} @@ -14,12 +12,9 @@ env: CX_NOT_MATCH_TEST_PROJECT: ${{ secrets.CX_NOT_MATCH_TEST_PROJECT }} CX_NOT_MATCH_TEST_BRANCH: ${{ secrets.CX_NOT_MATCH_TEST_BRANCH }} CX_NOT_MATCH_TEST_SCAN_ID: ${{ secrets.CX_NOT_MATCH_TEST_SCAN_ID }} - - concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true - jobs: testUI: needs: [ testIntegration ] @@ -84,33 +79,23 @@ jobs: # Check out current repository - name: Fetch Sources uses: actions/checkout@v4 - # Setup Java 11 environment for the next steps - name: Setup Java uses: actions/setup-java@v3.13.0 with: distribution: zulu java-version: 11 - # Perform clean before testing - name: Clean run: ./gradlew clean - - # Run tests and capture exit code - - name: Run Tests with coverage report - id: test_results - run: | - ./gradlew test --tests "com.checkmarx.intellij.standard*" jacocoTestReport || echo "TESTS_FAILED=true" >> $GITHUB_ENV - - # Save coverage report as an artifact - - name: Upload Coverage Report + # Run tests + - name: Tests + run: ./gradlew test -i --tests com.checkmarx.intellij.standard* + # Save report if tests fail + - name: Save fails report + if: ${{ failure() }} uses: actions/upload-artifact@v4 with: - name: coverage-report - path: build/reports/jacoco/test/html/ - - # Fail the pipeline if tests failed - - name: Fail Pipeline if Tests Failed - if: env.TESTS_FAILED == 'true' - run: exit 1 - + name: test-fails-report-integration + path: | + build/reports \ No newline at end of file From 8bb16e6164f5f52059732bbc4dcfb1289d1a0f75 Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Sun, 5 Jan 2025 12:31:23 +0200 Subject: [PATCH 13/16] ci.yml changes --- .github/workflows/ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a00b68ae..16448b14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,8 +89,16 @@ jobs: - name: Clean run: ./gradlew clean # Run tests - - name: Tests - run: ./gradlew test -i --tests com.checkmarx.intellij.standard* + - name: Run Tests with coverage report + id: test_results + run: | + ./gradlew test --tests "com.checkmarx.intellij.standard*" jacocoTestReport + # Save coverage report as an artifact + - name: Upload Coverage Report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: build/reports/jacoco/test/html/ # Save report if tests fail - name: Save fails report if: ${{ failure() }} From 22fab8c339a95916fba0077b1570096d637d198c Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Sun, 5 Jan 2025 14:12:36 +0200 Subject: [PATCH 14/16] ci.yml changes --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16448b14..af5e8d4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: distribution: zulu java-version: 11 - name: Setup FFmpeg - uses: FedericoCarboni/setup-ffmpeg@v2 + uses: FedericoCarboni/setup-ffmpeg@583042d32dd1cabb8bd09df03bde06080da5c87c #v2.0.0 with: # Not strictly necessary, but it may prevent rate limit # errors especially on GitHub-hosted macos machines. From 776ea96e5045db1a84a2159bf46ab72f461b675f Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Mon, 6 Jan 2025 15:32:24 +0200 Subject: [PATCH 15/16] check downgrade jacoco version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 58282ca9..1abef41f 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ repositories { } jacoco { - toolVersion = "0.8.12" + toolVersion = "0.8.7" } tasks.jacocoTestReport { From a9d648e7d8d45db9b4371125c57eab86e6e60b7b Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Tue, 7 Jan 2025 14:06:35 +0200 Subject: [PATCH 16/16] resolve conversations --- .../java/com/checkmarx/intellij/standard/commands/TestScan.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java b/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java index 6edd6fa7..303d621c 100644 --- a/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java +++ b/src/test/java/com/checkmarx/intellij/standard/commands/TestScan.java @@ -27,6 +27,8 @@ public void testGetList() { String msg = String.format("project: %s branch: %s scans: %d", project.getId(), Environment.BRANCH_NAME, scans.size()); Assertions.assertTrue(scans.size() > 0, msg); Assertions.assertTrue(scans.size() <= 10000, msg); + + // Check that all scans are for the correct project and branch and have completed Assertions.assertTrue(scans.stream().allMatch(scan -> scan.getProjectId().equals(project.getId()) && scan.getBranch().equals(Environment.BRANCH_NAME) && scan.getStatus().equals("Completed"))); }