Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #158 from ACloudGuru/add-github-actions
Browse files Browse the repository at this point in the history
Add GitHub actions
  • Loading branch information
adikari authored Feb 10, 2021
2 parents eda857c + 39d3d71 commit 1201511
Show file tree
Hide file tree
Showing 39 changed files with 3,229 additions and 1,505 deletions.
2 changes: 2 additions & 0 deletions .commitlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extends:
- '@commitlint/config-conventional'
38 changes: 38 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
extends:
- airbnb-base
- prettier
- plugin:import/errors
- plugin:import/warnings
- plugin:jest/recommended

globals:
Atomics: readonly
SharedArrayBuffer: readonly

parserOptions:
ecmaVersion: 2020
sourceType: module

plugins:
- jest
- prettier

rules: {
"prettier/prettier": "error",
"import/prefer-default-export": 0,
"jest/no-focused-tests": 0,

# eventually want to remove everything below this
"class-methods-use-this": 0,
"prefer-object-spread": 0,
"prefer-destructuring": 0,
"no-return-assign": 0,
"array-callback-return": 0,
"global-require": 0,
"consistent-return": 0,
"no-param-reassign": 0,
"no-underscore-dangle": 0,
"no-plusplus": 0,
"guard-for-in": 0,
"no-restricted-syntax": 0
}
17 changes: 0 additions & 17 deletions .eslintrc.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2

- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install packages
run: yarn install --frozen-lockfile

- name: Run lint
run: yarn lint

- name: Run tests
run: yarn test

- name: Generate code coverage
uses: codecov/codecov-action@v1
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish

on:
push:
branches:
- master

jobs:
publish:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use node 14.x
uses: actions/setup-node@v1
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'

- name: Install packages
run: yarn install --frozen-lockfile

- name: Publish to npm
run: yarn release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit.
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 2,
"printWidth": 80,
"singleQuote": true
}
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Dependency Status][daviddm-image]][daviddm-url]
[![Coverage percentage][coveralls-image]][coveralls-url]
[![codecov][codecov-image]][codecov-url]

A Serverless plugin to easily add CloudWatch alarms to functions

## Installation
`npm i serverless-plugin-aws-alerts`
OR
`yarn add --dev serverless-plugin-aws-alerts`

## Usage

Expand Down Expand Up @@ -187,7 +189,7 @@ custom:
#### CloudFormation support

