This repository has been archived by the owner on Feb 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-features.ts
97 lines (87 loc) · 2.14 KB
/
run-features.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import {
FeatureRunner,
ConsoleReporter,
awsSdkStepRunners,
storageStepRunners,
} from '@bifravst/e2e-bdd-test-runner'
import * as chalk from 'chalk'
import { IoTClient } from '@aws-sdk/client-iot'
import { STSClient, GetCallerIdentityCommand } from '@aws-sdk/client-sts'
import { firmwareCIStepRunners } from './steps/firmwareCI'
import { getInput } from '@actions/core'
const getRequiredInput = (input: string): string =>
getInput(input, { required: true })
const jobId = getRequiredInput('job id')
const accessKeyId = getRequiredInput('aws access key id')
const secretAccessKey = getRequiredInput('aws secret access key')
const region = getRequiredInput('aws region')
const mqttEndpoint = getRequiredInput('broker hostname')
const stackName = getRequiredInput('stack name')
const appVersion = getRequiredInput('app version')
const featureDir = getRequiredInput('feature dir')
const testEnvSDKConfig = {
region,
credentials: {
accessKeyId,
secretAccessKey,
},
}
const main = async () => {
const { Account: accountId } = await new STSClient(testEnvSDKConfig).send(
new GetCallerIdentityCommand({}),
)
const iot = new IoTClient(testEnvSDKConfig)
const world = {
region: region,
accountId: accountId as string,
mqttEndpoint,
stackName,
jobId,
awsAccessKeyId: accessKeyId,
awsSecretAccessKey: secretAccessKey,
appVersion,
}
console.log(chalk.yellow.bold(' World:'))
console.log()
console.log(world)
console.log()
const runner = new FeatureRunner<typeof world>(world, {
dir: featureDir,
reporters: [
new ConsoleReporter({
printResults: true,
printProgress: true,
printSummary: true,
}),
],
retry: false,
})
try {
const { success } = await runner
.addStepRunners(
firmwareCIStepRunners({
iot,
}),
)
.addStepRunners(
awsSdkStepRunners({
constructorArgs: {
IotData: {
endpoint: world.mqttEndpoint,
},
},
}),
)
.addStepRunners(storageStepRunners())
.run()
if (!success) {
process.exit(1)
}
process.exit()
} catch (error) {
console.error(chalk.red('Running the features failed!'))
console.error(error)
process.exit(1)
}
}
void main()