cloudcomponents.cdk-pull-request-check


Namecloudcomponents.cdk-pull-request-check JSON
Version 2.4.0 PyPI version JSON
download
home_pagehttps://github.com/cloudcomponents/cdk-constructs
SummaryCdk component that automatically check pull requests
upload_time2024-05-16 19:33:28
maintainerNone
docs_urlNone
authorhupe1980
requires_python~=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![cloudcomponents Logo](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/logo.png)](https://github.com/cloudcomponents/cdk-constructs)

# @cloudcomponents/cdk-pull-request-check

[![Build Status](https://github.com/cloudcomponents/cdk-constructs/workflows/Build/badge.svg)](https://github.com/cloudcomponents/cdk-constructs/actions?query=workflow=Build)
[![cdkdx](https://img.shields.io/badge/buildtool-cdkdx-blue.svg)](https://github.com/hupe1980/cdkdx)
[![typescript](https://img.shields.io/badge/jsii-typescript-blueviolet.svg)](https://www.npmjs.com/package/@cloudcomponents/cdk-pull-request-check)
[![python](https://img.shields.io/badge/jsii-python-blueviolet.svg)](https://pypi.org/project/cloudcomponents.cdk-pull-request-check/)
[![Mentioned in Awesome CDK](https://awesome.re/mentioned-badge.svg)](https://github.com/kolomied/awesome-cdk)

> Cdk component that automatically check pull requests

## Install

TypeScript/JavaScript:

```bash
npm install --save @cloudcomponents/cdk-pull-request-check
```

Python:

```bash
pip install cloudcomponents.cdk-pull-request-check
```

## How to use

```python
import { PullRequestCheck } from '@cloudcomponents/cdk-pull-request-check';
import { Stack, StackProps } from 'aws-cdk-lib';
import { BuildSpec } from 'aws-cdk-lib/aws-codebuild';
import { Repository } from 'aws-cdk-lib/aws-codecommit';
import { Construct } from 'constructs';

export class CodePipelineStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const repository = new Repository(this, 'Repository', {
      repositoryName: 'MyRepositoryName',
    });

    // CodePipeline etc.

    new PullRequestCheck(this, 'PullRequestCheck', {
      repository,
      buildSpec: BuildSpec.fromSourceFilename('prcheck.yml'),
    });
  }
}
```

## Approval Template Rules

```python
import { ApprovalRuleTemplate, ApprovalRuleTemplateRepositoryAssociation } from '@cloudcomponents/cdk-pull-request-approval-rule';
import { PullRequestCheck } from '@cloudcomponents/cdk-pull-request-check';
import { Stack, StackProps } from 'aws-cdk-lib';
import { BuildSpec } from 'aws-cdk-lib/aws-codebuild';
import { Repository } from 'aws-cdk-lib/aws-codecommit';
import { Construct } from 'constructs';

export class PullRequestStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const repository = new Repository(this, 'Repository', {
      repositoryName: 'pr-check-repository',
    });

    const { approvalRuleTemplateName } = new ApprovalRuleTemplate(this, 'ApprovalRuleTemplate', {
      approvalRuleTemplateName: 'template-name',
      template: {
        approvers: {
          numberOfApprovalsNeeded: 1,
        },
      },
    });

    new ApprovalRuleTemplateRepositoryAssociation(this, 'ApprovalRuleTemplateRepositoryAssociation', {
      approvalRuleTemplateName,
      repository,
    });

    new PullRequestCheck(this, 'PullRequestCheck', {
      repository,
      buildSpec: BuildSpec.fromSourceFilename('prcheck.yml'),
    });
  }
}
```

## Custom notifications

The component comments the pull request and sets the approval state by default. Custom notifications can be set up this way

```python
import { PullRequestCheck } from '@cloudcomponents/cdk-pull-request-check';
import { Stack, StackProps } from 'aws-cdk-lib';
import { BuildSpec } from 'aws-cdk-lib/aws-codebuild';
import { Repository } from 'aws-cdk-lib/aws-codecommit';
import { SnsTopic } from 'aws-cdk-lib/aws-events-targets';
import { Topic } from 'aws-cdk-lib/aws-sns';
import { EmailSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';
import { Construct } from 'constructs';

export class CodePipelineStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const repository = new Repository(this, 'Repository', {
      repositoryName: 'MyRepositoryName',
      description: 'Some description.', // optional property
    });

    // Your CodePipeline...

    const prCheck = new PullRequestCheck(this, 'PullRequestCheck', {
      repository,
      buildSpec: BuildSpec.fromSourceFilename('buildspecs/prcheck.yml'),
    });

    const prTopic = new Topic(this, 'PullRequestTopic');

    prTopic.addSubscription(
      new EmailSubscription(process.env.DEVSECOPS_TEAM_EMAIL as string),
    );

    prCheck.onCheckStarted('started', {
      target: new SnsTopic(prTopic),
    });

    prCheck.onCheckSucceeded('succeeded', {
      target: new SnsTopic(prTopic),
    });

    prCheck.onCheckFailed('failed', {
      target: new SnsTopic(prTopic),
    });
  }
}
```

## API Reference

See [API.md](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-pull-request-check/API.md).

## Example

See more complete [examples](https://github.com/cloudcomponents/cdk-constructs/tree/master/examples).

## License

[MIT](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-pull-request-check/LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cloudcomponents/cdk-constructs",
    "name": "cloudcomponents.cdk-pull-request-check",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "hupe1980",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/2a/62/cdb52751df4ade64bcbbfef63492132a05251738a8ae7dbcb8c135dc45bb/cloudcomponents.cdk-pull-request-check-2.4.0.tar.gz",
    "platform": null,
    "description": "[![cloudcomponents Logo](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/logo.png)](https://github.com/cloudcomponents/cdk-constructs)\n\n# @cloudcomponents/cdk-pull-request-check\n\n[![Build Status](https://github.com/cloudcomponents/cdk-constructs/workflows/Build/badge.svg)](https://github.com/cloudcomponents/cdk-constructs/actions?query=workflow=Build)\n[![cdkdx](https://img.shields.io/badge/buildtool-cdkdx-blue.svg)](https://github.com/hupe1980/cdkdx)\n[![typescript](https://img.shields.io/badge/jsii-typescript-blueviolet.svg)](https://www.npmjs.com/package/@cloudcomponents/cdk-pull-request-check)\n[![python](https://img.shields.io/badge/jsii-python-blueviolet.svg)](https://pypi.org/project/cloudcomponents.cdk-pull-request-check/)\n[![Mentioned in Awesome CDK](https://awesome.re/mentioned-badge.svg)](https://github.com/kolomied/awesome-cdk)\n\n> Cdk component that automatically check pull requests\n\n## Install\n\nTypeScript/JavaScript:\n\n```bash\nnpm install --save @cloudcomponents/cdk-pull-request-check\n```\n\nPython:\n\n```bash\npip install cloudcomponents.cdk-pull-request-check\n```\n\n## How to use\n\n```python\nimport { PullRequestCheck } from '@cloudcomponents/cdk-pull-request-check';\nimport { Stack, StackProps } from 'aws-cdk-lib';\nimport { BuildSpec } from 'aws-cdk-lib/aws-codebuild';\nimport { Repository } from 'aws-cdk-lib/aws-codecommit';\nimport { Construct } from 'constructs';\n\nexport class CodePipelineStack extends Stack {\n  constructor(scope: Construct, id: string, props?: StackProps) {\n    super(scope, id, props);\n\n    const repository = new Repository(this, 'Repository', {\n      repositoryName: 'MyRepositoryName',\n    });\n\n    // CodePipeline etc.\n\n    new PullRequestCheck(this, 'PullRequestCheck', {\n      repository,\n      buildSpec: BuildSpec.fromSourceFilename('prcheck.yml'),\n    });\n  }\n}\n```\n\n## Approval Template Rules\n\n```python\nimport { ApprovalRuleTemplate, ApprovalRuleTemplateRepositoryAssociation } from '@cloudcomponents/cdk-pull-request-approval-rule';\nimport { PullRequestCheck } from '@cloudcomponents/cdk-pull-request-check';\nimport { Stack, StackProps } from 'aws-cdk-lib';\nimport { BuildSpec } from 'aws-cdk-lib/aws-codebuild';\nimport { Repository } from 'aws-cdk-lib/aws-codecommit';\nimport { Construct } from 'constructs';\n\nexport class PullRequestStack extends Stack {\n  constructor(scope: Construct, id: string, props?: StackProps) {\n    super(scope, id, props);\n\n    const repository = new Repository(this, 'Repository', {\n      repositoryName: 'pr-check-repository',\n    });\n\n    const { approvalRuleTemplateName } = new ApprovalRuleTemplate(this, 'ApprovalRuleTemplate', {\n      approvalRuleTemplateName: 'template-name',\n      template: {\n        approvers: {\n          numberOfApprovalsNeeded: 1,\n        },\n      },\n    });\n\n    new ApprovalRuleTemplateRepositoryAssociation(this, 'ApprovalRuleTemplateRepositoryAssociation', {\n      approvalRuleTemplateName,\n      repository,\n    });\n\n    new PullRequestCheck(this, 'PullRequestCheck', {\n      repository,\n      buildSpec: BuildSpec.fromSourceFilename('prcheck.yml'),\n    });\n  }\n}\n```\n\n## Custom notifications\n\nThe component comments the pull request and sets the approval state by default. Custom notifications can be set up this way\n\n```python\nimport { PullRequestCheck } from '@cloudcomponents/cdk-pull-request-check';\nimport { Stack, StackProps } from 'aws-cdk-lib';\nimport { BuildSpec } from 'aws-cdk-lib/aws-codebuild';\nimport { Repository } from 'aws-cdk-lib/aws-codecommit';\nimport { SnsTopic } from 'aws-cdk-lib/aws-events-targets';\nimport { Topic } from 'aws-cdk-lib/aws-sns';\nimport { EmailSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';\nimport { Construct } from 'constructs';\n\nexport class CodePipelineStack extends Stack {\n  constructor(scope: Construct, id: string, props?: StackProps) {\n    super(scope, id, props);\n\n    const repository = new Repository(this, 'Repository', {\n      repositoryName: 'MyRepositoryName',\n      description: 'Some description.', // optional property\n    });\n\n    // Your CodePipeline...\n\n    const prCheck = new PullRequestCheck(this, 'PullRequestCheck', {\n      repository,\n      buildSpec: BuildSpec.fromSourceFilename('buildspecs/prcheck.yml'),\n    });\n\n    const prTopic = new Topic(this, 'PullRequestTopic');\n\n    prTopic.addSubscription(\n      new EmailSubscription(process.env.DEVSECOPS_TEAM_EMAIL as string),\n    );\n\n    prCheck.onCheckStarted('started', {\n      target: new SnsTopic(prTopic),\n    });\n\n    prCheck.onCheckSucceeded('succeeded', {\n      target: new SnsTopic(prTopic),\n    });\n\n    prCheck.onCheckFailed('failed', {\n      target: new SnsTopic(prTopic),\n    });\n  }\n}\n```\n\n## API Reference\n\nSee [API.md](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-pull-request-check/API.md).\n\n## Example\n\nSee more complete [examples](https://github.com/cloudcomponents/cdk-constructs/tree/master/examples).\n\n## License\n\n[MIT](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-pull-request-check/LICENSE)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Cdk component that automatically check pull requests",
    "version": "2.4.0",
    "project_urls": {
        "Homepage": "https://github.com/cloudcomponents/cdk-constructs",
        "Source": "https://github.com/cloudcomponents/cdk-constructs.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "74a62453bd72c8736eb452bf8f68f3b2dfcb6411d5c4e230309967e79d7cc4ea",
                "md5": "4f455f09a7bb2febbdc92f8f0292e8b5",
                "sha256": "b974df0382d823dd2a4e15313765f1a8b375ba8fc3dc9f2f2dfddd4bde1df3e3"
            },
            "downloads": -1,
            "filename": "cloudcomponents.cdk_pull_request_check-2.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4f455f09a7bb2febbdc92f8f0292e8b5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 95709,
            "upload_time": "2024-05-16T19:33:05",
            "upload_time_iso_8601": "2024-05-16T19:33:05.207483Z",
            "url": "https://files.pythonhosted.org/packages/74/a6/2453bd72c8736eb452bf8f68f3b2dfcb6411d5c4e230309967e79d7cc4ea/cloudcomponents.cdk_pull_request_check-2.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a62cdb52751df4ade64bcbbfef63492132a05251738a8ae7dbcb8c135dc45bb",
                "md5": "be6696fccdc01552c0d9a1547df3cd15",
                "sha256": "87e126fb80e06f9b85b95fdf233932a35f0679a2f5bc2648ab50efcba757a121"
            },
            "downloads": -1,
            "filename": "cloudcomponents.cdk-pull-request-check-2.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "be6696fccdc01552c0d9a1547df3cd15",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 97418,
            "upload_time": "2024-05-16T19:33:28",
            "upload_time_iso_8601": "2024-05-16T19:33:28.154222Z",
            "url": "https://files.pythonhosted.org/packages/2a/62/cdb52751df4ade64bcbbfef63492132a05251738a8ae7dbcb8c135dc45bb/cloudcomponents.cdk-pull-request-check-2.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-16 19:33:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cloudcomponents",
    "github_project": "cdk-constructs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cloudcomponents.cdk-pull-request-check"
}
        
Elapsed time: 4.11666s