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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d306d14
Showing
18 changed files
with
296,272 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@bifravst/eslint-config-typescript" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Test and Release | ||
|
||
on: push | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: "12.x" | ||
- name: Keep npm cache around to speed up installs | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }} | ||
- run: npm ci --no-audit | ||
- run: npx tsc | ||
- run: npm run build | ||
- name: Semantic release | ||
continue-on-error: true | ||
run: | | ||
npm i --no-save semantic-release | ||
npx semantic-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules/ | ||
dist/ | ||
build/* | ||
!build/index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist/ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
...require('@bifravst/code-style/.prettierrc'), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
See https://github.com/bifravst/bifravst/blob/saga/CODE_OF_CONDUCT.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2019-2021, Nordic Semiconductor ASA | nordicsemi.no | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Firmware CI feature runner GitHub action for AWS | ||
|
||
[![GitHub Actions](https://github.com/bifravst/firmware-ci-feature-runner-action-aws/workflows/Test%20and%20Release/badge.svg)](https://github.com/bifravst/firmware-ci-feature-runner-action-aws/actions) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/bifravst/firmware-ci-feature-runner-action-aws/badge.svg)](https://snyk.io/test/github/bifravst/firmware-ci-feature-runner-action-aws) | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
[![Renovate](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com) | ||
[![Mergify Status](https://img.shields.io/endpoint.svg?url=https://dashboard.mergify.io/badges/bifravst/firmware-ci-feature-runner-action-aws&style=flat)](https://mergify.io) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier/) | ||
[![ESLint: TypeScript](https://img.shields.io/badge/ESLint-TypeScript-blue.svg)](https://github.com/typescript-eslint/typescript-eslint) | ||
|
||
Uses | ||
[`@bifravst/e2e-bdd-test-runner`](https://github.com/bifravst/e2e-bdd-test-runner) | ||
to run features files of a firmware. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: "Firmware CI feature runner" | ||
description: | ||
"Uses @bifravst/e2e-bdd-test-runner to run features files of a firmware." | ||
inputs: | ||
job id: | ||
description: "The ID of the job" | ||
required: true | ||
app version: | ||
description: | ||
"The version string to use for the app. This is used with the FOTA test." | ||
required: true | ||
aws access key id: | ||
description: "Access Key ID for the Firmware CI Runner" | ||
required: true | ||
aws secret access key: | ||
description: "Secret Access Key for the Firmware CI Runner" | ||
required: true | ||
aws region: | ||
description: "AWS region to use" | ||
required: false | ||
default: us-west-1 | ||
broker hostname: | ||
description: "AWS IoT broker hostname to use" | ||
required: true | ||
stack name: | ||
description: "Stack name of the cloud backend to use" | ||
required: false | ||
default: bifravst | ||
feature dir: | ||
description: "Location of the feature files" | ||
required: false | ||
default: features | ||
|
||
runs: | ||
using: "node12" | ||
main: "build/index.js" |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = { extends: ["@commitlint/config-angular"] }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { deviceFileLocations } from '@bifravst/aws' | ||
import { promises as fs } from 'fs' | ||
import * as chalk from 'chalk' | ||
import { IoTClient, GetJobDocumentCommand } from '@aws-sdk/client-iot' | ||
|
||
export const downloadDeviceCredentials = async ({ | ||
certsDir, | ||
deviceId, | ||
iot, | ||
brokerHostname, | ||
}: { | ||
certsDir: string | ||
deviceId: string | ||
iot: IoTClient | ||
brokerHostname: string | ||
}): Promise<void> => { | ||
const deviceFiles = deviceFileLocations({ | ||
certsDir, | ||
deviceId, | ||
}) | ||
console.log( | ||
chalk.magenta('Checking device credentials...'), | ||
chalk.blueBright(deviceFiles.json), | ||
) | ||
try { | ||
await fs.stat(deviceFiles.json) | ||
console.log(chalk.green('Device credentials exist locally')) | ||
return | ||
} catch { | ||
console.log(chalk.red('Device credentials do not exist locally.')) | ||
console.log(chalk.magenta('Downloading from job...')) | ||
|
||
const { document } = await iot.send( | ||
new GetJobDocumentCommand({ | ||
jobId: deviceId, | ||
}), | ||
) | ||
|
||
const d = JSON.parse(document as string) | ||
|
||
await fs.writeFile( | ||
deviceFiles.json, | ||
JSON.stringify( | ||
{ | ||
...d.credentials, | ||
clientId: deviceId, | ||
brokerHostname, | ||
}, | ||
null, | ||
2, | ||
), | ||
'utf-8', | ||
) | ||
console.log(chalk.green('Written device credentials')) | ||
} | ||
} |
Oops, something went wrong.