Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jdp-seq authored Jul 1, 2024
0 parents commit 77527fd
Show file tree
Hide file tree
Showing 13 changed files with 470 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# By default, PRs for this repo are automatically reviewed by:
* @calico/sweng-dev @calico/data-eng-dev
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Description of your changes

<!--- Changes proposed in this pull request -->

### Issue ticket number and link

<!--- Please include the JIRA ticket and link -->

### Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation add / update

### (If applicable) How has this been tested?

<!--- Please describe the tests that you ran to verify your changes. -->
<!--- Include details of your testing environment -->
21 changes: 21 additions & 0 deletions .github/workflows/check-prettier-formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Validate prettier formatting

on:
push:
paths-ignore:
- "*Dockerfile"

permissions:
contents: "read"
id-token: "write"

defaults:
run:
shell: bash

jobs:
call-check-prettier-formatting:
uses: calico/calico-github-actions/.github/workflows/check-prettier-formatting.yml@main
permissions:
contents: "write"
id-token: "write"
38 changes: 38 additions & 0 deletions .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Workflow to build the Python package and push to Calico-PyPI

name: Build/Release Python Package

on:
workflow_dispatch:
inputs:
python-version:
default: "3.11"
description: "Python version to use for building the package"
required: false
type: string
release-version:
description: "New version (e.g., v0.0.0)"
required: true
release-notes:
default: ""
required: false
description: "Release notes for the new version"
type: string

defaults:
run:
shell: bash

permissions:
contents: "write"
id-token: "write"

jobs:
call-release-new-version-calico-pypi:
if: github.event.repository.name != 'github-template-python-library'
uses: calico/calico-github-actions/.github/workflows/release-new-version-calico-pypi.yml@main
with:
python-version: ${{ inputs.python-version }}
release-version: ${{ inputs.release-version }}
release-notes: ${{ inputs.release-notes }}
secrets: inherit
24 changes: 24 additions & 0 deletions .github/workflows/run-tests-formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Python formatting and tests

on:
push:
paths:
- "**.py"

permissions:
contents: "read"
id-token: "write"

jobs:
call-python-black:
uses: calico/calico-github-actions/.github/workflows/python-black.yml@main
permissions:
contents: "write"
id-token: "write"
call-python-pytest-3-11:
if: github.event.repository.name != 'github-template-python-library'
uses: calico/calico-github-actions/.github/workflows/python-pytest.yml@main
with:
python-version: "3.11"
run-python-ruff:
uses: calico/calico-github-actions/.github/workflows/python-ruff.yml@main
134 changes: 134 additions & 0 deletions .github/workflows/set-up-new-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Set up new Python library repo

on:
workflow_dispatch:
inputs:
packageName:
description: "Python package name. No spacing or hyphens."
required: true

defaults:
run:
shell: bash

jobs:
set-up-repo:
runs-on: ubuntu-latest
steps:
- name: Check repo name validity
run: |
# Calico Python library repo names need to begin with calicolabs-
repo_name=${{ github.event.repository.name }}
echo "REPO_NAME=$repo_name" >> $GITHUB_ENV
if [[ $repo_name != calicolabs-* ]]; then
echo "Repo name needs to begin with calicolabs-"
exit 1
fi
- name: Check Python package validity
run: |
python_package_name=${{ inputs.packageName }}
if [[ $python_package_name == *" "* ]]; then
echo "Python package name cannot have spaces"
exit 1
fi
if [[ $python_package_name == *"-"* ]]; then
echo "Python package name cannot have hyphens"
exit 1
fi
echo "Python package name $python_package_name is valid!"
- name: Set up environment variable from input
run: |
python_package_name=${{ inputs.packageName }}
# replace underscores with hyphens
hyphenated_package_name=${python_package_name//_/-}
echo "PYTHON_PACKAGE_NAME=$python_package_name" >> $GITHUB_ENV
echo "Setting PYTHON_PACKAGE_NAME to: $python_package_name"
echo "HYPHENATED_PACKAGE_NAME=$hyphenated_package_name" >> $GITHUB_ENV
echo "Setting HYPHENATED_PACKAGE_NAME to: $hyphenated_package_name"
- name: Checkout current repo
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_REPO_SETUP_KEY }}

- name: Configure git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Make a new branch
run: |
git checkout -b set-up-new-repo
- name: Updating README
run: |
sed_expr="s/github-template-python-library/${{ env.REPO_NAME }}/g"
cat README.md | sed "s/github-template-python-library/${{ env.REPO_NAME }}/g" > README.md_new
mv README.md_new README.md
git add --all
git commit -m "Update README"
- name: Modify setup.cfg and pyproject.toml
run: |
envsubst < setup.cfg > setup.cfg_new && mv setup.cfg_new setup.cfg
envsubst < pyproject.toml > pyproject.toml_new && mv pyproject.toml_new pyproject.toml
git add --all
git commit -m "Update setup.cfg and pyproject.toml"
- name: Update package folder and update versioning package
run: |
export dir_name=$PYTHON_PACKAGE_NAME
mv src/package_name src/$dir_name
cd src/$dir_name
envsubst < __init__.py > __init__.py_new && mv __init__.py_new __init__.py
cd - > /dev/null
git add --all
git commit -m "Update package folder and update versioning package"
- name: Add collaborators
run: |
gh api -X PUT /orgs/calico/teams/sweng-dev/repos/calico/{repo} \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f permission='maintain'
gh api -X PUT /orgs/calico/teams/data-eng-dev/repos/calico/{repo} \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f permission='admin'
env:
GH_TOKEN: ${{ secrets.GH_REPO_SETUP_KEY }}

- name: Configure Branch Protection
uses: calico/calico-github-actions/.github/actions/configure-branch-protection@main
with:
token: ${{ secrets.GH_REPO_SETUP_KEY }}

- name: Configure New Repo Settings
uses: calico/calico-github-actions/.github/actions/configure-new-repo-settings@main
with:
token: ${{ secrets.GH_REPO_SETUP_KEY }}

- name: Remove set up workflow
run: |
# remove this github workflow
git rm .github/workflows/set-up-new-repo.yml
git commit -m "Remove set up workflow"
- name: Print git diff and push branch
run: |
echo "DIFF:" && git diff main && echo
git push -u origin set-up-new-repo
- name: Create PR
run: |
gh pr create --title "Set up new workflow repo" --body "New PR setup"
env:
GH_TOKEN: ${{ secrets.GH_REPO_SETUP_KEY }}
132 changes: 132 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# JetBrains IDE files
**/.idea*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
Loading

0 comments on commit 77527fd

Please sign in to comment.