Skip to content

Commit

Permalink
Adding more tests for npm packages (#347)
Browse files Browse the repository at this point in the history
* Extend Codewhisperer server packaging test

* Add more tests

* Set private field for test package

* Add README
  • Loading branch information
viktorsaws authored Jun 27, 2024
1 parent 2a7c092 commit c2bbc6b
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 15 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/npm-packaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build:
name: Test Codewhisperer Server Packaging
name: Test public NPM packages
runs-on: ubuntu-latest
steps:
- name: Sync Code
Expand All @@ -21,12 +21,13 @@ jobs:
- name: Build all monorepo packages
run: |
npm run compile
- name: Pack AWS CodeWhisperer LSP server
run: npm pack -w server/aws-lsp-codewhisperer
- name: Pack public npm packages
run: |
npm pack -w server/aws-lsp-codewhisperer -w server/aws-lsp-partiql -w server/aws-lsp-json -w server/aws-lsp-yaml
- name: Create test package
run: |
cd tests
npm install ../aws-lsp-codewhisperer-*.tgz
npm install ../aws-lsp-codewhisperer-*.tgz ../aws-lsp-partiql-*.tgz ../aws-lsp-json-*.tgz ../aws-lsp-yaml-*.tgz
- name: Test imports
run: |
cd tests
Expand Down
1 change: 1 addition & 0 deletions server/aws-lsp-codewhisperer/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './language-server/codeWhispererSecurityScanServer'
export * from './language-server/codeWhispererServer'
export * from './language-server/qChatServer'
export * from './language-server/proxy-server'
1 change: 1 addition & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is test package, used in [NPM packaging testing](../.github/workflows/npm-packaging.yaml) workflow.
16 changes: 13 additions & 3 deletions tests/aws-lsp-codewhisperer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
const myPackage = require('@aws/lsp-codewhisperer')
console.log(myPackage.CodeWhispererServerIAM)
console.log(myPackage.CodeWhispererServerToken)
const assert = require('assert')
const codewhispererPackage = require('@aws/lsp-codewhisperer')

assert.ok(codewhispererPackage.CodeWhispererServerIAM)
assert.ok(codewhispererPackage.CodeWhispererServerIAMProxy)
assert.ok(codewhispererPackage.CodeWhispererServerToken)
assert.ok(codewhispererPackage.CodeWhispererServerTokenProxy)
assert.ok(codewhispererPackage.SecurityScanServerToken)
assert.ok(codewhispererPackage.CodeWhispererSecurityScanServerTokenProxy)
assert.ok(codewhispererPackage.QChatServer)
assert.ok(codewhispererPackage.QChatServerProxy)

console.info('AWS Codewhisperer LSP: all tests passed')
7 changes: 7 additions & 0 deletions tests/aws-lsp-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const assert = require('assert')
const jsonPackage = require('@aws/lsp-json')

assert.ok(jsonPackage.CreateJsonLanguageServer)
assert.ok(jsonPackage.JsonLanguageService)

console.info('AWS JSON LSP: all tests passed')
5 changes: 5 additions & 0 deletions tests/aws-lsp-partiql.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// const assert = require('assert')
// const partiqlPackage = require('@aws/lsp-partiql')
// assert.ok(partiqlPackage.PartiQLLanguageServer)

console.warn('AWS PartiQL server: Skipping test')
7 changes: 7 additions & 0 deletions tests/aws-lsp-yaml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const assert = require('assert')
const yamlPackage = require('@aws/lsp-yaml')

assert.ok(yamlPackage.CreateYamlLanguageServer)
assert.ok(yamlPackage.YamlLanguageService)

console.info('AWS Yaml LSP: all tests passed')
15 changes: 7 additions & 8 deletions tests/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"name": "test-package",
"version": "1.0.0",
"description": "",
"main": "index.js",
"private": true,
"scripts": {
"test": "npm run test:aws-lsp-codewhisperer",
"test:aws-lsp-codewhisperer": "node aws-lsp-codewhisperer.js"
},
"keywords": [],
"author": "",
"license": "ISC"
"test": "npm run test:codewhisperer && npm run test:json && npm run test:partiql && npm run test:json",
"test:codewhisperer": "node aws-lsp-codewhisperer.js",
"test:json": "node aws-lsp-json.js",
"test:partiql": "node aws-lsp-partiql.js",
"test:yaml": "node aws-lsp-yaml.js"
}
}

0 comments on commit c2bbc6b

Please sign in to comment.