Skip to content

Commit d6907b3

Browse files
Initial commit
0 parents  commit d6907b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+6237
-0
lines changed

.dockerignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
**/__pycache__
2+
**/.classpath
3+
**/.dockerignore
4+
**/.DS_Store
5+
**/.editorconfig
6+
**/.env
7+
**/.git
8+
**/.github
9+
**/.gitignore
10+
**/.project
11+
**/.settings
12+
**/.toolstarget
13+
**/.vs
14+
**/.vscode
15+
**/*.*proj.user
16+
**/*.dbmdl
17+
**/*.jfm
18+
**/*.py#
19+
**/*.py~
20+
**/*.pyc
21+
**/azds.yaml
22+
**/bin
23+
**/charts
24+
**/compose*
25+
**/csv
26+
**/django
27+
**/docker-compose*
28+
**/Dockerfile*
29+
**/img
30+
**/node_modules
31+
**/npm-debug.log
32+
**/obj
33+
**/README.md
34+
**/secrets.dev.yaml
35+
**/terraform
36+
**/values.dev.yaml

.editorconfig

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines and whitespace cleanup
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
13+
# Protect whitespace in markdown files
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
# general formatting
18+
[*.{bash,go,sh,zsh,Makefile}]
19+
indent_style = tab
20+
indent_size = 4
21+
22+
# Set default charset
23+
[*.{html,xml,js,css,py}]
24+
charset = utf-8
25+
26+
# python
27+
[*.py]
28+
indent_style = space
29+
indent_size = 4
30+
31+
# webdev + terraform
32+
[*.{html,xml,js,css,gql,tf,tfvars}]
33+
indent_style = space
34+
indent_size = 2

.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: [pythoninthegrass]
4+
# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
5+
# patreon: # Replace with a single Patreon username
6+
# open_collective: # Replace with a single Open Collective username
7+
# ko_fi: # Replace with a single Ko-fi username
8+
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
9+
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
10+
# liberapay: # Replace with a single Liberapay username
11+
# issuehunt: # Replace with a single IssueHunt username
12+
# otechie: # Replace with a single Otechie username
13+
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry

.github/dependabot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
6+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#directory
7+
8+
version: 2
9+
updates:
10+
- package-ecosystem: "pip" # package manager
11+
directory: "/" # Files stored in repository root
12+
schedule:
13+
interval: "weekly"
14+
day: "saturday"
15+
time: "10:00"
16+
timezone: "America/Chicago"
17+
open-pull-requests-limit: 5

.github/workflows/auto_merge.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#approve-a-pull-request
2+
3+
name: auto_merge
4+
on: [pull_request, workflow_dispatch] # pull_request, push, workflow_dispatch
5+
6+
permissions:
7+
pull-requests: write
8+
9+
jobs:
10+
dependabot:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.actor == 'dependabot[bot]' }}
13+
steps:
14+
- name: Dependabot metadata
15+
id: metadata
16+
uses: dependabot/fetch-metadata@v1.1.1
17+
with:
18+
github-token: "${{ secrets.GITHUB_TOKEN }}"
19+
- name: Approve a PR
20+
run: gh pr review --approve "$PR_URL"
21+
env:
22+
PR_URL: ${{github.event.pull_request.html_url}}
23+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
24+
- name: Merge a PR
25+
run: gh pr merge "$PR_URL" --auto --squash
26+
env:
27+
PR_URL: ${{github.event.pull_request.html_url}}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: codeql
13+
14+
on:
15+
push:
16+
branches: [ "main" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ "main" ]
20+
schedule:
21+
- cron: '37 22 * * 4'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'python' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v3
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v2
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
52+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53+
# queries: security-extended,security-and-quality
54+
55+
56+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57+
# If this step fails, then you should remove it and run the build manually (see below)
58+
- name: Autobuild
59+
uses: github/codeql-action/autobuild@v2
60+
61+
# ℹ️ Command-line programs to run using the OS shell.
62+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63+
64+
# If the Autobuild fails above, remove it and uncomment the following three lines.
65+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66+
67+
# - run: |
68+
# echo "Run, Build Application using script"
69+
# ./location_of_script_within_repo/buildscript.sh
70+
71+
- name: Perform CodeQL Analysis
72+
uses: github/codeql-action/analyze@v2

