cloudcomponents.cdk-pull-request-check


Namecloudcomponents.cdk-pull-request-check JSON
Version 2.3.0 PyPI version JSON
download
home_pagehttps://github.com/cloudcomponents/cdk-constructs
SummaryCdk component that automatically check pull requests
upload_time2024-04-17 18:36:21
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/b9/94/082bf0b9c28a64c2dd715b63abbe323d56c578995386c0ddbff29c3afef1/cloudcomponents.cdk-pull-request-check-2.3.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.3.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": "d0844ffb4f12a21f5bab3bc4e0c451667512c8d9eddd77367d9a941f9284205d",
                "md5": "cd7f713f82e1b78f9a0cc631042edcf3",
                "sha256": "7324ed3ac3479ea08807515cd5a3e7b79c64d19e780449081b2bf7dc4677a91c"
            },
            "downloads": -1,
            "filename": "cloudcomponents.cdk_pull_request_check-2.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cd7f713f82e1b78f9a0cc631042edcf3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 1295455,
            "upload_time": "2024-04-17T18:36:09",
            "upload_time_iso_8601": "2024-04-17T18:36:09.077836Z",
            "url": "https://files.pythonhosted.org/packages/d0/84/4ffb4f12a21f5bab3bc4e0c451667512c8d9eddd77367d9a941f9284205d/cloudcomponents.cdk_pull_request_check-2.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b994082bf0b9c28a64c2dd715b63abbe323d56c578995386c0ddbff29c3afef1",
                "md5": "bf7a42d893c6a5aeafec4c71235a78c7",
                "sha256": "8e94f88e871734a885c1988d6d181e6ceb7408c2f06aa57d9acec7a29bd6a495"
            },
            "downloads": -1,
            "filename": "cloudcomponents.cdk-pull-request-check-2.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bf7a42d893c6a5aeafec4c71235a78c7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 1297113,
            "upload_time": "2024-04-17T18:36:21",
            "upload_time_iso_8601": "2024-04-17T18:36:21.212000Z",
            "url": "https://files.pythonhosted.org/packages/b9/94/082bf0b9c28a64c2dd715b63abbe323d56c578995386c0ddbff29c3afef1/cloudcomponents.cdk-pull-request-check-2.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 18:36:21",
    "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: 0.21045s