Skip to content

Commit

Permalink
Improve CONTRIBUTING.md docs and add option to use :runIde with custo…
Browse files Browse the repository at this point in the history
…m IJ version (#223)

## Test plan

Not needed as this is only impacting dev docs and workflow.

Changes to `build.gradle.kts` I verified manually and for the standard
workflow are also verified each time by CI run.
  • Loading branch information
pkukielka authored Dec 21, 2023
1 parent 1e5430a commit 1b12a98
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 16 deletions.
32 changes: 25 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,31 @@ using the `jetbrains-ide` & `team/integrations` labels.
- Install Java 11 via SDKMAN! https://sdkman.io. Once you have SDKMAN! installed, run `sdk use java 11.0.15-tem`.
Confirm that you have Java 11 installed with `java -version`.
- Clone `https://github.com/sourcegraph/sourcegraph`
- Clone `https://github.com/sourcegraph/cody` in a sibling directory. The toplevel directories for
sourcegraph/sourcegraph and sourcegraph/cody must be next to each other.
- Clone `https://github.com/sourcegraph/cody` in a sibling directory.
The toplevel directories for sourcegraph/sourcegraph and sourcegraph/cody must be next to each other.
- Install the following two IntelliJ plugins to format Java and Kotlin on file save
- https://plugins.jetbrains.com/plugin/8527-google-java-format
- https://plugins.jetbrains.com/plugin/14912-ktfmt

Few tips and tricks regarding versioning of the tooling:

- If you are using macOS make sure to install `pnpm` version `8.6.7` using `corepack` and
not `brew`: `corepack install --global [email protected]`.
Currently `brew` does not allow you to pick custom `pnpm` version which is
causing [various issues](https://github.com/pnpm/pnpm/issues/6903).
- Use `node` version `18` (newer versions causes hard to diagnose errors with `ERR_INVALID_THIS`).
- If you changed `pnpm` or `node` version after running gradle you need to kill gradle daemon with `./gradlew --stop`.
Otherwise you won't see effects of your changes.
- Running `:runIde PplatformRuntimeVersion=X.Y` for the first time might fail due to missing IntelliJ installation. You
can fix it by running `:runIde PplatformVersion=X.Y` once - even if compilation fails it fixes your caches.

| What | Command |
|------------------------------------------------------------------|--------------------------------------------------------------------------|
| Run the plugin locally | `./gradlew :runIDE` |
| Run the plugin locally with fresh build of Cody | `./gradlew -PforceAgentBuild=true :runIDE` |
| Run the plugin locally with fresh build of a local clone of Cody | `CODY_DIR=<path_to_cody> ./gradlew -PforceAgentBuild=true :runIDE` |
| Run the plugin locally with fresh build of Code Search assets | `./gradlew -PforceCodeSearchBuild=true :runIDE` |
| Run the plugin locally with different IntelliJ version | `./gradlew -PplatformRuntimeVersion=2023.1 :runIDE` |
| Build Code Search assets (separate terminal) | `pnpm build` |
| Continuously re-build Code Search assets (separate terminal) | `pnpm watch` |
| Code Search "Find with Sourcegraph" window | `pnpm standalone && open http://localhost:3000/` |
Expand Down Expand Up @@ -71,7 +84,7 @@ We plan to make releases every other Monday. Nightly version can be released as
### 1. Push a Git Tag
First, choose whether to publish a new version of nightly or stable.
First, choose whether to publish a new version of nightly or stable.
Use the following command for a **nightly** release:
Expand All @@ -96,15 +109,20 @@ Wait for the `Release to Marketplace` GitHub workflow to complete.

For every stable release, create a GitHub release summarizing the changes.

Visit [releases page](https://github.com/sourcegraph/jetbrains/releases) and click `Draft a new release`, choose your tag and use `Generate release notes`. Release notes should appear automatically. Be aware that the automatic release are based on the history of commits, so sometimes the titles are not properly formatted, capitalized or grammatically correct. **This may sometimes require manual tweaks.**
Visit [releases page](https://github.com/sourcegraph/jetbrains/releases) and click `Draft a new release`, choose your
tag and use `Generate release notes`. Release notes should appear automatically. Be aware that the automatic release are
based on the history of commits, so sometimes the titles are not properly formatted, capitalized or grammatically
correct. **This may sometimes require manual tweaks.**

Try to maintain a similar style to that of the previous releases, similar to [our first release](https://github.com/sourcegraph/jetbrains/releases/tag/v5.2.2301).
Try to maintain a similar style to that of the previous releases, similar
to [our first release](https://github.com/sourcegraph/jetbrains/releases/tag/v5.2.2301).

It's also optional create GitHub releases for nightly builds where it makes sense.

### 3. Announce the New Release on our internal Slack channel

It is mandatory to post about both stable and nightly releases on our internal `wg-cody-jetbrains` Slack channel. You can refer to past posts in the channel's history for examples.
It is mandatory to post about both stable and nightly releases on our internal `wg-cody-jetbrains` Slack channel. You
can refer to past posts in the channel's history for examples.

## Enabling web view debugging

Expand All @@ -121,4 +139,4 @@ built into the JetBrains platform. To enable debugging tools for this view, plea
8. Switch to a browser window, go to [`localhost:9222`](http://localhost:9222), and select the Sourcegraph window.
Sometimes it needs some back and forth to focus the external browser with the JCEF component also focused—you may
need to move the popup out of the way and click the external browser rather than using <kbd>Alt+Tab</kbd> / <kbd>
⌘Tab</kbd>.
⌘Tab</kbd>.
27 changes: 18 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import com.jetbrains.plugin.structure.base.utils.isDirectory
import java.lang.IllegalArgumentException
import java.net.URL
import java.nio.file.FileSystems
import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.PathMatcher
import java.nio.file.Paths
import java.nio.file.SimpleFileVisitor
import java.nio.file.StandardCopyOption
import java.nio.file.*
import java.nio.file.attribute.BasicFileAttributes
import java.util.EnumSet
import java.util.*
import java.util.jar.JarFile
import java.util.zip.ZipFile
import org.jetbrains.changelog.markdownToHTML
Expand Down Expand Up @@ -260,6 +253,13 @@ tasks {
return buildCodyDir
}

fun getIdeaInstallDir(ideaVersion: String): File? {
val gradleHome = project.gradle.gradleUserHomeDir
val cacheDir = File(gradleHome, "caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC")
val ideaDir = File(cacheDir, ideaVersion)
return ideaDir.walk().find { it.name == "ideaIC-$ideaVersion" }
}

register("buildCodeSearch") { buildCodeSearch() }
register("buildCody") { buildCody() }

Expand Down Expand Up @@ -337,6 +337,15 @@ tasks {
systemProperty(
"cody.autocomplete.enableFormatting",
project.property("cody.autocomplete.enableFormatting") ?: "true")

val platformRuntimeVersion = project.findProperty("platformRuntimeVersion")
if (platformRuntimeVersion != null) {
val ideaInstallDir =
getIdeaInstallDir(platformRuntimeVersion.toString())
?: throw GradleException(
"Could not find IntelliJ install for $platformRuntimeVersion")
ideDir.set(ideaInstallDir)
}
}

runPluginVerifier {
Expand Down

0 comments on commit 1b12a98

Please sign in to comment.