Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
526d09f
test: refactor to use BDD markdown v. 6
pudkrong Sep 11, 2023
0770498
test: refactor to use BDD markdown v. 6
pudkrong Sep 12, 2023
be5d44c
test: refactor to use BDD markdown v. 6
pudkrong Sep 12, 2023
99ecf35
test: refactor to use BDD markdown v. 6
pudkrong Sep 12, 2023
9c3dd52
test: refactor to use BDD markdown v. 6
pudkrong Sep 12, 2023
501258b
test: refactor to use BDD markdown v. 6
pudkrong Sep 12, 2023
19fa463
test: refactor to use BDD markdown v. 6
pudkrong Sep 12, 2023
0b8f10e
test: refactor to use BDD markdown v. 6
pudkrong Sep 12, 2023
508ecd8
test: refactor to use BDD markdown v. 6
pudkrong Sep 12, 2023
355b550
test: clean up
pudkrong Sep 12, 2023
3b3eacf
chore: update dependencies
pudkrong Sep 12, 2023
ccffb76
fix: bdd markdown API change
pudkrong Sep 12, 2023
51df96f
chore: update dependencies
pudkrong Sep 12, 2023
d9c6bb0
test: using generated request id in testing
pudkrong Sep 12, 2023
4abe1e9
Merge branch 'saga' into refactor-e2e
pudkrong Sep 12, 2023
153a44f
test: adjust retry to match the task
pudkrong Sep 12, 2023
be4cc06
fix: downgrade swc
pudkrong Sep 13, 2023
8c89839
test: adjust retry time for shadow
pudkrong Sep 13, 2023
f382412
test: refactor code
pudkrong Sep 13, 2023
5f2fb59
Revert "chore: update dependencies"
pudkrong Sep 13, 2023
bce46ef
Revert "fix: downgrade swc"
pudkrong Sep 13, 2023
4c5bc80
test: using hardcoded ID
pudkrong Sep 13, 2023
9e9d274
fix: emit assert for import assertions
pudkrong Sep 13, 2023
fceab00
test: revert unrelated changes
pudkrong Sep 13, 2023
dfa5f3e
test: remove unrelated steps for user
pudkrong Sep 14, 2023
dd799f3
fix: add more info on the log
pudkrong Sep 14, 2023
6408a36
fix: using package-lock.json from linux
pudkrong Sep 14, 2023
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
10 changes: 7 additions & 3 deletions feature-runner/lib/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import WebSocket from 'ws'
import { ulid } from '../../util/ulid.js'

export type WebSocketClient = {
id: string
connect: () => Promise<any>
close: () => void
send: (message: Record<string, unknown>) => Promise<void>
Expand All @@ -20,8 +21,9 @@ export const createWebsocketClient = ({
}): WebSocketClient => {
if (clients[id] === undefined) {
const client = new WebSocket(url)
const messages: Record<string, unknown> = {}
const messages: Record<string, unknown> = {} as const
clients[id] = {
id,
connect: async () =>
new Promise<void>((resolve, reject) =>
client
Expand All @@ -33,7 +35,7 @@ export const createWebsocketClient = ({
})
.on('message', async (msg) => {
const message = JSON.parse(msg.toString())
debug?.(msg.toString())
debug?.('<< ' + msg.toString())
messages[ulid()] = message
}),
),
Expand All @@ -44,8 +46,10 @@ export const createWebsocketClient = ({
messages,
send: async (message) =>
new Promise<void>((resolve, reject) => {
client.send(JSON.stringify(message), (error) => {
const strMessage = JSON.stringify(message)
client.send(strMessage, (error) => {
if (error) return reject(error)
debug?.('>> ' + strMessage)
resolve()
})
}),
Expand Down
22 changes: 11 additions & 11 deletions feature-runner/run-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,30 @@ const runner = await runFolder({
onDebug: (info, ...args) =>
console.error(
ts(),
chalk.magenta.dim(info.context.keyword),
chalk.magenta(info.context.title),
chalk.magenta.dim(info.step.keyword),
chalk.magenta(info.step.title),
...args.map((arg) => chalk.cyan(print(arg))),
),
onError: (info, ...args) =>
console.error(
ts(),
chalk.magenta.dim(info.context.keyword),
chalk.magenta(info.context.title),
...args.map((arg) => chalk.red(print(arg))),
chalk.magenta.dim(info.step.keyword),
chalk.magenta(info.step.title),
...args.map((arg) => chalk.cyan(print(arg))),
),
onInfo: (info, ...args) =>
console.error(
ts(),
chalk.magenta.dim(info.context.keyword),
chalk.magenta(info.context.title),
...args.map((arg) => chalk.green(print(arg))),
chalk.magenta.dim(info.step.keyword),
chalk.magenta(info.step.title),
...args.map((arg) => chalk.cyan(print(arg))),
),
onProgress: (info, ...args) =>
console.error(
ts(),
chalk.magenta.dim(info.context.keyword),
chalk.magenta(info.context.title),
...args.map((arg) => chalk.yellow(print(arg))),
chalk.magenta.dim(info.step.keyword),
chalk.magenta(info.step.title),
...args.map((arg) => chalk.cyan(print(arg))),
),
},
})
Expand Down
41 changes: 14 additions & 27 deletions feature-runner/steps/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
matchGroups,
noMatch,
type StepRunResult,
type StepRunner,
type StepRunnerArgs,
regExpMatchedStep,
} from '@nordicsemiconductor/bdd-markdown'
import { Type } from '@sinclair/typebox'
import { hashSHA1 } from '../../util/hashSHA1.js'
Expand All @@ -18,34 +15,24 @@ const createConfigStepRunners = ({
}: {
configWriter: ReturnType<typeof putSettings>
}): StepRunner<Record<string, any>>[] => {
const setupDeviceShadowFetchingConfiguration = async ({
step,
log: {
step: { progress },
},
}: StepRunnerArgs<Record<string, any>>): Promise<StepRunResult> => {
const match = matchGroups(
Type.Object({
const setupDeviceShadowFetchingConfiguration = regExpMatchedStep(
{
regExp:
/^device shadow fetching config for model `(?<model>[^`]+)` is `(?<interval>[^`]+)`$/,
schema: Type.Object({
model: Type.String(),
interval: Type.Integer(),
}),
{
converters: {
interval: (s) => parseInt(s, 10),
},
)(
/^device shadow fetching config for model `(?<model>[^`]+)` is `(?<interval>[^`]+)`$/,
step.title,
)

if (match === null) return noMatch

// ssm path must be letter, number, .(dot), -(dash), or _(underscore)
const model = hashSHA1(match.model)
const interval = match.interval

progress(`Set fetching interval for ${model} as ${interval} seconds`)
await configWriter({ property: model, value: `${interval}` })
}
},
async ({ match: { model, interval }, log: { progress } }) => {
const modelHash = hashSHA1(model)
progress(`Set fetching interval for ${modelHash} as ${interval} seconds`)
await configWriter({ property: modelHash, value: `${interval}` })
},
)

return [setupDeviceShadowFetchingConfiguration]
}
Expand Down
Loading