Skip to content

Commit

Permalink
Implement multiple IDE versions and EAP testing. Fixes #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
thepieterdc committed Feb 29, 2020
1 parent 15b718d commit 22e0e36
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 23 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = false
indent_style = space
indent_size = 4
max_line_length = 80

[{*.json, *.yml}]
indent_style = space
indent_size = 2

[*.java]
indent_style = tab
tab_width = 4

[*.xml]
indent_size = 2

[plugin.xml]
max_line_length = off
109 changes: 109 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Created by .ignore support plugin (hsz.mobi)
### Gradle template
.gradle
/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Linux template
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### Java template
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ FROM gradle:jdk11
# Download the plugin verifier.
RUN curl -L --output /verifier.jar https://dl.bintray.com/jetbrains/intellij-plugin-service/org/jetbrains/intellij/plugins/verifier-cli/1.222/verifier-cli-1.222-all.jar

# Copy and compile the sources of the parser into a jar.
RUN mkdir /tmp/build-parser
COPY src/ /tmp/build-parser
RUN find /tmp/build-parser -name *.java | xargs javac -classpath /tmp/build-parser/build -d /tmp/build-parser/build -sourcepath /tmp/build-parser
RUN jar -cvf /parser.jar -C /tmp/build-parser/build .

# Copy the initialisation script.
COPY docker-entrypoint.sh /usr/bin/entrypoint.sh
RUN chmod +x /usr/bin/entrypoint.sh
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ Use GitHub Actions to verify the compatibility of your IntelliJ plugin against a

## Usage

Simply add the action to your workflow-file and specify the path to your plugin, as well as the desired version of IntelliJ IDEA to test, as shown in hte example:
Simply add the action to your workflow-file and specify the path to your plugin, as well as the desired versions of IntelliJ IDEA to test, as shown in the example:

```yaml
steps:
- uses: actions/checkout@master
- uses: thepieterdc/intellij-plugin-verifier-action@v1.0.0
- uses: thepieterdc/intellij-plugin-verifier-action@v1.1.0
with:
plugin: '/path/to/plugin.zip'
version: '181.5684.4'
versions: |
181.5684.4
2019.3.3
```
## Arguments
Expand All @@ -24,10 +26,10 @@ This action currently requires 2 arguments:
| Input | Description | Usage |
| :---: | :---: | :---: |
| `plugin` | The path to the `zip`-distribution of the plugin, generated by executing `./gradlew buildPlugin` | *Required* |
| `version` | Release of IntelliJ that should be used to validate against | *Required* |
| `versions` | Releases of IntelliJ that should be used to validate against, formatted as a multi-line string as shown in the example. | *Required* |

## Example
The following example builds a plugin using Gradle, and validates it against IDEA build `193.5662.53`.
The following example builds a plugin using Gradle, and validates it against IDEA builds `181.5684.4`, `2019.3.3` and the latest EAP version.

```yaml
name: Plugin compatibility
Expand All @@ -43,10 +45,13 @@ jobs:
java-version: 11.x.x
- name: Build the plugin using Gradle
run: ./gradlew buildPlugin
- uses: thepieterdc/intellij-plugin-verifier-action@v1.0.0
- uses: thepieterdc/intellij-plugin-verifier-action@v1.1.0
with:
plugin: '/home/runner/work/demo-plugin/demo-plugin/build/distributions/demo-plugin-1.0.0-SNAPSHOT.zip'
version: '193.5662.53'
versions: |
181.5684.4
2019.3.3
LATEST-EAP-SNAPSHOT
```
## Contributing

Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ inputs:
plugin:
description: 'Path to the plugin distribution zip file'
required: true
version:
description: 'The version of IntelliJ that should be validated against'
versions:
description: 'The versions of IntelliJ that should be validated against'
required: true
branding:
color: 'green'
Expand All @@ -16,4 +16,4 @@ runs:
image: 'Dockerfile'
args:
- ${{ inputs.plugin }}
- ${{ inputs.version }}
- ${{ inputs.versions }}
54 changes: 41 additions & 13 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,49 @@ set -eu
# Create a directory to store the IDEs in.
mkdir -p /ides

