🧪 Add a non_agent_mode e2e test (#925) #2318
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI (repo level) | |
on: | |
push: | |
branches: | |
- "main" | |
- "release-*" | |
tags: | |
- "v*" | |
pull_request: | |
paths-ignore: | |
- "docs/**" | |
branches: | |
- "main" | |
- "release-*" | |
workflow_dispatch: | |
workflow_call: | |
concurrency: | |
group: ci-repo-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: true | |
# https://typicode.github.io/husky/how-to.html#ci-server-and-docker | |
env: | |
HUSKY: 0 | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Install workspace dependencies | |
run: | | |
npm ci | |
- name: Lint sources | |
run: | | |
npm run lint | |
build: | |
needs: lint | |
name: Build (${{ matrix.arch }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
arch: linux | |
- os: macos-latest | |
arch: macos | |
- os: windows-latest | |
arch: windows | |
max-parallel: 3 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Install workspace dependencies | |
run: | | |
npm ci | |
- name: Build | |
run: | | |
npm run build | |
test: | |
name: Test (${{ matrix.arch }}) | |
runs-on: ${{ matrix.os }} | |
needs: build | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
arch: linux | |
- os: macos-latest | |
arch: macos | |
- os: windows-latest | |
arch: windows | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Install workspace dependencies | |
run: | | |
npm ci | |
# | |
# TODO: To run a proper test, the Kai assets need to be downloaded for the proper place | |
# TODO: For example, this would be nice... | |
# - name: Collect assets needed to run Kai on the current runtime's platform/arch | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# run: | | |
# npm run collect-assets -- \ | |
# --use-workflow-artifacts \ | |
# --branch=main \ | |
# --platform=runtime \ | |
# --arch=runtime | |
# Run tests on Linux | |
- name: Run tests (Linux) | |
if: matrix.arch == 'linux' | |
run: xvfb-run -a npm test | |
# Run tests on macOS | |
- name: Run tests (macOS) | |
if: matrix.arch == 'macos' | |
run: npm test | |
# Run tests on Windows | |
- name: Run tests (Windows) | |
if: matrix.arch == 'windows' | |
shell: cmd | |
run: npm test | |
package: | |
name: Package (${{ matrix.arch }}) | |
runs-on: ${{ matrix.os }} | |
needs: test | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
arch: linux | |
max-parallel: 1 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Install dependencies and build | |
run: | | |
npm ci | |
npm run build | |
- name: Collect runtime assets | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
npm run collect-assets -- --use-release | |
- name: Set version for build | |
run: | | |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then | |
# Tagged release: use tag version | |
VERSION="${{ github.ref_name }}" | |
VERSION="${VERSION#v}" # Strip 'v' prefix | |
echo "Setting release version: $VERSION" | |
npm version "$VERSION" --workspaces --include-workspace-root --no-git-tag-version --allow-same-version | |
else | |
# Development build: add timestamp and SHA | |
CURRENT_VERSION=$(npm pkg get version | tr -d '"') | |
TIMESTAMP=$(date +%Y%m%d%H%M%S) | |
SHA=$(git rev-parse --short HEAD) | |
DEV_VERSION="${CURRENT_VERSION}-dev.${TIMESTAMP}.${SHA}" | |
echo "Setting development version: $DEV_VERSION" | |
npm version "$DEV_VERSION" --workspaces --include-workspace-root --no-git-tag-version | |
fi | |
- name: Package extension | |
run: | | |
npm run dist | |
npm run package | |
- name: Upload VSIX artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: vsix-artifact | |
path: ./dist/*.vsix | |
test-e2e: | |
name: Test E2E | |
runs-on: ubuntu-latest | |
needs: package | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Install vscode dependencies | |
run: sudo apt-get update && sudo apt-get install -y wget | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: "oracle" | |
java-version: "17" | |
- name: Download and Install VSCode | |
run: | | |
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg | |
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg | |
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" |sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null | |
rm -f packages.microsoft.gpg | |
sudo apt install apt-transport-https -y | |
sudo apt update | |
sudo apt install code -y | |
- name: Set up virtual X11 | |
run: | | |
sudo apt-get install -y \ | |
xvfb \ | |
x11-xserver-utils \ | |
dbus-x11 \ | |
xfonts-100dpi \ | |
xfonts-75dpi \ | |
libxrender1 \ | |
libxext6 \ | |
libx11-6 \ | |
xfonts-base \ | |
nickle cairo-5c \ | |
xorg-docs-core | |
- name: Set DISPLAY environment variable | |
run: | | |
Xvfb :99 -screen 0 1920x1080x24 & | |
echo "DISPLAY=:99" >> "$GITHUB_ENV" | |
- name: Start Dbus | |
run: | | |
dbus-launch --exit-with-session & | |
sudo service dbus start | |
export XDG_RUNTIME_DIR=/run/user/$(id -u) | |
sudo chmod 700 $XDG_RUNTIME_DIR | |
sudo chown $(id -un):$(id -gn) $XDG_RUNTIME_DIR | |
export DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus | |
dbus-daemon --session --address=$DBUS_SESSION_BUS_ADDRESS --nofork --nopidfile --syslog-only & | |
mkdir ~/.vscode && echo '{ "disable-hardware-acceleration": true }' > ~/.vscode/argv.json | |
- name: Verify Installation | |
run: code --version | |
- name: Ensure no VSCode instances are running | |
run: | | |
pkill -f code || true | |
- name: Install dependencies | |
run: npm ci | |
working-directory: ./tests | |
- name: Download VSIX artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: vsix-artifact | |
path: ./dist | |
- name: Set VSIX path | |
id: set_vsix_path | |
run: echo "vsix_path=$(ls -1 ./dist/*.vsix)" >> $GITHUB_OUTPUT | |
- name: Run e2e tests (Linux) | |
run: npx playwright test e2e/tests/base/configure-and-run-analysis.test.ts | |
working-directory: ./tests | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
VSIX_FILE_PATH: ${{ github.workspace }}/${{ steps.set_vsix_path.outputs.vsix_path }} | |
# This is intentionally kept in a separate step to avoid passing in credentials | |
- name: Run e2e tests (Linux - Offline) | |
run: npx playwright test e2e/tests/agent_flow_coolstore.test.ts | |
working-directory: ./tests | |
env: | |
VSIX_FILE_PATH: ${{ github.workspace }}/${{ steps.set_vsix_path.outputs.vsix_path }} | |
OPENAI_API_KEY: <dummy> # this only exists to pass provider validation | |
- name: Collect test artifacts | |
if: always() | |
run: | | |
mkdir -p test-artifacts | |
if [ -d "test-data-dir" ]; then | |
cp -r test-data-dir test-artifacts/ | |
fi | |
if [ -d "test-output" ]; then | |
cp -r test-output test-artifacts/ | |
fi | |
working-directory: ./tests | |
- name: Upload test artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: e2e-test-artifacts | |
path: tests/test-artifacts/ | |
retention-days: 7 | |
publish: | |
name: Publish Development Build | |
runs-on: ubuntu-latest | |
needs: test-e2e | |
# Only publish development builds (not tagged releases) | |
if: ${{ ! (github.event_name == 'pull_request' && ! github.event.pull_request.merged) && ! startsWith(github.ref, 'refs/tags/v') }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download VSIX artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: vsix-artifact | |
path: ./dist | |
- name: Find VSIX file | |
id: find_vsix | |
run: | | |
VSIX_FILE=$(find ./dist -name "*.vsix" -type f | head -1) | |
VSIX_NAME=$(basename "$VSIX_FILE") | |
echo "vsix_path=$VSIX_FILE" >> "$GITHUB_OUTPUT" | |
echo "vsix_name=$VSIX_NAME" >> "$GITHUB_OUTPUT" | |
echo "Found VSIX: $VSIX_NAME" | |
- name: Deploy development build | |
uses: WebFreak001/[email protected] | |
with: | |
upload_url: ${{ vars.CI_UPLOAD_URL }} | |
release_id: ${{ vars.CI_RELEASE_ID }} | |
asset_path: ${{ steps.find_vsix.outputs.vsix_path }} | |
asset_name: ${{ steps.find_vsix.outputs.vsix_name }} | |
asset_content_type: application/octet-stream | |
ignore_hash: true | |
- name: Cleanup old development builds | |
run: | | |
c=1 | |
for i in $(gh release view -R konveyor/editor-extensions development-builds --json assets | jq -r .assets[].name | sort -r); do | |
if [ "$c" -gt 7 ]; then | |
gh release delete-asset -y -R konveyor/editor-extensions development-builds $i | |
fi | |
c=$((c+1)) | |
done | |
env: | |
GH_TOKEN: ${{ github.token }} | |
release: | |
name: Create Release | |
needs: test-e2e | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
uses: ./.github/workflows/release.yml | |
with: | |
tag_name: ${{ github.ref_name }} | |
prerelease: ${{ contains(github.ref_name, '-') }} | |
vsix_artifact_name: "vsix-artifact" | |
secrets: inherit |