Skip to content

Commit

Permalink
tests (#1501)
Browse files Browse the repository at this point in the history
* 👷 CI for jetbrains

* default working dir

* changelog

* build binaries

* binary testing setup

* idesettings

* core binary testing

* run binary tests in ci

* remove unused targets

* needs build

* console.log bin contents

* fix ci

* fix win32 binary download

* test

* no linux arm64

* macos latest

* macos-12

* binary permissions

* upload logs

* fix

* upload full folder as binary artifact

* test

* test macos only

* set full execute permissions

* copy sqlite binary

* cd

* it worked!

* build again in test job

* debug

* remove timeout

* info

* log

* log2

* more logs

* catch

* fewer logs

* test all platforms

* test downloaded artifact

* needs build

* updates

* build

* false

* release

* add tag and upload binaryes

* change tag name

* proper artifact upload

* jest updates

* ✅ generate a few unit tests with Continue

* fix imports related to IdeSettings

* run tsc on PRs

* remove shareSession command (unused)

* update release process

* update plugin version

* don't show ghost text when jetbrains completion visible

* run jetbrains ci in main
  • Loading branch information
sestinj authored Jun 21, 2024
1 parent 2ed4ff6 commit 20bf1bd
Show file tree
Hide file tree
Showing 58 changed files with 6,930 additions and 1,544 deletions.
448 changes: 448 additions & 0 deletions .github/workflows/jetbrains-build.yaml

Large diffs are not rendered by default.

142 changes: 142 additions & 0 deletions .github/workflows/jetbrains-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# GitHub Actions Workflow created for handling the release process based on the draft release prepared with the Build workflow.
# Running the publishPlugin task requires all following secrets to be provided: PUBLISH_TOKEN, PRIVATE_KEY, PRIVATE_KEY_PASSWORD, CERTIFICATE_CHAIN.
# See https://plugins.jetbrains.com/docs/intellij/plugin-signing.html for more information.

name: Release
on:
release:
types: [prereleased, released]

defaults:
run:
working-directory: ./extensions/intellij

jobs:
# Prepare and publish the plugin to JetBrains Marketplace repository
release:
name: Publish Plugin
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}

# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17

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

# Set environment variables
- name: Export Properties
id: properties
shell: bash
run: |
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
${{ github.event.release.body }}
EOM
)"
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Setup Node.js
- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"

# Cache node_modules
- name: Cache core node_modules
uses: actions/cache@v3
with:
path: core/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}

- name: Cache binary node_modules
uses: actions/cache@v3
with:
path: binary/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('binary/package-lock.json') }}

# npm install core
- name: Install core node_modules
run: |
cd ../../core
npm ci
# npm install binary
- name: Install core node_modules
run: |
cd ../../binary
npm ci
# Build binaries
- name: Install core node_modules
run: |
cd ../../binary
npm run build
# Update Unreleased section with the current release note
- name: Patch Changelog
if: ${{ steps.properties.outputs.changelog != '' }}
env:
CHANGELOG: ${{ steps.properties.outputs.changelog }}
run: |
./gradlew patchChangelog --release-note="$CHANGELOG"
# Publish the plugin to JetBrains Marketplace
- name: Publish Plugin
env:
PUBLISH_TOKEN: ${{ secrets.JETBRAINS_PUBLISH_TOKEN }}
CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_CERTIFICATE_CHAIN }}
PRIVATE_KEY: ${{ secrets.JETBRAINS_PRIVATE_KEY }}
PRIVATE_KEY_PASSWORD: ${{ secrets.JETBRAINS_PRIVATE_KEY_PASSWORD }}
run: ./gradlew publishPlugin

# Upload artifact as a release asset
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*

# Create a pull request
- name: Create Pull Request
if: ${{ steps.properties.outputs.changelog != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ github.event.release.tag_name }}"
BRANCH="changelog-update-$VERSION"
LABEL="release changelog"
git config user.email "action@github.com"
git config user.name "GitHub Action"
git checkout -b $BRANCH
git commit -am "Changelog update - $VERSION"
git push --set-upstream origin $BRANCH
gh label create "$LABEL" \
--description "Pull requests with release changelog update" \
--force \
|| true
gh pr create \
--title "Changelog update - \`$VERSION\`" \
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
--label "$LABEL" \
--head $BRANCH
6 changes: 6 additions & 0 deletions .github/workflows/preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ jobs:
cd core
npm ci
# 2.25 Run core tests
- name: Run core tests
run: |
cd core
npm run test
# 2.5. Pre package
- name: Set var for environment info
shell: pwsh
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/ts-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: TypeScript Check

on:
pull_request:
branches:
- main
- preview

jobs:
tsc-check:
runs-on: ubuntu-latest

steps:
# 1. Check-out repository
- name: Check-out repository
uses: actions/checkout@v4

# 2. Install npm dependencies
- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"

- name: Cache extension node_modules
uses: actions/cache@v3
with:
path: extensions/vscode/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}

- name: Cache core node_modules
uses: actions/cache@v3
with:
path: core/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}

- name: Cache gui node_modules
uses: actions/cache@v3
with:
path: gui/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}

- name: Cache binary node_modules
uses: actions/cache@v3
with:
path: binary/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('binary/package-lock.json') }}

- name: Install extension Dependencies
run: |
cd extensions/vscode
npm ci
env:
# https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}

- name: Install gui Dependencies
run: |
cd gui
npm ci
- name: Install Core Dependencies
run: |
cd core
npm ci
- name: Install Binary Dependencies
run: |
cd binary
npm ci
- name: tsc core
run: |
cd core
npx tsc
- name: tsc extensions/vscode
run: |
cd extensions/vscode
npx tsc
- name: tsc binary
run: |
cd binary
npx tsc
- name: tsc gui
run: |
cd gui
npx tsc
19 changes: 19 additions & 0 deletions .prompts/test.prompt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
temperature: 0.5
maxTokens: 4096
name: jest
description: Write Jest unit tests
---
<system>
You are an expert programmer
</system>

{{{ input }}}

Write unit tests for the above selected code, following each of these instructions:
- Use `jest`
- Properly set up and tear down
- Include important edge cases
- The tests should be complete and sophisticated
- Give the tests just as chat output, don't edit any file
- Don't explain how to set up `jest`
- Write a single code block, making sure to label with the language being used (e.g. "```typscript")
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${workspaceFolder}/binary",
"env": {
"CONTINUE_DEVELOPMENT": "true"
"CONTINUE_DEVELOPMENT": "true",
"CONTINUE_GLOBAL_DIR": "${workspaceFolder}/binary/.continue"
}
},
{
Expand Down
23 changes: 23 additions & 0 deletions binary/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
roots: ["<rootDir>/test"],
transform: {
"^.+\\.ts?$": [
"ts-jest",
{
useESM: true,
},
],
"^.+\\.js$": [
"babel-jest",
{
presets: [["@babel/preset-env", { targets: { node: "current" } }]],
},
],
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node", ".d.ts"],
extensionsToTreatAsEsm: [".ts", ".d.ts"],
// Remove or comment out the moduleNameMapper configuration
moduleNameMapper: {
"^(.*)\\.js$": "$1",
},
};
Loading

0 comments on commit 20bf1bd

Please sign in to comment.