Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 111 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ name: CI

on:
push:
branches: [main, feature/*]
branches: [main]
pull_request:
# By default, CI will trigger on opened/synchronize/reopened event types.
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request
# Note: To re-run `lint-commits` after fixing the PR title, close-and-reopen the PR.
branches: [main, feature/*]

permissions:
contents: read

# Cancel old jobs when a pull request is updated.
concurrency:
group: ${{ github.head_ref || github.run_id }}
Expand Down Expand Up @@ -117,6 +120,44 @@ jobs:
REPO_NAME: ${{ github.repository }}
run: node "$GITHUB_WORKSPACE/.github/workflows/filterDuplicates.js" run diff_output.txt jscpd-report.json $COMMIT_HASH $REPO_NAME

linux:
needs: lint-commits
name: test Linux
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18.x]
vscode-version: [minimum, stable, insiders]
package: [amazonq]
env:
VSCODE_TEST_VERSION: ${{ matrix.vscode-version }}
NODE_OPTIONS: '--max-old-space-size=8192'
AWS_TOOLKIT_TEST_CACHE_DIR: '/tmp/.vscode-test/'
AWS_TOOLKIT_TEST_USER_DIR: '/tmp/.vscode-test/user-data/'
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- name: Tests
uses: coactions/setup-xvfb@v1
with:
run: npm run test -w packages/${{ matrix.package }}
- name: Code coverage for ${{ matrix.package }}
env:
# Unset NODE_OPTIONS because of https://github.com/codecov/uploader/issues/475
NODE_OPTIONS: ''
if: ${{ github.repository == 'aws/amazon-q-vscode' && github.event_name == 'pull_request' && github.base_ref == 'main' }}
uses: codecov/codecov-action@v5
with:
flags: linux-${{ matrix.package }}-unittests
verbose: true
file: ./coverage/${{ matrix.package }}/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}

macos:
needs: lint-commits
name: test macOS
Expand Down Expand Up @@ -181,6 +222,75 @@ jobs:
with:
run: npm run testWeb

e2e:
needs: lint-commits
name: test E2E
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18.x]
vscode-version: [minimum, stable, insiders]
package: [amazonq]
env:
VSCODE_TEST_VERSION: ${{ matrix.vscode-version }}
NODE_OPTIONS: '--max-old-space-size=8192'
AWS_TOOLKIT_TEST_CACHE_DIR: '/tmp/.vscode-test/'
AWS_TOOLKIT_TEST_USER_DIR: '/tmp/.vscode-test/user-data/'
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- name: Increase file watchers
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: Tests
uses: coactions/setup-xvfb@v1
with:
run: npm run testE2E -w packages/${{ matrix.package }}
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-test-reports-${{ matrix.vscode-version }}
path: .test-reports/
- name: Code coverage for ${{ matrix.package }}
env:
NODE_OPTIONS: ''
if: ${{ github.repository == 'aws/amazon-q-vscode' && github.event_name == 'pull_request' && github.base_ref == 'main' }}
uses: codecov/codecov-action@v5
with:
flags: linux-${{ matrix.package }}-e2e
verbose: true
file: ./coverage/${{ matrix.package }}/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}

package:
needs: lint-commits
name: package VSIX
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
env:
NODE_OPTIONS: '--max-old-space-size=8192'
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run createRelease -w packages/amazonq
- run: npm run package -w packages/amazonq
- name: Upload VSIX artifact
uses: actions/upload-artifact@v4
with:
name: amazonq-vsix
path: '*.vsix'

windows:
needs: lint-commits
name: test Windows
Expand Down
11 changes: 6 additions & 5 deletions packages/amazonq/test/e2e/amazonq/chat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import { Messenger } from './framework/messenger'
import { MynahUIDataModel } from '@aws/mynah-ui'
import { assertContextCommands, assertQuickActions } from './assert'
import { registerAuthHook, using } from 'aws-core-vscode/test'
import { loginToIdC } from './utils/setup'
import { isSSOTestEnvironmentAvailable, loginToIdC } from './utils/setup'
import { webviewConstants, webviewTabConstants } from 'aws-core-vscode/amazonq'

// These tests require SSO auth infrastructure (auth Lambda + Secrets Manager) only available in internal CI.
// They are skipped in GitHub Actions since the repo is open source and credentials cannot be exposed.
describe('Amazon Q Chat', function () {
this.retries(3)
let framework: qTestingFramework
Expand All @@ -22,10 +24,9 @@ describe('Amazon Q Chat', function () {
const availableCommands: string[] = ['/dev', '/test', '/review', '/doc', '/transform']

before(async function () {
/**
* Login to the amazonq-test-account. When running in CI this has unlimited
* calls to the backend api
*/
if (!isSSOTestEnvironmentAvailable()) {
this.skip()
}
await using(registerAuthHook('amazonq-test-account'), async () => {
await loginToIdC()
})
Expand Down
7 changes: 6 additions & 1 deletion packages/amazonq/test/e2e/amazonq/review.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { qTestingFramework } from './framework/framework'
import sinon from 'sinon'
import { Messenger } from './framework/messenger'
import { registerAuthHook, using, closeAllEditors } from 'aws-core-vscode/test'
import { loginToIdC } from './utils/setup'
import { isSSOTestEnvironmentAvailable, loginToIdC } from './utils/setup'
import {
codewhispererDiagnosticSourceLabel,
invalidFileTypeChatMessage,
Expand All @@ -29,6 +29,8 @@ function getWorkspaceFolder(): string {
return vscode.workspace.workspaceFolders![0].uri.fsPath
}

// These tests require SSO auth infrastructure (auth Lambda + Secrets Manager) only available in internal CI.
// They are skipped in GitHub Actions since the repo is open source and credentials cannot be exposed.
describe('Amazon Q Code Review', function () {
let framework: qTestingFramework
let tab: Messenger
Expand Down Expand Up @@ -105,6 +107,9 @@ describe('Amazon Q Code Review', function () {
}

before(async function () {
if (!isSSOTestEnvironmentAvailable()) {
this.skip()
}
await using(registerAuthHook('amazonq-test-account'), async () => {
await loginToIdC()
})
Expand Down
7 changes: 6 additions & 1 deletion packages/amazonq/test/e2e/amazonq/transformByQ.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ import {
} from 'aws-core-vscode/codewhisperer'
import { GumbyController, setMaven, startTransformByQ, TabsStorage } from 'aws-core-vscode/amazonqGumby'
import { using, registerAuthHook, TestFolder } from 'aws-core-vscode/test'
import { loginToIdC } from './utils/setup'
import { isSSOTestEnvironmentAvailable, loginToIdC } from './utils/setup'
import { fs } from 'aws-core-vscode/shared'
import path from 'path'

// These tests require SSO auth infrastructure (auth Lambda + Secrets Manager) only available in internal CI.
// They are skipped in GitHub Actions since the repo is open source and credentials cannot be exposed.
describe('Amazon Q Code Transformation', function () {
let framework: qTestingFramework
let tab: Messenger

before(async function () {
if (!isSSOTestEnvironmentAvailable()) {
this.skip()
}
await using(registerAuthHook('amazonq-test-account'), async () => {
await loginToIdC()
})
Expand Down
11 changes: 11 additions & 0 deletions packages/amazonq/test/e2e/amazonq/utils/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
*/
import { AuthUtil } from 'aws-core-vscode/codewhisperer'

/**
* Returns true if the SSO auth infrastructure required for E2E tests is available.
*
* These tests require an internal SSO identity provider and a Lambda-based auth
* hook that automates the browser login flow. This infrastructure is only available
* in internal CI (CodeBuild) and cannot be replicated in GitHub Actions.
*/
export function isSSOTestEnvironmentAvailable(): boolean {
return !!process.env['TEST_SSO_STARTURL'] && !!process.env['TEST_SSO_REGION']
}

export async function loginToIdC() {
const authState = await AuthUtil.instance.getChatAuthState()
if (process.env['AWS_TOOLKIT_AUTOMATION'] === 'local') {
Expand Down
20 changes: 6 additions & 14 deletions packages/amazonq/test/e2e/amazonq/welcome.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Amazon Q Welcome page', function () {
let tab: Messenger
let store: MynahUIDataModel

const availableCommands = ['/dev', '/test', '/review', '/doc', '/transform']
const availableCommands = ['/transform', '/help', '/clear']

const highlightCommand: FeatureContext = {
name: 'highlightCommand',
Expand Down Expand Up @@ -45,7 +45,7 @@ describe('Amazon Q Welcome page', function () {
assertContextCommands(tab, ['@workspace', '@highlight'])
})

describe('shows 3 times', async () => {
describe('shows 5 times', async () => {
it('new tabs', () => {
framework.createTab()
framework.createTab()
Expand All @@ -58,11 +58,11 @@ describe('Amazon Q Welcome page', function () {
welcomeCount++
}
}
// 3 welcome tabs
assert.deepStrictEqual(welcomeCount, 3)
// all 5 tabs are welcome tabs since the closure captures the initial welcomeCount because there is no more / commands
assert.deepStrictEqual(welcomeCount, 5)

// 2 normal tabs
assert.deepStrictEqual(framework.getTabs().length - welcomeCount, 2)
// 0 normal tabs
assert.deepStrictEqual(framework.getTabs().length - welcomeCount, 0)
})

it('new windows', () => {
Expand All @@ -85,14 +85,6 @@ describe('Amazon Q Welcome page', function () {
})

describe('Welcome actions', () => {
it('explore', () => {
tab.clickInBodyButton('explore')

// explore opens in a new tab
const exploreTabStore = framework.findTab('Explore')?.getStore()
assert.strictEqual(exploreTabStore?.tabTitle, 'Explore')
})

it('quick-start', async () => {
tab.clickInBodyButton('quick-start')

Expand Down
7 changes: 6 additions & 1 deletion packages/amazonq/test/e2e/inline/inline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import {
} from 'aws-core-vscode/test'
import { RecommendationHandler, RecommendationService, session } from 'aws-core-vscode/codewhisperer'
import { Commands, globals, sleep, waitUntil, collectionUtil } from 'aws-core-vscode/shared'
import { loginToIdC } from '../amazonq/utils/setup'
import { loginToIdC, isSSOTestEnvironmentAvailable } from '../amazonq/utils/setup'

// These tests require SSO auth infrastructure (auth Lambda + Secrets Manager) only available in internal CI.
// They are skipped in GitHub Actions since the repo is open source and credentials cannot be exposed.
describe('Amazon Q Inline', async function () {
const retries = 3
this.retries(retries)
Expand All @@ -30,6 +32,9 @@ describe('Amazon Q Inline', async function () {
}

before(async function () {
if (!isSSOTestEnvironmentAvailable()) {
this.skip()
}
await using(registerAuthHook('amazonq-test-account'), async () => {
await loginToIdC()
})
Expand Down
Loading