```yaml
custom:
custom:
alerts:
topics:
alarm:
Expand All @@ -204,7 +206,6 @@ custom:
insufficientData:
topic:
Ref: ExampleInsufficientdataTopic
resources:
Resources:
Expand Down Expand Up @@ -473,5 +474,5 @@ MIT © [A Cloud Guru](https://acloud.guru/)
[travis-url]: https://travis-ci.org/ACloudGuru/serverless-plugin-aws-alerts
[daviddm-image]: https://david-dm.org/ACloudGuru/serverless-plugin-aws-alerts.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/ACloudGuru/serverless-plugin-aws-alerts
[coveralls-image]: https://coveralls.io/repos/ACloudGuru/serverless-plugin-aws-alerts/badge.svg
[coveralls-url]: https://coveralls.io/r/ACloudGuru/serverless-plugin-aws-alerts
[codecov-image]: https://codecov.io/gh/ACloudGuru/serverless-plugin-aws-alerts/branch/master/graph/badge.svg?token=uC4maLoz3W
[codecov-url]: https://codecov.io/gh/ACloudGuru/serverless-plugin-aws-alerts
15 changes: 15 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
coverage:
status:
project:
default:
target: auto
threshold: null

comment:
layout: "reach, diff, flags, files"
behavior: default
require_changes: false
require_base: no
require_head: yes
branches:
- master
5 changes: 1 addition & 4 deletions example/error.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
exports.handler = (event, context, cb) => {
console.log('Received event', event);
console.log('Blah');

exports.handler = (_, __, cb) => {
cb(new Error('This is an error'));
};
6 changes: 2 additions & 4 deletions example/foo.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
exports.handler = async (event) => {
console.log('Received event', event);

exports.handler = async () => {
const response = {
statusCode: 200,
body: JSON.stringify({ message: `success - ${Date.now()}` })
body: JSON.stringify({ message: `success - ${Date.now()}` }),
};

return response;
Expand Down
8 changes: 2 additions & 6 deletions example/slow.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
exports.handler = (event, context, cb) => {
console.log('Received event', event);
console.log('Sleeping');

exports.handler = (_, __, cb) => {
setTimeout(() => {
console.log('Awake');
cb(null, { message: 'success' });
}, 10000);
}
};
32 changes: 20 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,39 @@
"lint": "eslint .",
"lint-fix": "eslint . --fix",
"test": "jest --coverage",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"postinstall": "husky install",
"prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable"
},
"repository": {
"url": "https://github.com/ACloudGuru/serverless-plugin-aws-alerts.git",
"type": "git"
},
"author": "John McKim <[email protected]>",
"license": "MIT",
"peerDependencies": {
"serverless": "^2.4.0"
},
"dependencies": {
"lodash": "^4.17.10"
},
"devDependencies": {
"coveralls": "^2.11.16",
"eslint": "^4.7.1",
"eslint-config-standard": "^6.2.0",
"eslint-plugin-node": "^4.0.0",
"eslint-plugin-promise": "^3.4.1",
"eslint-plugin-standard": "^2.0.1",
"jest": "^19.0.2"
"@commitlint/config-conventional": "^11.0.0",
"commitlint": "^11.0.0",
"eslint": "^7.19.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-prettier": "^3.3.1",
"husky": "^5.0.9",
"jest": "^19.0.2",
"pinst": "^2.1.4",
"prettier": "^2.2.1"
},
"peerDependencies": {
"serverless": "^2.4.0"
},
"engines": {
"node": ">=6.10.0"
"node": ">=8.10.0"
},
"jest": {
"testMatch": [
Expand Down
8 changes: 3 additions & 5 deletions src/dashboards/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use strict';

const widgetFactory = require('./widgets/factory');

const dashboards = {
'default': require('./configs/default'),
'vertical': require('./configs/vertical'),
default: require('./configs/default'),
vertical: require('./configs/vertical'),
};

const createDashboard = (service, stage, region, functions, name) => {
Expand All @@ -22,7 +20,7 @@ const createDashboard = (service, stage, region, functions, name) => {
region,
coordinates: w.coordinates,
title: w.title,
functions
functions,
};

return widget.createWidget(config);
Expand Down
32 changes: 26 additions & 6 deletions src/dashboards/widgets/api-gw/latency/numbers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const createWidget = (config) => {
const apiName = `${config.stage}-${config.service}`;

Expand All @@ -13,12 +11,34 @@ const createWidget = (config) => {
title: config.title,
view: 'singleValue',
metrics: [
[ 'AWS/ApiGateway', 'IntegrationLatency', 'ApiName', apiName, { stat: 'Average', period: 2592000, region: config.region, label: 'IntegrationLatency' } ],
[ 'AWS/ApiGateway', 'Latency', 'ApiName', apiName, { stat: 'Average', period: 2592000, region: config.region, label: 'Latency' } ]
[
'AWS/ApiGateway',
'IntegrationLatency',
'ApiName',
apiName,
{
stat: 'Average',
period: 2592000,
region: config.region,
label: 'IntegrationLatency',
},
],
[
'AWS/ApiGateway',
'Latency',
'ApiName',
apiName,
{
stat: 'Average',
period: 2592000,
region: config.region,
label: 'Latency',
},
],
],
region: config.region,
period: 300
}
period: 300,
},
};

return widget;
Expand Down
Loading

0 comments on commit 1201511

Please sign in to comment.