Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

Commit 3eebe54

Browse files
author
Philipp Spiess
authored
Upgrade IntelliJ platform template (#30)
* Upgrade Gradle wrapper to 7.0 * Upgrade config file and IntelliJ version * Add workflow to run UI tests * Run UI Tests on every push * Fix tests * Remove wait * Run tests in debug mode * Add build workflow * Move build.gradle to Kotlin * Clean up build.gradle.kts * Ensure we start the build with the proper JVM version * Migrate changelog format to use org.jetbrains.changelog * Update workflows and bring back UI test server * Cleanup build.yml workflow * Retry UI tests to see if they are still flaky #1 * Retry UI tests to see if they are still flaky #2 * Revert min version changes
1 parent 6a4b5c2 commit 3eebe54

File tree

15 files changed

+722
-292
lines changed

15 files changed

+722
-292
lines changed

.github/workflows/build.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
2+
# - validate Gradle Wrapper,
3+
# - run 'test' and 'verifyPlugin' tasks,
4+
# - run Qodana inspections,
5+
# - run 'buildPlugin' task and prepare artifact for the further tests,
6+
# - run 'runPluginVerifier' task,
7+
# - create a draft release.
8+
#
9+
# Workflow is triggered on push and pull_request events.
10+
#
11+
# GitHub Actions reference: https://help.github.com/en/actions
12+
13+
name: Build
14+
on:
15+
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
16+
push:
17+
branches: [main]
18+
# Trigger the workflow on any pull request
19+
pull_request:
20+
21+
jobs:
22+
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
23+
# Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
24+
# Build plugin and provide the artifact for the next workflow jobs
25+
build:
26+
name: Build
27+
runs-on: ubuntu-latest
28+
outputs:
29+
version: ${{ steps.properties.outputs.version }}
30+
changelog: ${{ steps.properties.outputs.changelog }}
31+
steps:
32+
# Check out current repository
33+
- name: Fetch Sources
34+
uses: actions/[email protected]
35+
36+
# Validate wrapper
37+
- name: Gradle Wrapper Validation
38+
uses: gradle/[email protected]
39+
40+
# Setup Java 11 environment for the next steps
41+
- name: Setup Java
42+
uses: actions/setup-java@v2
43+
with:
44+
distribution: zulu
45+
java-version: 11
46+
cache: gradle
47+
48+
# Set environment variables
49+
- name: Export Properties
50+
id: properties
51+
shell: bash
52+
run: |
53+
PROPERTIES="$(./gradlew properties --console=plain -q)"
54+
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
55+
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
56+
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
57+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
58+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
59+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
60+
61+
echo "::set-output name=version::$VERSION"
62+
echo "::set-output name=name::$NAME"
63+
echo "::set-output name=changelog::$CHANGELOG"
64+
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
65+
66+
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
67+
68+
# Run tests
69+
- name: Run Tests
70+
run: ./gradlew test
71+
72+
# Collect Tests Result of failed tests
73+
- name: Collect Tests Result
74+
if: ${{ failure() }}
75+
uses: actions/upload-artifact@v2
76+
with:
77+
name: tests-result
78+
path: ${{ github.workspace }}/build/reports/tests
79+
80+
# Cache Plugin Verifier IDEs
81+
- name: Setup Plugin Verifier IDEs Cache
82+
uses: actions/[email protected]
83+
with:
84+
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
85+
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
86+
87+
# Run Verify Plugin task and IntelliJ Plugin Verifier tool
88+
- name: Run Plugin Verification tasks
89+
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
90+
91+
# Collect Plugin Verifier Result
92+
- name: Collect Plugin Verifier Result
93+
if: ${{ always() }}
94+
uses: actions/upload-artifact@v2
95+
with:
96+
name: pluginVerifier-result
97+
path: ${{ github.workspace }}/build/reports/pluginVerifier
98+
99+
# Run Qodana inspections
100+
- name: Qodana - Code Inspection
101+
uses: JetBrains/[email protected]
102+
103+
# Prepare plugin archive content for creating artifact
104+
- name: Prepare Plugin Artifact
105+
id: artifact
106+
shell: bash
107+
run: |
108+
cd ${{ github.workspace }}/build/distributions
109+
FILENAME=`ls *.zip`
110+
unzip "$FILENAME" -d content
111+
112+
echo "::set-output name=filename::${FILENAME:0:-4}"
113+
114+
# Store already-built plugin as an artifact for downloading
115+
- name: Upload artifact
116+
uses: actions/[email protected]
117+
with:
118+
name: ${{ steps.artifact.outputs.filename }}
119+
path: ./build/distributions/content/*/*
120+
121+
# Prepare a draft release for GitHub Releases page for the manual verification
122+
# If accepted and published, release workflow would be triggered
123+
releaseDraft:
124+
name: Release Draft
125+
if: github.event_name != 'pull_request'
126+
needs: build
127+
runs-on: ubuntu-latest
128+
steps:
129+
# Check out current repository
130+
- name: Fetch Sources
131+
uses: actions/[email protected]
132+
133+
# Remove old release drafts by using the curl request for the available releases with draft flag
134+
- name: Remove Old Release Drafts
135+
env:
136+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
137+
run: |
138+
gh api repos/{owner}/{repo}/releases \
139+
--jq '.[] | select(.draft == true) | .id' \
140+
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
141+
142+
# Create new release draft - which is not publicly visible and requires manual acceptance
143+
- name: Create Release Draft
144+
env:
145+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
146+
run: |
147+
gh release create v${{ needs.build.outputs.version }} \
148+
--draft \
149+
--title "v${{ needs.build.outputs.version }}" \
150+
--notes "$(cat << 'EOM'
151+
${{ needs.build.outputs.changelog }}
152+
EOM
153+
)"

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# GitHub Actions Workflow created for handling the release process based on the draft release prepared
2+
# with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided.
3+
4+
name: Release
5+
on:
6+
release:
7+
types: [prereleased, released]
8+
9+
jobs:
10+
11+
# Prepare and publish the plugin to the Marketplace repository
12+
release:
13+
name: Publish Plugin
14+
runs-on: ubuntu-latest
15+
steps:
16+
17+
# Check out current repository
18+
- name: Fetch Sources
19+
uses: actions/[email protected]
20+
with:
21+
ref: ${{ github.event.release.tag_name }}
22+
23+
# Setup Java 11 environment for the next steps
24+
- name: Setup Java
25+
uses: actions/setup-java@v2
26+
with:
27+
distribution: zulu
28+
java-version: 11
29+
cache: gradle
30+
31+
# Set environment variables
32+
- name: Export Properties
33+
id: properties
34+
shell: bash
35+
run: |
36+
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
37+
${{ github.event.release.body }}
38+
EOM
39+
)"
40+
41+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
42+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
43+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
44+
45+
echo "::set-output name=changelog::$CHANGELOG"
46+
47+
# Update Unreleased section with the current release note
48+
- name: Patch Changelog
49+
if: ${{ steps.properties.outputs.changelog != '' }}
50+
env:
51+
CHANGELOG: ${{ steps.properties.outputs.changelog }}
52+
run: |
53+
./gradlew patchChangelog --release-note="$CHANGELOG"
54+
55+
# Publish the plugin to the Marketplace
56+
- name: Publish Plugin
57+
env:
58+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
59+
run: ./gradlew publishPlugin
60+
61+
# Upload artifact as a release asset
62+
- name: Upload Release Asset
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
66+
67+
# Create pull request
68+
- name: Create Pull Request
69+
if: ${{ steps.properties.outputs.changelog != '' }}
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
run: |
73+
VERSION="${{ github.event.release.tag_name }}"
74+
BRANCH="changelog-update-$VERSION"
75+
76+
git config user.email "[email protected]"
77+
git config user.name "GitHub Action"
78+
79+
git checkout -b $BRANCH
80+
git commit -am "Changelog update - $VERSION"
81+
git push --set-upstream origin $BRANCH
82+
83+
gh pr create \
84+
--title "Changelog update - \`$VERSION\`" \
85+
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
86+
--base main \
87+
--head $BRANCH

.github/workflows/run-ui-tests.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# GitHub Actions Workflow for launching UI tests on Linux, Windows, and Mac in the following steps:
2+
# - prepare and launch IDE with your plugin and robot-server plugin, which is needed to interact with UI
3+
# - wait for IDE to start
4+
# - run UI tests with separate Gradle task
5+
#
6+
# Please check https://github.com/JetBrains/intellij-ui-test-robot for information about UI tests with IntelliJ Platform
7+
#
8+
# Workflow is triggered manually.
9+
10+
name: Run UI Tests
11+
on:
12+
workflow_dispatch:
13+
pull_request:
14+
15+
jobs:
16+
17+
testUI:
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- os: ubuntu-latest
24+
runIde: |
25+
export DISPLAY=:99.0
26+
Xvfb -ac :99 -screen 0 1920x1080x16 &
27+
gradle runIdeForUiTests &
28+
- os: windows-latest
29+
runIde: start gradlew.bat runIdeForUiTests
30+
- os: macos-latest
31+
runIde: ./gradlew runIdeForUiTests &
32+
33+
steps:
34+
35+
# Check out current repository
36+
- name: Fetch Sources
37+
uses: actions/[email protected]
38+
39+
# Setup Java 11 environment for the next steps
40+
- name: Setup Java
41+
uses: actions/setup-java@v2
42+
with:
43+
distribution: zulu
44+
java-version: 11
45+
cache: gradle
46+
47+
# Run IDEA prepared for UI testing
48+
- name: Run IDE
49+
run: ${{ matrix.runIde }}
50+
51+
# Wait for IDEA to be started
52+
- name: Health Check
53+
uses: jtalk/url-health-check-action@v2
54+
with:
55+
url: http://127.0.0.1:8082
56+
max-attempts: 15
57+
retry-delay: 30s
58+
59+
# Run tests
60+
- name: Tests
61+
run: ./gradlew test

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Sourcegraph Changelog
2+
3+
## [Unreleased]
4+
5+
- Upgrade JetBrains IntelliJ shell to 1.3.1 and modernize the build and release pipeline.
6+
7+
## [1.2.2] - Minor bug fixes
8+
9+
- It is now possible to configure the plugin per-repository using a `.idea/sourcegraph.xml` file. See the README for details.
10+
- Special thanks: @oliviernotteghem for contributing the new features in this release!
11+
- Fixed bugs where Open in Sourcegraph from the git menu does not work for repos with ssh url as their remote url
12+
13+
## [1.2.1] - Open Revision in Sourcegraph
14+
15+
- Added "Open In Sourcegraph" action to VCS History and Git Log to open a revision in the Sourcegraph diff view.
16+
- Added "defaultBranch" configuration option that allows opening files in a specific branch on Sourcegraph.
17+
- Added "remoteUrlReplacements" configuration option that allow users to replace specified values in the remote url with new strings.
18+
19+
## [1.2.0] - Copy link to file, search in repository, per-repository configuration, bug fixes & more
20+
21+
- The search menu entry is now no longer present when no text has been selected.
22+
- When on a branch that does not exist remotely, `master` will now be used instead.
23+
- Menu entries (Open file, etc.) are now under a Sourcegraph sub-menu.
24+
- Added a "Copy link to file" action (alt+c / opt+c).
25+
- Added a "Search in repository" action (alt+r / opt+r).
26+
- It is now possible to configure the plugin per-repository using a `.idea/sourcegraph.xml` file. See the README for details.
27+
- Special thanks: @oliviernotteghem for contributing the new features in this release!
28+
29+
## [1.1.2] - Minor bug fixes around searching.
30+
31+
- Fixed an error that occurred when trying to search with no selection.
32+
- The git remote used for repository detection is now `sourcegraph` and then `origin`, instead of the previously poor choice of just the first git remote.
33+
34+
## [1.1.1] - Fixed search shortcut
35+
36+
- Updated the search URL to reflect a recent Sourcegraph.com change.
37+
38+
## [1.1.0] - Configurable Sourcegraph URL
39+
40+
- Added support for using the plugin with on-premises Sourcegraph instances.
41+
42+
## [1.0.0] - Initial Release
43+
44+
- Basic Open File & Search functionality.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
<!-- Plugin description -->
12
# Sourcegraph for JetBrains IDEs [![JetBrains Plugin](https://img.shields.io/badge/JetBrains-Sourcegraph-green.svg)](https://plugins.jetbrains.com/plugin/9682-sourcegraph)
23

34
- Search snippets of code on Sourcegraph.
45
- Copy and share a link to code on Sourcegraph.
56
- Quickly go from files in your editor to Sourcegraph.
7+
<!-- Plugin description end -->
68

79
The plugin works with all JetBrains IDEs including:
810

build.gradle

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)