.github/workflows/echo_secret.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: echo_secret
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- shell: bash
12+
env:
13+
SUPER_SECRET: ${{ secrets.CREDS }}
14+
run: |
15+
echo "$SUPER_SECRET"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python3
2+
3+
"""Helper script to be used as a pre-commit hook."""
4+
import os
5+
import sys
6+
import subprocess
7+
8+
9+
def gitleaksEnabled():
10+
"""Determine if the pre-commit hook for gitleaks is enabled."""
11+
out = subprocess.getoutput("git config --bool hooks.gitleaks")
12+
if out == "false":
13+
return False
14+
return True
15+
16+
17+
if gitleaksEnabled():
18+
exitCode = os.WEXITSTATUS(os.system('gitleaks protect -v --staged'))
19+
if exitCode == 1:
20+
print('''Warning: gitleaks has detected sensitive information in your changes.
21+
To disable the gitleaks precommit hook run the following command:
22+
23+
git config hooks.gitleaks false
24+
''')
25+
sys.exit(1)
26+
else:
27+
print('gitleaks precommit disabled\
28+
(enable with `git config hooks.gitleaks true`)')

.github/workflows/main.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: gitleaks
2+
3+
on: [pull_request, push, workflow_dispatch]
4+
5+
jobs:
6+
scan:
7+
name: gitleaks
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
- uses: gitleaks/gitleaks-action@v2
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}} # Only required for Organizations, not personal accounts.

.github/workflows/python_test.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
2+
# https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#caching-packages
3+
# https://www.peterbe.com/plog/install-python-poetry-github-actions-faster
4+
5+
name: python_test
6+
7+
on:
8+
workflow_dispatch:
9+
# push:
10+
# branches:
11+
# - main
12+
# pull_request:
13+
14+
jobs:
15+
ci:
16+
strategy:
17+
matrix:
18+
python-version: ["3.10", "3.11"]
19+
os: ["ubuntu-latest"]
20+
arch: ['x64']
21+
22+
runs-on: ${{ matrix.os }}
23+
24+
steps:
25+
- name: checkout repo content
26+
uses: actions/checkout@v3
27+
# TODO: debug 'cache not found for input keys dotlocal-Linux-8e1cebf...'
28+
# - name: load cached $HOME/.local
29+
# uses: actions/cache@v2.1.6
30+
# id: cash-money
31+
# with:
32+
# path: ~/.local
33+
# key: dotlocal-${{ runner.os }}-${{ hashFiles('.github/workflows/python_test.yml') }}
34+
# - run: echo '${{ steps.cash-money.outputs.cache-hit }}' # true if cache-hit occured on the primary key
35+
# TODO: use `git config --global --add safe.directory` to find working dir (may need to set under checkout step)
36+
- name: set cwd and change to directory
37+
run: |
38+
CWD=$(basename $(git rev-parse --show-toplevel))
39+
BASE_DIR=$(cat BASE_DIR)
40+
echo "BASE_DIR=$BASE_DIR" >> $GITHUB_ENV
41+
cd ${{ env.BASE_DIR }} || unset BASE_DIR; \
42+
BASE_DIR="$(pwd)/work/${CWD}/${CWD}" && echo "BASE_DIR=$BASE_DIR" >> $GITHUB_ENV; \
43+
cd ${{ env.BASE_DIR }}
44+
# - run: ls -la ${{ env.BASE_DIR }}
45+
- name: Read .tool-versions # dynamic versions
46+
uses: marocchino/tool-versions-action@v1
47+
id: versions
48+
with:
49+
path: ${{ env.BASE_DIR }}/.tool-versions
50+
- name: shuffle files
51+
run: |
52+
cat ${{ env.BASE_DIR }}/.tool-versions | awk '/python/ {print $NF}' >> ${{ env.BASE_DIR }}/.python-version
53+
# [[ -e "$(pwd)/pyproject.toml" ]] && mv "$(pwd)/pyproject.toml" "$(pwd)/pyproject.toml.bak"
54+
# cp "${{ env.BASE_DIR }}/pyproject.toml" $(pwd)/
55+
- name: setup python
56+
uses: actions/setup-python@v4
57+
with:
58+
python-version-file: ${{ env.BASE_DIR }}/.python-version
59+
cache: 'pip'
60+
- name: setup poetry
61+
uses: snok/install-poetry@v1
62+
id: cp310
63+
with:
64+
version: ${{ steps.versions.outputs.poetry }}
65+
virtualenvs-create: true
66+
virtualenvs-in-project: true
67+
virtualenvs-path: ${{ env.BASE_DIR }}
68+
installer-parallel: true
69+
- name: load cached venv
70+
id: cached-poetry-dependencies
71+
uses: actions/cache@v2.1.6
72+
with:
73+
path: ${{ env.BASE_DIR }}/.venv
74+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('.github/workflows/python_test.yml') }}
75+
- name: install virtualenv
76+
run: |
77+
cd ${{ env.BASE_DIR }}
78+
poetry install
79+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
80+
- name: Lint with flake8
81+
run: |
82+
# stop the build if there are Python syntax errors or undefined names
83+
poetry run flake8 ${{ env.BASE_DIR }} --count --select=E9,F63,F7,F82 --show-source --statistics
84+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
85+
poetry run flake8 ${{ env.BASE_DIR }} --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
86+
# TODO: write tests
87+
- name: Test with pytest
88+
run: |
89+
# exit code 5 == 'collected 0 items'
90+
poetry run pytest ${{ env.BASE_DIR }}

0 commit comments

Comments
 (0)