Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
datalogics-deh authored Sep 25, 2023
0 parents commit 7b816cd
Show file tree
Hide file tree
Showing 24 changed files with 4,655 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .cdk-init/patch-cdk-json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import json

with open("cdk.json") as cdk_json:
cdk_json_data = json.load(cdk_json)

# Exclude PDM projects and all Python caches from 'cdk watch'
cdk_json_data["watch"]["exclude"].extend(
["pyproject.toml", "pdm.lock", "**/__pycache__"]
)

with open("cdk.json", "w") as cdk_json:
json.dump(cdk_json_data, cdk_json, indent=2)
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Don't put Docker config into the image
Dockerfile
.dockerignore

# Ignore Git, IDEs, pre-commit configs, Jenkins, and other project scaffolding
.git
.idea
.ecrc
.editorconfig
.empty
.gitattributes
.gitignore
.github
.pre-commit-config.yaml
README.md

# Files that aren't part of the image
rpms
19 changes: 19 additions & 0 deletions .ecrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"Version": "2.7.0",
"Verbose": false,
"Debug": false,
"IgnoreDefaults": false,
"SpacesAftertabs": false,
"NoColor": false,
"Exclude": ["^\\.idea/", "\\.md$", "\\.py$"],
"AllowedContentTypes": [],
"PassedFiles": [],
"Disable": {
"EndOfLine": false,
"Indentation": false,
"InsertFinalNewline": false,
"TrimTrailingWhitespace": false,
"IndentSize": true,
"MaxLineLength": false
}
}
28 changes: 28 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
root = true


[*]
charset = utf-8
insert_final_newline = true
indent_style = space
indent_size = 2

[*.md]
indent_size = 2
max_line_length = 80

[*.py]
indent_size = 4
max_line_length = 88

[*.sh]
# like -i=4
indent_style = space
indent_size = 4

shell_variant = bash # --language-variant
binary_next_line = true
switch_case_indent = true # --case-indent
space_redirects = true
keep_padding = false
function_next_line = true # --func-next-line
108 changes: 108 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Common settings that generally should always be used with your language specific settings

# Auto detect text files and perform LF normalization
# https://www.davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
* text=auto

#
# The above will handle all files NOT found below
#

# Documents
*.bibtex text diff=bibtex
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.md text
*.tex text diff=tex
*.adoc text
*.textile text
*.mustache text
*.csv text
*.tab text
*.tsv text
*.txt text
*.sql text

# Graphics
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.tif binary
*.tiff binary
*.ico binary
# SVG treated as an asset (binary) by default.
*.svg text
# If you want to treat it as binary,
# use the following line instead.
# *.svg binary
*.eps binary

# Scripts
*.bash text eol=lf
*.fish text eol=lf
*.sh text eol=lf
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf

# Serialisation
*.json text
*.toml text
*.xml text
*.yaml text
*.yml text

# Archives
*.7z binary
*.gz binary
*.tar binary
*.tgz binary
*.zip binary

# Text files where line endings should be preserved
*.patch -text

#
# Exclude files from exporting
#

.gitattributes export-ignore
.gitignore export-ignore
# Basic .gitattributes for a python repo.

# Source files
# ============
*.pxd text diff=python
*.py text diff=python
*.py3 text diff=python
*.pyw text diff=python
*.pyx text diff=python
*.pyz text diff=python

# Binary files
# ============
*.db binary
*.p binary
*.pkl binary
*.pickle binary
*.pyc binary
*.pyd binary
*.pyo binary

# Jupyter notebook
*.ipynb text

# Note: .db, .p, and .pkl files are associated
# with the python modules ``pickle``, ``dbm.*``,
# ``shelve``, ``marshal``, ``anydbm``, & ``bsddb``
# (among others).
35 changes: 35 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy AWS CDK to staging

on:
push:
branches: [staging]

jobs:
deploy-staging-to-aws:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install CDK and Python dependencies
run: |
npm install -g aws-cdk
python -m pip install --upgrade pip pdm
# Create the virtual environment and install the locked packages from pdm.lock
# --production used to not install all the development packages, not needed here
pdm install --production
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@master
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: "us-east-2"
- name: Deploy to AWS
# Running with 'pdm run' makes the virtual environment active and then runs cdk
run: pdm run cdk deploy --require-approval=never
22 changes: 22 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: pre-commit

on:
pull_request:
push:
branches: [develop, python]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- uses: actions/cache@v3
with:
path: .mypy_cache
key: mypy_cache|${{ hashFiles('pyproject.toml') }}
- uses: datalogics/[email protected]
with:
extra_args: "--all-files --hook-stage manual"
49 changes: 49 additions & 0 deletions .github/workflows/pytest-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Run pytest on a branch

on:
push:

jobs:
run-pytest-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check for Secret availability
# https://stackoverflow.com/a/70249520/11996393
id: secret-check
# perform secret check & put boolean result as an output
shell: bash
run: |
if [ "${{ secrets.AWS_ACCESS_KEY }}" != '' -a "${{ secrets.AWS_SECRET_KEY }}" != '' ]; then
echo "available=true" >> $GITHUB_OUTPUT;
else
echo "available=false" >> $GITHUB_OUTPUT;
fi
- name: Set up PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: 3.11
cache: true
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install CDK
run: |
npm install -g aws-cdk
- name: Install Python dependencies
# Installing the development dependencies as well, which includes Pytest and all the
# other modules needed to work with the tests.
run: |
pdm install --dev
- name: Configure AWS credentials, if secrets are available
if: ${{ steps.secret-check.outputs.available == 'true' }}
uses: aws-actions/configure-aws-credentials@master
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: "us-east-2"
- name: Run pytest
uses: pavelzw/pytest-action@v2
with:
custom-pytest: pdm run pytest
57 changes: 57 additions & 0 deletions .github/workflows/pytest-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Run pytest on a pull request, with coverage

on:
pull_request:

jobs:
run-pytest-pull-request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check for Secret availability
# https://stackoverflow.com/a/70249520/11996393
id: secret-check
# perform secret check & put boolean result as an output
shell: bash
run: |
if [ "${{ secrets.AWS_ACCESS_KEY }}" != '' -a "${{ secrets.AWS_SECRET_KEY }}" != '' ]; then
echo "available=true" >> $GITHUB_OUTPUT;
else
echo "available=false" >> $GITHUB_OUTPUT;
fi
- name: Set up PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: 3.11
cache: true
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install CDK
run: |
npm install -g aws-cdk
- name: Install Python dependencies
# Installing the development dependencies as well, which includes Pytest and all the
# other modules needed to work with the tests.
run: |
pdm install --dev
- name: Configure AWS credentials, if secrets are available
if: ${{ steps.secret-check.outputs.available == 'true' }}
uses: aws-actions/configure-aws-credentials@master
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: "us-east-2"
- name: Run pytest
uses: pavelzw/pytest-action@v2
with:
custom-pytest: pdm run coverage run -m pytest --junit-xml=pytest-junit.xml
- name: Gather coverage
run: |
pdm run coverage xml
- name: Report coverage
uses: MishaKav/[email protected]
with:
pytest-xml-coverage-path: ./coverage.xml
junitxml-path: ./pytest-junit.xml
Loading

0 comments on commit 7b816cd

Please sign in to comment.