Skip to content

Commit 5a99e07

Browse files
authored
Added docs and examples (#2)
* Added docs and fixed typos * Added CICD for the docs * Added source from SecretsManager and examples
1 parent cc52ece commit 5a99e07

31 files changed

+1212
-116
lines changed

.cicd/buildspec.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,17 @@ phases:
7272
docker push ${PUBLIC_REGISTRY}/ecs-files-composer:${ARCH_TAG}
7373
done
7474
- |
75-
docker manifest create ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION} \
76-
--amend ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION}-amd64 \
75+
docker manifest create ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION} \
76+
--amend ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION}-amd64 \
7777
--amend ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION}-arm64v8
7878
- docker manifest push ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION}
79+
- |
80+
if [ "${PRE}" == "tag" ]; then
81+
docker manifest create ${PUBLIC_REGISTRY}/ecs-files-composer:latest \
82+
--amend ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION}-amd64 \
83+
--amend ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION}-arm64v8;
84+
docker manifest push ${PUBLIC_REGISTRY}/ecs-files-composer:latest
85+
fi
7986
8087
finally:
8188
- rm -rfv ~/.docker

.cicd/buildspec_docs.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
version: 0.2
3+
env:
4+
shell: /bin/bash
5+
variables:
6+
USE_EPOCH: 0
7+
8+
phases:
9+
install:
10+
runtime-versions:
11+
python: "$(echo $PY_VERSION)"
12+
commands:
13+
- if [ -z ${AWS_ACCOUNT_ID+x} ]; then AWS_ACCOUNT_ID=$(aws sts get-caller-identity | jq -r .Account); fi
14+
- if ! [ -z ${CODEBUILD_RESOLVED_SOURCE_VERSION+x} ]; then COMMIT_HASH=${CODEBUILD_RESOLVED_SOURCE_VERSION::7}; fi
15+
- EPOCH=`date +'%Y%m%d'`
16+
- VERSION=${COMMIT_HASH:=$EPOCH}
17+
- if [ $USE_EPOCH -eq 1 ]; then VERSION=$EPOCH; fi
18+
- |
19+
if ! [ -z "${CODEBUILD_WEBHOOK_TRIGGER+x}" ]; then
20+
echo TRIGGER is $CODEBUILD_WEBHOOK_TRIGGER
21+
PRE=`echo $CODEBUILD_WEBHOOK_TRIGGER|cut -d '/' -f 1`;
22+
echo PRE is $PRE
23+
echo VERSION is $VERSION
24+
if [ "${PRE}" == "tag" ]; then VERSION=`echo $CODEBUILD_WEBHOOK_TRIGGER|cut -d '/' -f 2`; TAG_RELEASE=1 ; fi
25+
fi
26+
- echo VERSION ends up being $VERSION
27+
- pip install -r requirements_dev.txt
28+
- pip install -r requirements.txt
29+
30+
build:
31+
commands:
32+
- make publish-docs
33+
- aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths "/*"

