From 5f825c702f87ba272f3f4b4f955522ccdd415285 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 12 Apr 2024 10:26:07 +0200 Subject: [PATCH 1/5] Initial CI reorganization --- .github/workflows/ci.yml | 65 +++++++++++ .github/workflows/run-ui-tests.yml | 59 ---------- .github/workflows/step_draft.yml | 42 +++++++ .github/workflows/step_static-analysis.yml | 29 +++++ .../workflows/{build.yml => step_tests.yml} | 109 +++++++++--------- 5 files changed, 191 insertions(+), 113 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/run-ui-tests.yml create mode 100644 .github/workflows/step_draft.yml create mode 100644 .github/workflows/step_static-analysis.yml rename .github/workflows/{build.yml => step_tests.yml} (66%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..33d3c7d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: CI +run-name: > + CI (${{ github.event_name }}) + ${{ github.event_name == 'pull_request' && format('PR#{0}', github.event.number) || '' }} + +on: + workflow_dispatch: + inputs: + ui-tests: + description: Run UI-tests + type: boolean + default: false + pull_request: + branches: [ main ] + push: + branches: [ main ] + schedule: + - cron: 0 0 15 * * + + +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + name: ๐Ÿงช tests + uses: ./.github/workflows/step_tests.yml + with: + mask-experimental: ${{ github.event_name == 'push' }} + ui-tests: ${{ inputs.ui-tests || false }} + + static-analysis: + name: ๐Ÿ” Static-Analysis + uses: ./.github/workflows/step_static-analysis.yml + secrets: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} + permissions: + security-events: write + contents: write + checks: write + pull-requests: write + if: github.event_name != 'schedule' + + draft: + name: ๐Ÿš€ Release + needs: [ tests, static-analysis ] + uses: ./.github/workflows/step_draft.yml + permissions: + contents: write + if: github.event_name == 'push' + + pass: + name: โœ… Pass + needs: [ tests, static-analysis, draft ] + runs-on: ubuntu-latest + steps: + - name: Check all CI jobs + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} + allowed-skips: draft, static-analysis + if: always() diff --git a/.github/workflows/run-ui-tests.yml b/.github/workflows/run-ui-tests.yml deleted file mode 100644 index 45a08f2..0000000 --- a/.github/workflows/run-ui-tests.yml +++ /dev/null @@ -1,59 +0,0 @@ -# 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 Platform -# -# Workflow is triggered manually. - -name: Run UI Tests -on: - workflow_dispatch - -jobs: - - testUI: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-latest - runIde: | - export DISPLAY=:99.0 - Xvfb -ac :99 -screen 0 1920x1080x16 & - gradle runIdeForUiTests & - - os: windows-latest - runIde: start gradlew.bat runIdeForUiTests - - os: macos-latest - runIde: ./gradlew runIdeForUiTests & - - steps: - - # Check out current repository - - name: Fetch Sources - uses: actions/checkout@v3 - - # Setup Java 11 environment for the next steps - - name: Setup Java - uses: actions/setup-java@v3 - with: - distribution: zulu - java-version: 17 - - # Run IDEA prepared for UI testing - - name: Run IDE - run: ${{ matrix.runIde }} - - # Wait for IDEA to be started - - name: Health Check - uses: jtalk/url-health-check-action@v3 - with: - url: http://127.0.0.1:8082 - max-attempts: 15 - retry-delay: 30s - - # Run tests - - name: Tests - run: ./gradlew test diff --git a/.github/workflows/step_draft.yml b/.github/workflows/step_draft.yml new file mode 100644 index 0000000..5d65716 --- /dev/null +++ b/.github/workflows/step_draft.yml @@ -0,0 +1,42 @@ +# TODO: Unify with release.yml +name: Draft + +on: + workflow_call: + +permissions: + contents: write + +jobs: + Draft: + # TODO: Get the artifacts from a build run + # What to do with this workflow? + runs-on: ubuntu-latest + steps: + + # Check out current repository + - name: Fetch Sources + uses: actions/checkout@v3 + + # Remove old release drafts by using the curl request for the available releases with a draft flag + - name: Remove Old Release Drafts + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh api repos/{owner}/{repo}/releases \ + --jq '.[] | select(.draft == true) | .id' \ + | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} + + # Create a new release draft which is not publicly visible and requires manual acceptance + - name: Create Release Draft + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create v${{ needs.build.outputs.version }} \ + --draft \ + --title "v${{ needs.build.outputs.version }}" \ + --notes "$(cat << 'EOM' + ${{ needs.build.outputs.changelog }} + EOM + )" + if: false diff --git a/.github/workflows/step_static-analysis.yml b/.github/workflows/step_static-analysis.yml new file mode 100644 index 0000000..eefd7ea --- /dev/null +++ b/.github/workflows/step_static-analysis.yml @@ -0,0 +1,29 @@ +name: Static Analysis + +on: + workflow_call: + secrets: + QODANA_TOKEN: + required: false + description: Qodana token + +permissions: + security-events: write + contents: write + checks: write + pull-requests: write + +jobs: + Qodana: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # TODO: Java setup? + - name: Qodana Scan + uses: JetBrains/qodana-action@v2023.3 + env: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} + - name: Upload to GitHub code scanning + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json diff --git a/.github/workflows/build.yml b/.github/workflows/step_tests.yml similarity index 66% rename from .github/workflows/build.yml rename to .github/workflows/step_tests.yml index 19035a2..3c6866d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/step_tests.yml @@ -1,30 +1,25 @@ -# GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps: -# - validate Gradle Wrapper, -# - run 'test' and 'verifyPlugin' tasks, -# - run Qodana inspections, -# - 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. -# -# GitHub Actions reference: https://help.github.com/en/actions -# -## JBIJPPTPL - -name: Build +name: ๐Ÿงช tests + on: - # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests) - push: - branches: [main] - # Trigger the workflow on any pull request - pull_request: + workflow_call: + inputs: + mask-experimental: + type: boolean + default: true + description: Always report experimental test as successful + ui-tests: + type: boolean + default: false + description: Run UI-tests + +permissions: {} jobs: # Run Gradle Wrapper Validation Action to verify the wrapper's checksum # Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks # Build plugin and provide the artifact for the next workflow jobs + # TODO: Separate build and and test steps build: name: Build runs-on: ubuntu-latest @@ -112,10 +107,6 @@ jobs: name: pluginVerifier-result path: ${{ github.workspace }}/build/reports/pluginVerifier - # Run Qodana inspections - - name: Qodana - Code Inspection - uses: JetBrains/qodana-action@v2022.3.4 - # Prepare plugin archive content for creating artifact - name: Prepare Plugin Artifact id: artifact @@ -134,39 +125,49 @@ jobs: 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 - releaseDraft: - name: Release Draft - if: github.event_name != 'pull_request' - needs: build - runs-on: ubuntu-latest - permissions: - contents: write + + testUI: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + runIde: | + export DISPLAY=:99.0 + Xvfb -ac :99 -screen 0 1920x1080x16 & + gradle runIdeForUiTests & + - os: windows-latest + runIde: start gradlew.bat runIdeForUiTests + - os: macos-latest + runIde: ./gradlew runIdeForUiTests & + if: ${{ inputs.ui-tests }} + steps: # Check out current repository - name: Fetch Sources uses: actions/checkout@v3 - # Remove old release drafts by using the curl request for the available releases with a draft flag - - name: Remove Old Release Drafts - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh api repos/{owner}/{repo}/releases \ - --jq '.[] | select(.draft == true) | .id' \ - | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} - - # Create a new release draft which is not publicly visible and requires manual acceptance - - name: Create Release Draft - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release create v${{ needs.build.outputs.version }} \ - --draft \ - --title "v${{ needs.build.outputs.version }}" \ - --notes "$(cat << 'EOM' - ${{ needs.build.outputs.changelog }} - EOM - )" + # Setup Java 11 environment for the next steps + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: zulu + java-version: 17 + + # Run IDEA prepared for UI testing + - name: Run IDE + run: ${{ matrix.runIde }} + + # Wait for IDEA to be started + - name: Health Check + uses: jtalk/url-health-check-action@v3 + with: + url: http://127.0.0.1:8082 + max-attempts: 15 + retry-delay: 30s + + # Run tests + - name: Tests + run: ./gradlew test From 2ff2d4c64ca2b1f9d8a5357fe64964448bc609ed Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 12 Apr 2024 14:25:57 +0200 Subject: [PATCH 2/5] Update qodana.yml --- qodana.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/qodana.yml b/qodana.yml index c09f8da..f1f7203 100644 --- a/qodana.yml +++ b/qodana.yml @@ -1,11 +1,8 @@ -# Qodana configuration: -# https://www.jetbrains.com/help/qodana/qodana-yaml.html +version: "1.0" + +projectJDK: "17" -version: 1.0 profile: name: qodana.recommended - projectJDK: 17 -exclude: - - name: All - paths: - - .qodana + +linter: jetbrains/qodana-jvm-community:latest From 33619b6b8bad3b3f1c2178c1257f0fbdb3fdc3f3 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 12 Apr 2024 14:40:20 +0200 Subject: [PATCH 3/5] Make build test a matrix --- .github/workflows/step_tests.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/step_tests.yml b/.github/workflows/step_tests.yml index 3c6866d..c59f051 100644 --- a/.github/workflows/step_tests.yml +++ b/.github/workflows/step_tests.yml @@ -23,9 +23,12 @@ jobs: build: name: Build runs-on: ubuntu-latest - outputs: - version: ${{ steps.properties.outputs.version }} - changelog: ${{ steps.properties.outputs.changelog }} + strategy: + fail-fast: false + matrix: + platform-version: [ "2023.1", "2023.2", "2023.3", "2024.1" ] + env: + ORG_GRADLE_PROJECT_platformVersion: ${{ matrix.platform-version }} steps: # Free GitHub Actions Environment Disk Space From 1262fc6b1aa4eee1a2c87f32de4592187c5377d2 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 12 Apr 2024 17:00:39 +0200 Subject: [PATCH 4/5] Separate build/test/verify steps More in line with current plugin template Also update github actions --- .github/workflows/release.yml | 10 +-- .github/workflows/step_draft.yml | 5 +- .github/workflows/step_tests.yml | 146 ++++++++++++++++--------------- 3 files changed, 78 insertions(+), 83 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1d3ff9e..cf01224 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,16 +17,10 @@ jobs: contents: write pull-requests: write steps: - - # Check out current repository - - name: Fetch Sources - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.event.release.tag_name }} - - # Setup Java 11 environment for the next steps - - name: Setup Java - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: zulu java-version: 17 diff --git a/.github/workflows/step_draft.yml b/.github/workflows/step_draft.yml index 5d65716..18419d8 100644 --- a/.github/workflows/step_draft.yml +++ b/.github/workflows/step_draft.yml @@ -13,10 +13,7 @@ jobs: # What to do with this workflow? runs-on: ubuntu-latest steps: - - # Check out current repository - - name: Fetch Sources - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Remove old release drafts by using the curl request for the available releases with a draft flag - name: Remove Old Release Drafts diff --git a/.github/workflows/step_tests.yml b/.github/workflows/step_tests.yml index c59f051..0da061d 100644 --- a/.github/workflows/step_tests.yml +++ b/.github/workflows/step_tests.yml @@ -19,9 +19,8 @@ jobs: # Run Gradle Wrapper Validation Action to verify the wrapper's checksum # Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks # Build plugin and provide the artifact for the next workflow jobs - # TODO: Separate build and and test steps build: - name: Build + name: ๐Ÿ› ๏ธ Build ${{ matrix.platform-version }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -30,48 +29,40 @@ jobs: env: ORG_GRADLE_PROJECT_platformVersion: ${{ matrix.platform-version }} steps: - - # Free GitHub Actions Environment Disk Space - - name: Maximize Build Space - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf /opt/ghc - - # Check out current repository - - name: Fetch Sources - uses: actions/checkout@v3 - - # Validate wrapper - - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v1.0.6 - - # Setup Java 17 environment for the next steps - - name: Setup Java - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + # TODO: Move this to a pre-commit check + - uses: gradle/wrapper-validation-action@v2 + - uses: actions/setup-java@v4 with: distribution: zulu java-version: 17 + # Build plugin + - name: Build plugin + run: ./gradlew buildPlugin - # Set environment variables - - name: Export Properties - id: properties - 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)" - - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "name=$NAME" >> $GITHUB_OUTPUT - echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT - - echo "changelog<> $GITHUB_OUTPUT - echo "$CHANGELOG" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + - uses: actions/upload-artifact@v4 + with: + name: build-artifact-${{ matrix.platform-version }} + path: ./build/distributions/* - ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier + test: + name: ๐Ÿงช Test ${{ matrix.platform-version }} + needs: [ build ] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform-version: [ "2023.1", "2023.2", "2023.3", "2024.1" ] + env: + ORG_GRADLE_PROJECT_platformVersion: ${{ matrix.platform-version }} + steps: + - uses: actions/checkout@v4 + # TODO: Move this to a pre-commit check + - uses: gradle/wrapper-validation-action@v2 + - uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 # Run tests - name: Run Tests @@ -80,9 +71,9 @@ jobs: # Collect Tests Result of failed tests - name: Collect Tests Result if: ${{ failure() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: tests-result + name: tests-result-${{ matrix.platform-version }} path: ${{ github.workspace }}/build/reports/tests # Upload Kover report to CodeCov @@ -91,9 +82,47 @@ jobs: with: files: ${{ github.workspace }}/build/reports/kover/xml/report.xml + verify: + name: ๐Ÿงช Verify ${{ matrix.platform-version }} + needs: [ build ] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform-version: [ "2023.1", "2023.2", "2023.3", "2024.1" ] + env: + ORG_GRADLE_PROJECT_platformVersion: ${{ matrix.platform-version }} + steps: + - uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + large-packages: false + + - uses: actions/checkout@v4 + # Set environment variables + - name: Export Properties + id: properties + shell: bash + run: | + PROPERTIES="$(./gradlew properties --console=plain -q)" + VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')" + CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)" + + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT + + echo "changelog<> $GITHUB_OUTPUT + echo "$CHANGELOG" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier + - uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 # Cache Plugin Verifier IDEs - name: Setup Plugin Verifier IDEs Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }} @@ -105,30 +134,11 @@ jobs: # Collect Plugin Verifier Result - name: Collect Plugin Verifier Result if: ${{ always() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: pluginVerifier-result + name: pluginVerifier-result-${{ matrix.platform-version }} path: ${{ github.workspace }}/build/reports/pluginVerifier - # Prepare plugin archive content for creating artifact - - name: Prepare Plugin Artifact - id: artifact - shell: bash - run: | - cd ${{ github.workspace }}/build/distributions - FILENAME=`ls *.zip` - unzip "$FILENAME" -d content - - echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT - - # Store already-built plugin as an artifact for downloading - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.artifact.outputs.filename }} - path: ./build/distributions/content/*/* - - testUI: runs-on: ${{ matrix.os }} strategy: @@ -147,14 +157,8 @@ jobs: if: ${{ inputs.ui-tests }} steps: - - # Check out current repository - - name: Fetch Sources - uses: actions/checkout@v3 - - # Setup Java 11 environment for the next steps - - name: Setup Java - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: zulu java-version: 17 From 0a4d778f1459c3218d19bcd608c234988146bb12 Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Fri, 12 Apr 2024 17:50:49 +0200 Subject: [PATCH 5/5] Remove Qodana plugin --- .run/Run Qodana.run.xml | 26 -------------------------- build.gradle.kts | 10 ---------- 2 files changed, 36 deletions(-) delete mode 100644 .run/Run Qodana.run.xml diff --git a/.run/Run Qodana.run.xml b/.run/Run Qodana.run.xml deleted file mode 100644 index 9603583..0000000 --- a/.run/Run Qodana.run.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - true - true - false - - - \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 5a7f688..0dacfb2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,8 +12,6 @@ plugins { id("org.jetbrains.intellij") version "1.16.1" // Gradle Changelog Plugin id("org.jetbrains.changelog") version "2.0.0" - // Gradle Qodana Plugin - id("org.jetbrains.qodana") version "0.1.13" } group = properties("pluginGroup").get() @@ -50,14 +48,6 @@ changelog { repositoryUrl.set(properties("pluginRepositoryUrl")) } -// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin -qodana { - cachePath.set(provider { file(".qodana").canonicalPath }) - reportPath.set(provider { file("build/reports/inspections").canonicalPath }) - saveReport.set(true) - showReport.set(environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false)) -} - tasks { wrapper { gradleVersion = properties("gradleVersion").get()