项目作者: redbadger

项目描述 :
CircleCI stats reporter
高级语言: JavaScript
项目地址: git://github.com/redbadger/square-the-circle.git
创建时间: 2017-03-02T16:36:55Z
项目社区:https://github.com/redbadger/square-the-circle

开源协议:

下载


Square the circle

This is a CircleCI builds statistics serverless lambda that runs on AWS. The report is sent out periodically to your chosen Slack channel.

At the moment we derive from CircleCI API the following stats:

  • Percentage of failed builds
  • Number of code deployments
  • Average Build time

Number of code deployments

To distinguish deployments from usual builds the script checks CircleCI build_parameters which can be set in your deployment script. build_parameters should containt PRODUCTION flag set to true.

  1. build_parameters: { PRODUCTION: 'true' }

Configuration

Make sure your AWS credentials are properly configured on your machine. For more information head to this page.

Copy src/config.example.js to src/config.js

  1. cp src/config.example.js src/config.js

Edit src/config.js and set your config variables

  1. config.circleCItoken = '123abc';
  2. config.slackEndpoint = 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX';
  3. config.organisationName = 'redbadger'; // Github account name
  4. config.projectName = 'website-honestly'; // Github repo name
  5. config.timeSpan = 7; // Report time span. 7 means weekly

CircleCI token can be obtained here.
For Slack webook endpoint head to this page

By default the report is scheduled every week on Monday at 9:00 am. If you want to change it you should head to serverless.yml file. The schedule is configured in AWS cron format.

  1. functions:
  2. stats:
  3. handler: dist/index.handler
  4. events:
  5. - schedule: cron(0 9 ? * 2 *)

Setup

Run:

  1. npm install
  2. npm run deploy

The expected result should be similar to:

  1. src/config.js -> dist/config.js
  2. src/getStats.js -> dist/getStats.js
  3. src/index.js -> dist/index.js
  4. Serverless: Packaging service...
  5. Serverless: Uploading CloudFormation file to S3...
  6. Serverless: Uploading service .zip file to S3 (14.24 MB)...
  7. Serverless: Updating Stack...
  8. Serverless: Checking Stack update progress...
  9. .........
  10. Serverless: Stack update finished...
  11. Serverless: Removing old service versions...
  12. Service Information
  13. service: square-the-circle
  14. stage: dev
  15. region: us-east-1
  16. api keys:
  17. None
  18. endpoints:
  19. None
  20. functions:
  21. stats: square-the-circle-dev-stats

After that your new scheduled lambda is ready.