.cicd/codebuild_docs.yml

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
---
2+
Description: >-
3+
Pipeline to release Lambda layers publicly when new release is created
4+
5+
Metadata:
6+
Author: https://github.com/johnpreston
7+
8+
Parameters:
9+
RepositoryOrganization:
10+
Type: String
11+
Default: compose-x
12+
13+
RepositoryProvider:
14+
Type: String
15+
AllowedValues:
16+
- GitHub
17+
- CodeCommit
18+
Default: GitHub
19+
RepositoryName:
20+
Type: String
21+
22+
BuildLogsRetentionDays:
23+
Type: Number
24+
AllowedValues: [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653]
25+
Default: 14
26+
27+
ReferenceBranchName:
28+
Type: String
29+
Default: main
30+
31+
DocsBuildspecFile:
32+
Type: String
33+
Default: .cicd/buildspec_docs.yml
34+
35+
DocsBucketName:
36+
Type: String
37+
38+
CftDistributionId:
39+
Type: String
40+
41+
Mappings:
42+
RepoUrlPrefixes:
43+
GitHub:
44+
Prefix: https://github.com/
45+
46+
Conditions:
47+
UseGitHub: !Equals [ !Ref RepositoryProvider, 'GitHub']
48+
UseCodeCommit: !Equals [ !Ref RepositoryProvider, 'CodeCommit']
49+
50+
Resources:
51+
BuildLogsGroup:
52+
Type: AWS::Logs::LogGroup
53+
Properties:
54+
LogGroupName: !Sub 'codebuild/${RepositoryName}/${AWS::StackName}'
55+
RetentionInDays: !Ref BuildLogsRetentionDays
56+
CodeBuildRole:
57+
Type: AWS::IAM::Role
58+
Properties:
59+
AssumeRolePolicyDocument:
60+
Version: '2012-10-17'
61+
Statement:
62+
- Action:
63+
- sts:AssumeRole
64+
Effect: Allow
65+
Principal:
66+
Service:
67+
- !Sub 'codebuild.${AWS::URLSuffix}'
68+
Policies:
69+
- PolicyName: ContentAccess
70+
PolicyDocument:
71+
Version: '2012-10-17'
72+
Statement:
73+
- Sid: CloudFrontAccess
74+
Effect: Allow
75+
Action:
76+
- cloudfront:CreateInvalidation
77+
Resource:
78+
- !Sub 'arn:${AWS::Partition}:cloudfront::${AWS::AccountId}:distribution/${CftDistributionId}'
79+
- Sid: S3ObjectsAccess
80+
Effect: Allow
81+
Action:
82+
- s3:PutObject*
83+
- s3:GetObject*
84+
- s3:DeleteObject*
85+
Resource:
86+
- !Sub "arn:${AWS::Partition}:s3:::${DocsBucketName}/*"
87+
- Sid: S3BucketsAccess
88+
Effect: Allow
89+
Action:
90+
- s3:ListBucket
91+
Resource:
92+
- !Sub "arn:${AWS::Partition}:s3:::${DocsBucketName}"
93+
- Sid: CloudWatchLogs
94+
Effect: Allow
95+
Action:
96+
- logs:CreateLogStream
97+
- logs:PutLogEvents
98+
Resource:
99+
- !Sub '${BuildLogsGroup.Arn}'
100+
- Sid: CodeBuildReportsAccess
101+
Effect: Allow
102+
Resource:
103+
- !Sub 'arn:${AWS::Partition}:codebuild:${AWS::Region}:${AWS::AccountId}:report-group/*'
104+
Action:
105+
- codebuild:UpdateReportGroup
106+
- codebuild:CreateReportGroup
107+
- codebuild:CreateReport
108+
- codebuild:UpdateReport
109+
- codebuild:BatchPut*
110+
- Sid: CodeBuildBatch
111+
Effect: Allow
112+
Resource:
113+
- !Sub 'arn:${AWS::Partition}:codebuild:${AWS::Region}:${AWS::AccountId}:*'
114+
Action:
115+
- codebuild:StartBuild
116+
- codebuild:RetryBuild
117+
118+
119+
DocsImagesBuild:
120+
Type: AWS::CodeBuild::Project
121+
Properties:
122+
ServiceRole: !GetAtt 'CodeBuildRole.Arn'
123+
Description: !Sub 'Publishes ${RepositoryName} new documentation'
124+
LogsConfig:
125+
CloudWatchLogs:
126+
GroupName: !Ref BuildLogsGroup
127+
Status: ENABLED
128+
StreamName: docker-builds
129+
BadgeEnabled: True
130+
Artifacts:
131+
Type: NO_ARTIFACTS
132+
Environment:
133+
ComputeType: BUILD_GENERAL1_SMALL
134+
Image: aws/codebuild/standard:5.0
135+
Type: LINUX_CONTAINER
136+
EnvironmentVariables:
137+
- Name: PY_VERSION
138+
Type: PLAINTEXT
139+
Value: 3.8
140+
- Type: PLAINTEXT
141+
Name: DOCS_BUCKET
142+
Value: !Ref DocsBucketName
143+
- Type: PLAINTEXT
144+
Name: DISTRIBUTION_ID
145+
Value: !Ref CftDistributionId
146+
Source:
147+
Type: GITHUB
148+
ReportBuildStatus: True
149+
Location: !If
150+
- UseGitHub
151+
- !Sub 'https://github.com/${RepositoryOrganization}/${RepositoryName}'
152+
- !Sub 'https://codecommit.${AWS::Region}.${AWS::URLSuffix}'
153+
InsecureSsl: False
154+
BuildSpec: !Ref DocsBuildspecFile
155+
Triggers:
156+
Webhook: True
157+
# BuildType: BUILD_BATCH
158+
FilterGroups:
159+
- - Type: EVENT
160+
Pattern: "PUSH"
161+
ExcludeMatchedPattern: False
162+
- Type: HEAD_REF
163+
Pattern: !Sub '^refs/tags/v.*$'
164+
ExcludeMatchedPattern: False
165+
# - - Type: EVENT
166+
# Pattern: "PULL_REQUEST_MERGED"
167+
# ExcludeMatchedPattern: False
168+
# - Type: HEAD_REF
169+
# Pattern: '^refs/heads/.*$'
170+
# ExcludeMatchedPattern: False
171+
# - Type: BASE_REF
172+
# Pattern: !Sub '^refs/heads/${ReferenceBranchName}$'
173+
# ExcludeMatchedPattern: False

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ insert_final_newline = true
1010
charset = utf-8
1111
end_of_line = lf
1212

