Skip to content

Commit

Permalink
IJMP-1587 Accumulated work for the issue (together with HHaliuk)
Browse files Browse the repository at this point in the history
Signed-off-by: Uladzislau <leksilonchikk@gmail.com>
  • Loading branch information
KUGDev committed Apr 3, 2024
1 parent f5bd87d commit 76b8e45
Show file tree
Hide file tree
Showing 11 changed files with 551 additions and 235 deletions.
22 changes: 22 additions & 0 deletions .github/actions/sonar/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Setup action"
description: "Runs sonar scans"


runs:
using: composite
steps:
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/caches
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Code coverage and publish results
shell: bash
run: >
./gradlew --info sonarqube
-Dorg.gradle.jvmargs="-XX:MaxMetaspaceSize=512m"
-Dresults="build/reports/tests/test,build/test-results/test,build/reports/jacoco/test/html"
-Psonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_TOKEN
-Dsonar.coverage.jacoco.xmlReportPaths="build/reports/jacoco.xml"
187 changes: 187 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Build + Test + Verify + Sonar

on: [push, workflow_dispatch]

permissions:
contents: read

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
outputs:
pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }}
steps:

- name: Checkout the plugin GitHub repository
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true

- name: Check repository content
shell: bash
run: pwd && ls -la

- name: Fetch Gradle properties
id: properties
env:
AUTO_SNAPSHOT_VERSION: false
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
# prepare list of IDEs to use by plugin verifier:
./gradlew listProductsReleases
- name: Build plugin
shell: bash
run: ./gradlew buildPlugin

- 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
echo "zip artifact name:"
echo "$FILENAME"
- name: Publish built plugin to artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact.outputs.filename }}
path: ./build/distributions/content/*/*

test:
needs: [build]
runs-on: ubuntu-latest
steps:

- name: Checkout the plugin GitHub repository
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true

- name: Run tests
shell: bash
run: ./gradlew test

- name: Publish tests result to artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: tests-report
path: ${{ github.workspace }}/build/reports/tests

- name: Publish code coverage report to artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: ${{ github.workspace }}/build/reports/kover/html

verify:
if: ${{ startsWith(github.ref, 'release/') }}
needs: [build]
runs-on: ubuntu-latest
steps:

- name: Maximize Build Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
large-packages: false

- name: Checkout the plugin GitHub repository
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true

- name: Setup Plugin Verifier IDEs Cache
uses: actions/cache@v4
with:
path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}

- name: Verify plugin against IntelliJ IDEA IDE's
continue-on-error: true
shell: bash
run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}

- name: Collect Plugin Verifier Result
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: plugin-verifier-report
path: ${{ github.workspace }}/build/reports/pluginVerifier

sonar:
needs: [test]
runs-on: ubuntu-latest
steps:

- name: Checkout the plugin GitHub repository
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true

- name: SonarCloud scans
continue-on-error: true
uses: ./.github/actions/sonar
env:
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
127 changes: 127 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time.
# After the build stage is finished, it is ready to be published to the respective public repositories
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Release

on:
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:

- name: Checkout the plugin GitHub repository
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true

- name: Fetch Gradle properties
id: properties
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
PLUGIN_VERSION_FULL="$(echo "$PROPERTIES" | grep "^pluginVersion:" | cut -f2- -d ' ')"
PLUGIN_VERSION_SEMVER="$(echo "$PLUGIN_VERSION_FULL" | grep -Po '\d{1,}\.\d{1,}\.\d{1,}')"
CURR_COMMIT="$(git rev-parse HEAD)"
echo "pluginVersionFull: $PLUGIN_VERSION_FULL"
echo "pluginVersionSemVer: $PLUGIN_VERSION_SEMVER"
echo "currCommit: $CURR_COMMIT"
echo "pluginVersionFull=$PLUGIN_VERSION_FULL" >> $GITHUB_OUTPUT
echo "pluginVersionSemVer=$PLUGIN_VERSION_SEMVER" >> $GITHUB_OUTPUT
echo "currCommit=$CURR_COMMIT" >> $GITHUB_OUTPUT
- name: Publish Plugin
env:
INTELLIJ_SIGNING_PUBLISH_TOKEN: ${{ secrets.INTELLIJ_SIGNING_PUBLISH_TOKEN }}
INTELLIJ_SIGNING_CERTIFICATE_CHAIN: ${{ secrets.INTELLIJ_SIGNING_CERTIFICATE_CHAIN }}
INTELLIJ_SIGNING_PRIVATE_KEY: ${{ secrets.INTELLIJ_SIGNING_PRIVATE_KEY }}
INTELLIJ_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.INTELLIJ_SIGNING_PRIVATE_KEY_PASSWORD }}
run: ./gradlew publishPlugin

- name: Prepare release notes
id: release_notes
shell: bash
run: |
CHANGELOG="$(./gradlew getChangelog -q)"
echo 'version_release_notes<<EOF' >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo "Release notes to be added:"
echo "$CHANGELOG"
- name: Create new tag and release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag ${{ steps.properties.outputs.pluginVersionFull }}
git push origin ${{ steps.properties.outputs.pluginVersionFull }}
gh release create ${{ steps.properties.outputs.pluginVersionFull }} --title ${{ steps.properties.outputs.pluginVersionFull }} --target ${{ steps.properties.outputs.currCommit }} -F- <<EOF
${{ steps.release_notes.outputs.version_release_notes }}
EOF
- name: Upload Release Built Artifact
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ steps.properties.outputs.pluginVersionFull }} ./build/distributions/*

- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.properties.outputs.pluginVersionFull }}"
BRANCH="release-changelog-update-$VERSION"
LABEL="release-closer"
git config user.email "action@github.com"
git config user.name "GitHub Action"
git checkout -b $BRANCH
git commit -am ":moyai: ${VERSION}" -m "[skip ci]"
git push --set-upstream origin $BRANCH
# gh label create "$LABEL" \
# --color FFEF00 \
# --description "Pull requests with release changelog update" \
# || true
gh pr create \
--title ":moyai: \`$VERSION\`" \
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
--base "release/$VERSION" \
--label "$LABEL" \
--head $BRANCH
- name: Close Milestone
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/{owner}/{repo}/milestones \
--jq '.[] | select(.title == "${{ steps.properties.outputs.pluginVersionSemVer }}") | .number' \
| xargs -I '{}' gh api -X PATCH repos/{owner}/{repo}/milestones/{} -F state='closed'
12 changes: 3 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
.gradle
.idea
gradle/*
gradle/wrapper/*
!gradle/
!gradle/wrapper/
!gradle/wrapper/gradle-wrapper.properties
build

libs
/build

verifier-all.jar

# Windows thumbnail cache files
Expand All @@ -34,4 +28,4 @@ bin

# Fleet files
.fleet
.editorconfig
.editorconfig
Loading

0 comments on commit 76b8e45

Please sign in to comment.