Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit 322c91a

Browse files
authored
Pre-commit + CodeBuild CI Job Setup (#1)
* Pre-commit + CodeBuild CI Job Setup
1 parent 6c5c0c6 commit 322c91a

File tree

6 files changed

+189
-5
lines changed

6 files changed

+189
-5
lines changed

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Compiled class file
2+
*.class
3+
4+
# Log file
5+
*.log
6+
7+
# BlueJ files
8+
*.ctxt
9+
10+
# Mobile Tools for Java (J2ME)
11+
.mtj.tmp/
12+
13+
# Package Files #
14+
*.jar
15+
*.war
16+
*.nar
17+
*.ear
18+
*.zip
19+
*.tar.gz
20+
*.rar
21+
22+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23+
hs_err_pid*
24+
25+
# IDE configurations
26+
*.iml
27+
.vscode/
28+
29+
# Build
30+
target/
31+
32+
# Generated Files
33+
.classpath
34+
.factorypath
35+
.project
36+
.settings/

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.0.0
4+
hooks:
5+
- id: check-case-conflict
6+
- id: detect-private-key
7+
- id: end-of-file-fixer
8+
- id: mixed-line-ending
9+
args:
10+
- --fix=lf
11+
- id: trailing-whitespace
12+
- id: pretty-format-json
13+
args:
14+
- --autofix
15+
- --indent=4
16+
- --no-sort-keys
17+
- id: check-merge-conflict

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
aws-cloudformation-resource-providers-redshift
2-
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.

README.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,41 @@
1-
## aws-cloudformation-resource-providers-redshift
1+
## AWS CloudFormation Resource Provider Package For AWS Redshift
22

3-
The CloudFormation Resource Provider Package For Amazon Redshift
3+
This repository contains AWS-owned resource providers for the `AWS::Redshift::*` namespace.
44

5-
## License
5+
Usage
6+
-----
67

7-
This library is licensed under the Apache 2.0 License.
8+
The CloudFormation CLI (cfn) allows you to author your own resource providers that can be used by CloudFormation.
9+
10+
Refer to the documentation for the [CloudFormation CLI](https://github.com/aws-cloudformation/aws-cloudformation-rpdk) for usage instructions.
11+
12+
13+
Development
14+
-----------
15+
16+
First, you will need to install the [CloudFormation CLI](https://github.com/aws-cloudformation/aws-cloudformation-rpdk), as it is a required dependency:
17+
18+
```shell
19+
pip3 install cloudformation-cli
20+
pip3 install cloudformation-cli-java-plugin
21+
```
22+
23+
Linting and running unit tests is done via [pre-commit](https://pre-commit.com/), and so is performed automatically on commit. The continuous integration also runs these checks.
24+
25+
```shell
26+
pre-commit install
27+
```
28+
29+
Manual options are available so you don't have to commit:
30+
31+
```shell
32+
# run all hooks on all files, mirrors what the CI runs
33+
pre-commit run --all-files
34+
# run unit tests and coverage checks
35+
mvn verify
36+
```
37+
38+
License
39+
-------
40+
41+
This library is licensed under the Apache 2.0 License.

buildspec.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 0.2
2+
phases:
3+
install:
4+
runtime-versions:
5+
java: openjdk8
6+
python: 3.7
7+
commands:
8+
pip install pre-commit
9+
build:
10+
commands:
11+
# pre-build check for commit hooks
12+
- pre-commit run --all-files
13+
# install cloudformation-cli dependencies
14+
- pip install cloudformation-cli cloudformation-cli-java-plugin

codebuild-ci.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
Description: Manage GitHub Continuous Integration and Release processes
3+
4+
Parameters:
5+
GitHubRepositoryName:
6+
Type: String
7+
Description: GitHub Repo Name For aws-cloudformation-resource-providers-redshift
8+
GitHubRepositoryShortName:
9+
Type: String
10+
Description: Short Name for this provider to avoid exceeding the 64char limit on IAM Resources
11+
CFNSDKBucket:
12+
Type: String
13+
Description: S3 Location of CloudFormation SDK; should be removed when we can publish the latest client
14+
15+
Resources:
16+
AWSCloudFormationResourceProviderCIPolicy:
17+
Type: AWS::IAM::ManagedPolicy
18+
Properties:
19+
ManagedPolicyName: !Sub "codebuild-${GitHubRepositoryName}-ci-policy"
20+
Path: /service-role/
21+
PolicyDocument:
22+
Version: "2012-10-17"
23+
Statement:
24+
- Effect: Allow
25+
Action:
26+
- logs:CreateLogGroup
27+
- logs:CreateLogStream
28+
- logs:PutLogEvents
29+
Resource:
30+
- !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/${GitHubRepositoryName}-ci"
31+
- !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/${GitHubRepositoryName}-ci:*"
32+
- Effect: Allow
33+
Action:
34+
- s3:PutObject
35+
- s3:GetObject
36+
- s3:GetObjectVersion
37+
Resource: !Sub "${CFNSDKBucket}/*"
38+
- Effect: Allow
39+
Action:
40+
- s3:ListBucket
41+
Resource: !Ref CFNSDKBucket
42+
43+
AWSCloudFormationResourceProviderCIRole:
44+
Type: AWS::IAM::Role
45+
Properties:
46+
RoleName: !Sub "codebuild-${GitHubRepositoryShortName}-ci"
47+
AssumeRolePolicyDocument:
48+
Version: "2012-10-17"
49+
Statement:
50+
- Effect: Allow
51+
Principal:
52+
Service: codebuild.amazonaws.com
53+
Action: sts:AssumeRole
54+
Path: /service-role/
55+
ManagedPolicyArns:
56+
- !Ref AWSCloudFormationResourceProviderCIPolicy
57+
58+
AWSCloudFormationResourceProviderCIProject:
59+
Type: AWS::CodeBuild::Project
60+
Properties:
61+
Name: !Sub "${GitHubRepositoryName}-ci"
62+
Description: !Sub "https://github.com/aws-cloudformation/${GitHubRepositoryName}/"
63+
BadgeEnabled: true
64+
TimeoutInMinutes: 30
65+
Artifacts:
66+
Type: NO_ARTIFACTS
67+
Environment:
68+
Type: LINUX_CONTAINER
69+
ComputeType: BUILD_GENERAL1_SMALL
70+
Image: aws/codebuild/standard:2.0
71+
PrivilegedMode: false
72+
Source:
73+
Type: GITHUB
74+
Auth:
75+
Type: OAUTH
76+
InsecureSsl: false
77+
Location: !Sub "https://github.com/aws-cloudformation/${GitHubRepositoryName}.git"
78+
ReportBuildStatus: true
79+
GitCloneDepth: 1
80+
BuildSpec: buildspec.yml
81+
ServiceRole: !GetAtt AWSCloudFormationResourceProviderCIRole.Arn
82+
Triggers:
83+
Webhook: true

0 commit comments

Comments
 (0)