# Download the required IntelliJ version.
curl -L --output "idea-$INPUT_VERSION.zip" "https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIU/$INPUT_VERSION/ideaIU-$INPUT_VERSION.zip"
# Set the correct JAVA_HOME path in case this is overwritten by a setup-java
# action.
JAVA_HOME="/opt/java/openjdk"

# Extract the zip.
unzip -d "/ides/$INPUT_VERSION" "idea-$INPUT_VERSION.zip"
# Create an empty file to write the versions to. This is a small hack since
# appending to a string is not possible in sh pipes.
directories="/tmp/directories.txt"
echo "" > $directories

# Set the correct JAVA_HOME path in case this is overwritten by a setup-java action.
JAVA_HOME="/opt/java/openjdk"
# Parse the versions array into a list of download links.
java -cp "/parser.jar" parser.Main | while read -r line; do
# Find the name of the zip file.
dir=$(echo "$line" | egrep -o "(ideaIU-.*)")
dir=$(echo "${dir%.zip}")
zipfile=$(echo "$dir.zip")

# Execute the verifier.
echo "Running verification..."
java -jar /verifier.jar check-plugin "$INPUT_PLUGIN" "/ides/$INPUT_VERSION" 2>&1 > "log-$INPUT_VERSION.txt"
# Write the name of the directory to the file
sed -i "$ s+$+/ides/$dir +g" $directories

# Output the log
cat "log-$INPUT_VERSION.txt"
# Download the required IntelliJ version.
curl -L --output "$zipfile" "$line"

# Validate the log
egrep "^Plugin (.*) against .*: Compatible$" "log-$INPUT_VERSION.txt"
# Extract the zip.
unzip -d "/ides/$dir" "$zipfile"
done

# Reopen the created file to get the list of directories as a space-separated
# string.
ides=$(cat $directories)

# Execute the verifier.
echo "Running verification..."
verification_log="/tmp/verification.log"
java -jar /verifier.jar check-plugin "$INPUT_PLUGIN" $ides 2>&1 > "$verification_log"

# Output the log.
cat "$verification_log"

## Validate the log
if egrep -q "^Plugin (.*) against .*: .* compatibility problems?$" "$verification_log"; then
# An error has occurred.
exit 1
else
# Everything's fine.
exit 0
fi
70 changes: 70 additions & 0 deletions src/parser/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2019-2020. All rights reserved.
*
* @author Pieter De Clercq
*
* https://github.com/thepieterdc/intellij-plugin-verifier-action/
*/

package parser;

import java.util.Arrays;

/**
* Main entry point.
*/
public class Main {
/**
* Name of the environment variable that contains the versions.
*/
private static final String ARG_VERSIONS = "INPUT_VERSIONS";

/**
* Gets the release type.
*
* @param version the version string
* @return the release type
*/
private static String getReleaseType(final String version) {
if (version.endsWith("-EAP-SNAPSHOT")
|| version.endsWith("-EAP-CANDIDATE-SNAPSHOT")
|| version.endsWith("-CUSTOM-SNAPSHOT")) {
return "snapshots";
}
if (version.endsWith("-SNAPSHOT")) {
return "nightly";
}
return "releases";
}

/**
* Gets the url to download the given version.
*
* @param version the version to parse
* @return the url
*/
private static String getUrl(final String version) {
// Get the release type.
final String releaseType = getReleaseType(version);

// Construct the url.
return String.format("https://www.jetbrains.com/intellij-repository/%s/com/jetbrains/intellij/idea/ideaIU/%s/ideaIU-%s.zip",
releaseType,
version,
version
);
}

/**
* Main method.
*
* @param args unused
*/
public static void main(String[] args) {
// Get the versions to test.
final String[] versions = System.getenv(ARG_VERSIONS).split("\n");

// Parse every version and print the download paths.
Arrays.stream(versions).map(Main::getUrl).forEach(System.out::println);
}
}

0 comments on commit 22e0e36

Please sign in to comment.