13+
[*.json]
14+
indent_size = 2
15+
1316
[*.yml]
1417
indent_size = 2
1518

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* ECS Config Composer version:
1+
* ECS Files Composer version:
22
* Python version:
33
* Operating System:
44

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,4 @@ ENV/
107107

108108
# IDE settings
109109
.vscode/
110+
/codebuild_build.sh

CONTRIBUTING.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Types of Contributions
1515
Report Bugs
1616
~~~~~~~~~~~
1717

18-
Report bugs at https://github.com/compose-x/ecs_files_composer/issues.
18+
Report bugs at https://github.com/compose-x/ecs-files-composer/issues.
1919

2020
If you are reporting a bug, please include:
2121

@@ -38,14 +38,14 @@ and "help wanted" is open to whoever wants to implement it.
3838
Write Documentation
3939
~~~~~~~~~~~~~~~~~~~
4040

41-
ECS Config Composer could always use more documentation, whether as part of the
42-
official ECS Config Composer docs, in docstrings, or even on the web in blog posts,
41+
ECS Files Composer could always use more documentation, whether as part of the
42+
official ECS Files Composer docs, in docstrings, or even on the web in blog posts,
4343
articles, and such.
4444

4545
Submit Feedback
4646
~~~~~~~~~~~~~~~
4747

48-
The best way to send feedback is to file an issue at https://github.com/compose-x/ecs_files_composer/issues.
48+
The best way to send feedback is to file an issue at https://github.com/compose-x/ecs-files-composer/issues.
4949

5050
If you are proposing a feature:
5151

@@ -57,17 +57,18 @@ If you are proposing a feature:
5757
Get Started!
5858
------------
5959

60-
Ready to contribute? Here's how to set up `ecs_files_composer` for local development.
60+
Ready to contribute? Here's how to set up `ecs-files-composer` for local development.
6161

62-
1. Fork the `ecs_files_composer` repo on GitHub.
62+
1. Fork the `ecs-files-composer` repo on GitHub.
6363
2. Clone your fork locally::
6464

65-
$ git clone [email protected]:your_name_here/ecs_files_composer.git
65+
$ git clone [email protected]:your_name_here/ecs-files-composer.git
6666

6767
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
6868

69-
$ mkvirtualenv ecs_files_composer
70-
$ cd ecs_files_composer/
69+
$ cd ecs-files-composer/
70+
$ python3 -m venv venv
71+
$ source venv/bin/activate
7172
$ python setup.py develop
7273

7374
4. Create a branch for local development::
@@ -103,15 +104,15 @@ Before you submit a pull request, check that it meets these guidelines:
103104
your new functionality into a function with a docstring, and add the
104105
feature to the list in README.rst.
105106
3. The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and for PyPy. Check
106-
https://travis-ci.com/compose-x/ecs_files_composer/pull_requests
107+
https://travis-ci.com/compose-x/ecs-files-composer/pull_requests
107108
and make sure that the tests pass for all supported Python versions.
108109

109110
Tips
110111
----
111112

112113
To run a subset of tests::
113114

114-
$ pytest tests.test_ecs_files_composer
115+
$ pytest tests.test_ecs-files-composer
115116

116117

117118
Deploying

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ endef
2222
export PRINT_HELP_PYSCRIPT
2323

2424
BROWSER := python -c "$$BROWSER_PYSCRIPT"
25+
AWS := aws
2526

2627
help:
2728
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
@@ -70,6 +71,12 @@ docs: ## generate Sphinx HTML documentation, including API docs
7071
$(MAKE) -C docs html
7172
$(BROWSER) docs/_build/html/index.html
7273

74+
75+
publish-docs: docs
76+
cd docs/_build/html && \
77+
$(AWS) s3 sync . s3://${DOCS_BUCKET}/ \
78+
--acl public-read --sse AES256 --storage-class ONEZONE_IA
79+
7380
servedocs: docs ## compile the docs watching for changes
7481
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
7582

0 commit comments

Comments
 (0)