Skip to content

Commit

Permalink
Covert from CircleCI to GH Actions (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
SketchingDev authored Jul 18, 2023
1 parent 9e8613c commit bed460d
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 117 deletions.
97 changes: 0 additions & 97 deletions .circleci/config.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: On Push

on: [push]

jobs:
# lint:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Setup Node
# uses: actions/setup-node@v1
# with:
# node-version: 16.x
# - run: yarn
# - run: yarn lint
# env:
# CI: true

test-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: yarn
- run: yarn build
- run: yarn test

test-building-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: yarn
- run: yarn build
- run: yarn build:docs

test-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: yarn
- run: yarn build
- run: cd examples/cli && yarn execute
env:
DEPLOYMENT_ID: ${{ secrets.DEPLOYMENT_ID }}
REGION: ${{ secrets.REGION }}
- run: cd examples/api && yarn test:js
env:
DEPLOYMENT_ID: ${{ secrets.DEPLOYMENT_ID }}
REGION: ${{ secrets.REGION }}
- run: cd examples/api && yarn test:ts
env:
DEPLOYMENT_ID: ${{ secrets.DEPLOYMENT_ID }}
REGION: ${{ secrets.REGION }}
20 changes: 20 additions & 0 deletions .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish Package to npmjs
on:
release:
types: [published]
jobs:
test-build-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
scope: '@ovotech'
- run: yarn
- run: yarn build
- run: yarn test
- run: yarn npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions examples/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"packageManager": "yarn@3.1.1",
"scripts": {
"lint": "eslint 'src/**/*.ts'",
"test": "jest __tests__",
"test:js": "node ../api/src/js-script.js",
"test:ts": "node -r ts-node/register ../api/src/ts-script.ts"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
],
"scripts": {
"test": "yarn workspaces foreach --verbose --exclude '@examples/*' run test",
"lint": "yarn workspaces foreach --verbose run lint",
"build": "yarn workspaces foreach --verbose run build",
"build:docs": "cp README.md packages/genesys-web-messaging-tester-cli/README.md && typedoc && yarn workspaces foreach --verbose run build:readme",
"publish": "yarn workspaces foreach --no-private --verbose npm publish --tolerate-republish --access public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ scenarios:
scenario:
- say: hi from scenario
`);
await expect(
cli([...['node', '/path/to/cli'], ...['test-path']]),
).rejects.toBeDefined();
await expect(cli([...['node', '/path/to/cli'], ...['test-path']])).rejects.toBeDefined();

expect(capturedOutput.errOut.map(stripAnsi)).toStrictEqual([expectedError]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ describe('Test script YAML loaded', () => {
throw new Error('force app to exit');
});

await expect(
cli([...['node', '/path/to/cli'], ...['test-file.yml']]),
).rejects.toBeDefined();
await expect(cli([...['node', '/path/to/cli'], ...['test-file.yml']])).rejects.toBeDefined();

expect(capturedOutput.errOut.map(stripAnsi)).toStrictEqual([
"error: command-argument value 'test-file.yml' is invalid for argument 'filePath'. File 'test-file.yml' is not readable\n"
"error: command-argument value 'test-file.yml' is invalid for argument 'filePath'. File 'test-file.yml' is not readable\n",
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ config:
deploymentId: xx
region: xx
`);
await expect(
cli([...['node', '/path/to/cli'], ...['test-path']]),
).rejects.toBeDefined();
await expect(cli([...['node', '/path/to/cli'], ...['test-path']])).rejects.toBeDefined();

expect(capturedOutput.errOut.map(stripAnsi)).toStrictEqual(['"scenarios" is required\n']);
});
Expand All @@ -81,9 +79,7 @@ scenarios:
- say: hi from scenario
waitForReplyContaining: hello
`);
await expect(
cli([...['node', '/path/to/cli'], ...['test-path']]),
).rejects.toBeDefined();
await expect(cli([...['node', '/path/to/cli'], ...['test-path']])).rejects.toBeDefined();

expect(capturedOutput.errOut.map(stripAnsi)).toStrictEqual([
'"scenarios.scenario-name[0]" must have 1 key\n',
Expand All @@ -99,9 +95,7 @@ scenarios:
scenario-name:
- testing: 123
`);
await expect(
cli([...['node', '/path/to/cli'], ...['test-path']]),
).rejects.toBeDefined();
await expect(cli([...['node', '/path/to/cli'], ...['test-path']])).rejects.toBeDefined();

expect(capturedOutput.errOut.map(stripAnsi)).toStrictEqual([
'"scenarios.scenario-name[0].testing" is not allowed\n',
Expand Down
5 changes: 3 additions & 2 deletions packages/genesys-web-messaging-tester-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ovotech/genesys-web-messaging-tester-cli",
"version": "1.0.9",
"version": "1.0.10",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"license": "Apache-2.0",
Expand All @@ -21,7 +21,8 @@
"build:readme": "cd ../.. && yarn build-readme ./packages/genesys-web-messaging-tester-cli/README.md https://github.com/ovotech/genesys-web-messaging-tester/tree/main",
"test": "jest __tests__/",
"test:execute": "ts-node src/index.ts ../../examples/cli/example.yml -id $DEPLOYMENT_ID -r $REGION -p 10",
"test:execute:help": "ts-node src/index.ts --help"
"test:execute:help": "ts-node src/index.ts --help",
"lint": "eslint 'src/**/*.ts'"
},
"bin": {
"web-messaging-tester": "lib/index.js"
Expand Down
7 changes: 6 additions & 1 deletion packages/genesys-web-messaging-tester-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { validateSessionConfig } from './testScript/validateSessionConfig';
import { validateTestScript } from './testScript/validateTestScript';
import { ScenarioError, ScenarioSuccess } from './ScenarioResult';
import { validateGenesysEnvVariables } from './genesysPlatform/validateGenesysEnvVariables';
import { configurePlatformClients } from './genesysPlatform/configurePlatformClients';
import {
createConversationIdGetter,
messageIdToConversationIdFactory,
Expand Down Expand Up @@ -134,6 +133,12 @@ GENESYSCLOUD_OAUTHCLIENT_SECRET`,
ui?.validatingAssociateConvoIdEnvValidationFailed(genesysEnvValidationResult.error),
);
} else {
// Only load when required
// Also removes 'You are trying to `import` a file after the Jest environment has been torn down' error due to
// file-watcher it starts
const { configurePlatformClients } = await import(
'./genesysPlatform/configurePlatformClients'
);
const clients = await configurePlatformClients(genesysEnvValidationResult.genesysVariables);

const messageIdToConversationIdClient = messageIdToConversationIdFactory(clients);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export async function configurePlatformClients(
auth: GenesysPlatformApiAuth,
): Promise<{ convoApi: platformClient.ConversationsApi }> {
const apiClient = platformClient.ApiClient.instance;

apiClient.setEnvironment(auth.region);
await apiClient.loginClientCredentialsGrant(auth.oAuthClientId, auth.oAuthClientSecret);

Expand Down
3 changes: 2 additions & 1 deletion packages/genesys-web-messaging-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"scripts": {
"build": "rm -rf ./lib && tsc -p tsconfig.json",
"build:readme": "cd ../.. && yarn build-readme ./packages/genesys-web-messaging-tester/README.md https://github.com/ovotech/genesys-web-messaging-tester/tree/main",
"test": "jest __tests__/"
"test": "jest __tests__/",
"lint": "eslint 'src/**/*.ts'"
},
"dependencies": {
"debug": "^4.3.3",
Expand Down

0 comments on commit bed460d

Please sign in to comment.