ci: Add GitHub Actions CI for Linux and Windows, update Mac workflow#35
ci: Add GitHub Actions CI for Linux and Windows, update Mac workflow#35laileni-aws wants to merge 1 commit intomainfrom
Conversation
…34) * ci: adding linux and windows unit tests * fix: Added LOCAL_ENV_RUN: true env var — set in all CodeBuild buildspecs * fix: Fix the race condition in testGetCredentialsExpired * fix: resolve test failures on GitHub Actions CI runners - Add coroutine scheduler pool size (4) to test JVM args to fix ClosedSendChannelException/Transactor errors on low-core GHA runners - Fix race condition in AwsCognitoCredentialsProviderTest where NonBlocking prefetch triggers extra refresh calls on slower runners - Add Xvfb virtual display for Linux unit tests - Install git-secrets for Linux CI - Add Linux and Windows unit test workflows with IDE version matrix * fix: test it * fix: fix mac unit test ci * fix: modifying tests
| name: Linux (${{ matrix.ideProfileName }}) | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| ideProfileName: [ "2025.1", "2025.2", "2025.3" ] | ||
| env: | ||
| CI: true | ||
| LOCAL_ENV_RUN: true | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up JDK 21 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: 21 | ||
| distribution: 'corretto' | ||
| cache: 'gradle' | ||
|
|
||
| - name: Configure Gradle properties | ||
| run: | | ||
| mkdir -p ~/.gradle | ||
| cat >> ~/.gradle/gradle.properties <<EOF | ||
| org.gradle.jvmargs=-Xmx4g | ||
| kotlin.daemon.jvmargs=-Xmx4g | ||
| EOF | ||
|
|
||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x gradlew | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| Xvfb :99 -screen 0 1920x1080x24 & | ||
| export DISPLAY=:99 | ||
| ./gradlew -PideProfileName=${{ matrix.ideProfileName }} check coverageReport -x gitSecrets --info --stacktrace --console plain --continue | ||
|
|
||
| - name: Build plugin | ||
| if: success() | ||
| run: ./gradlew -PideProfileName=${{ matrix.ideProfileName }} buildPlugin | ||
|
|
||
| - name: Collect test artifacts | ||
| if: always() | ||
| run: | | ||
| mkdir -p /tmp/testArtifacts/test-reports | ||
| rsync -rmq --include='*/' --include '**/build/idea-sandbox/**/log*/**' --exclude='*' . /tmp/testArtifacts/ || true | ||
| rsync -rmq --include='*/' --include '**/build/reports/**' --exclude='*' . /tmp/testArtifacts/ || true | ||
| rsync -rmq --include='*/' --include '**/test-results/**/*.xml' --exclude='*' . /tmp/testArtifacts/test-reports || true | ||
|
|
||
| - name: Upload test artifacts | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: linux-test-artifacts-${{ matrix.ideProfileName }} | ||
| path: /tmp/testArtifacts/ | ||
| retention-days: 14 | ||
|
|
||
| - name: Upload plugin artifact | ||
| if: success() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: linux-plugin-${{ matrix.ideProfileName }} | ||
| path: plugins/**/build/distributions/*.zip | ||
| retention-days: 14 |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
Generally, the fix is to explicitly define a permissions block in the workflow (at the root or per job) to restrict the GITHUB_TOKEN to the least privileges required. For this specific workflow, the job only checks out code and uploads artifacts, so contents: read is sufficient. No steps modify issues, pull requests, or repository contents.
The best minimal-impact fix is to add a permissions section to the linux-unit-tests job. This keeps the change localized and avoids affecting other workflows or jobs. Concretely, in .github/workflows/linux-unit-tests.yml, within the linux-unit-tests job definition, add:
permissions:
contents: readright after the runs-on: ubuntu-latest line (or anywhere within the job’s top-level keys). No imports or additional methods are needed; this is purely a YAML configuration change. Functionality remains the same, but the GITHUB_TOKEN is now explicitly limited.
| @@ -10,6 +10,8 @@ | ||
| linux-unit-tests: | ||
| name: Linux (${{ matrix.ideProfileName }}) | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: |
| name: Windows (${{ matrix.ideProfileName }}) | ||
| runs-on: windows-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| ideProfileName: [ "2025.1", "2025.2", "2025.3" ] | ||
| env: | ||
| CI: true | ||
| LOCAL_ENV_RUN: true | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK 21 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: 21 | ||
| distribution: 'corretto' | ||
| cache: 'gradle' | ||
|
|
||
| - name: Configure Gradle properties | ||
| shell: pwsh | ||
| run: | | ||
| New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.gradle" | Out-Null | ||
| @" | ||
| org.gradle.jvmargs=-Xmx4g | ||
| kotlin.daemon.jvmargs=-Xmx4g | ||
| "@ | Add-Content -Path "$env:USERPROFILE\.gradle\gradle.properties" | ||
|
|
||
| - name: Run tests | ||
| run: ./gradlew -PideProfileName="${{ matrix.ideProfileName }}" coverageReport --info --console plain | ||
|
|
||
| - name: Collect test artifacts | ||
| if: always() | ||
| shell: pwsh | ||
| run: | | ||
| $TEST_ARTIFACTS = Join-Path $env:TEMP "testArtifacts" | ||
| $TEST_REPORTS = Join-Path $TEST_ARTIFACTS "test-reports" | ||
| New-Item -ItemType Directory -Force -Path $TEST_REPORTS | Out-Null | ||
|
|
||
| function Copy-Artifacts($filter, $destdir) { | ||
| Get-ChildItem -Recurse -Directory -ErrorAction SilentlyContinue | | ||
| Where-Object { $_.FullName -Like "$filter" } | | ||
| ForEach-Object { | ||
| $relativePath = Resolve-Path -Relative $_.FullName | ||
| $dest = Join-Path $destdir $relativePath | ||
| Copy-Item -Path $_.FullName -Destination $dest -Recurse -Container -ErrorAction SilentlyContinue | ||
| } | ||
| } | ||
|
|
||
| Copy-Artifacts "*\build\idea-sandbox\*\log*" $TEST_ARTIFACTS | ||
| Copy-Artifacts "*\build\reports" $TEST_ARTIFACTS | ||
| Copy-Artifacts "*\test-results" $TEST_REPORTS | ||
|
|
||
| echo "TEST_ARTIFACTS=$TEST_ARTIFACTS" >> $env:GITHUB_ENV | ||
|
|
||
| - name: Upload test artifacts | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: windows-test-artifacts-${{ matrix.ideProfileName }} | ||
| path: ${{ env.TEST_ARTIFACTS }} | ||
| retention-days: 14 |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
In general, the fix is to explicitly declare a permissions: block for the workflow or the specific job, granting only the minimal required scopes. For this job, the steps only read repository contents (for checkout) and interact with the Actions artifact service; they do not need to write to repository contents, issues, or pull requests. The minimal safe configuration is to set contents: read, which is precisely what the CodeQL message suggests as a starting point.
The most direct and non-invasive fix is to add a permissions: block under the windows-unit-tests job, so it only affects this job and does not change behavior for any other jobs that might exist in the workflow file (we are only shown one, but this approach stays conservative). Concretely, in .github/workflows/windows-unit-tests.yml, insert:
permissions:
contents: readbetween the name: and runs-on: keys for the windows-unit-tests job (around lines 11–12). No new imports or external dependencies are needed, and no existing functionality changes, because GitHub’s standard actions (actions/checkout, actions/setup-java, actions/upload-artifact) all work with read-only contents permissions.
| @@ -9,6 +9,8 @@ | ||
| jobs: | ||
| windows-unit-tests: | ||
| name: Windows (${{ matrix.ideProfileName }}) | ||
| permissions: | ||
| contents: read | ||
| runs-on: windows-latest | ||
| strategy: | ||
| fail-fast: false |
Qodana for JVMIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked View the detailed Qodana reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2025.1.1
with:
upload-result: trueContact Qodana teamContact us at qodana-support@jetbrains.com
|
Summary
Adds GitHub Actions CI workflows for Linux and Windows unit tests, and updates the existing Mac workflow to match. Linux and Windows now run tests against IDE versions 2025.1, 2025.2, and 2025.3 in a matrix and Mac runs on 2025.3 version.
Workflows
linux-unit-tests.ymlubuntu-latestcheck coverageReport -x gitSecretswindows-unit-tests.ymlwindows-latestcoverageReportmac.yml(updated)macos-latestcheck coverageReport -x gitSecretsAll workflows trigger on push to
mainand PRs targetingmain,feature/*,fix/*,test/*.Build config fixes
Coroutine pool size: Added
systemProperty("kotlinx.coroutines.scheduler.core.pool.size", "4")to test JVM args intoolkit-intellij-subplugin.gradle.kts. GHA runners have 2 CPU cores, which starves the IntelliJ Fleet kernel Transactor when kotlinx.coroutines defaults pool size to CPU count.Cognito test race condition: Changed
verify(cognitoClient, times(1))toverify(cognitoClient, atLeast(2))inAwsCognitoCredentialsProviderTest.testGetCredentialsExpired. TheNonBlockingprefetch strategy causes additionalgetCredentialsForIdentitycalls on slower CI runners.Platform-specific notes
Xvfb :99) for AWT/Swing display support needed by IntelliJ test framework.coverageReportonly (notcheck), matching the existing CodeBuild buildspec behavior.-x gitSecretson Linux and Mac. The Gradle-downloadedgit-secretsscript has shell compatibility issues on GHA Ubuntu runners (/bin/sh→dash). GitHub's built-in secret scanning provides equivalent coverage.Common configuration across all workflows
gradle/actions/setup-gradle@v4-Dorg.gradle.jvmargs=-Xmx4gLOCAL_ENV_RUN=true,CI=truefetch-depth: 0--continueflagChecklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.