Skip to content

Commit

Permalink
🎉 init: new start
Browse files Browse the repository at this point in the history
  • Loading branch information
jzazo committed May 7, 2024
0 parents commit 1fcd07b
Show file tree
Hide file tree
Showing 60 changed files with 3,412 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .apidoc_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -- Project information -----------------------------------------------------
project = "{{project_name}}"
copyright = "microsoft"
author = "microsoft research"

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc", # main extension for generating from docstrings
"sphinx.ext.autosummary", # adds summary tables
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon", # not sure this one works with the markdown builder
# The `sphinx_autodoc_typehints` extension must be loaded AFTER `sphinx.ext.napoleon`.
"sphinx_autodoc_typehints",
"sphinx_markdown_builder",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = []

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []

intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
}

always_document_param_types = True

autosummary_generate = True # Turn on sphinx.ext.autosummary
autoclass_content = "class"
autodoc_class_signature = "separated"
autodoc_inherit_docstrings = True # If no docstring, inherit from base class
set_type_checking_flag = True # Enable 'expensive' imports for sphinx_autodoc_typehints
add_module_names = False # Remove namespaces from class/method signatures
1 change: 1 addition & 0 deletions .apidoc_conf.py.jinja
19 changes: 19 additions & 0 deletions .azure-pipelines/cg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
trigger: [main]
pr: [main]
schedules:
- cron: "0 0 * * 1"
displayName: "Weekly: {{project_name}}"
branches:
include:
- main
pool:
vmImage: ubuntu-latest
variables:
EnableDetectorPoetry: true
steps:
- task: ComponentGovernanceComponentDetection@0
inputs:
showAlertLink: true
failOnAlert: true
failOnStderr: true
logLevel: debug
1 change: 1 addition & 0 deletions .azure-pipelines/cg.yml.jinja
6 changes: 6 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[codespell]
write-changes =
count = true
quiet-level = 3
ignore-words-list = aks,aml,requestors
skip = *.drawio
2 changes: 2 additions & 0 deletions .copier-answers.yml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
{{_copier_answers|to_nice_yaml -}}
11 changes: 11 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[run]
branch = True
data_file = .tmp/.coverage
source = src/python/{{module_name}}
relative_files = true

[report]
show_missing = true

[xml]
output = .tmp/reports/coverage.xml
1 change: 1 addition & 0 deletions .coveragerc.jinja
6 changes: 6 additions & 0 deletions .cz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tool.commitizen]
name = "cz_gitmoji"
tag_format = "v$version"
version_scheme = "pep440"
version_provider = "poetry"
update_changelog_on_bump = true
38 changes: 38 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"image": "mcr.microsoft.com/devcontainers/python:3.10",
"features": {
"ghcr.io/devcontainers/features/git": {},
"ghcr.io/devcontainers/features/sshd": {},
"ghcr.io/devcontainers/features/github-cli": {},
"ghcr.io/devcontainers-contrib/features/tmux-apt-get": {},
"ghcr.io/devcontainers/features/common-utils": {
"configureZshAsDefaultShell": true
},
"ghcr.io/devcontainers/features/docker-in-docker": {},
"ghcr.io/devcontainers-contrib/features/fzf": {},
"ghcr.io/devcontainers-contrib/features/pipx-package": {},
"ghcr.io/devcontainers-contrib/features/poetry": {},
"ghcr.io/devcontainers-contrib/features/direnv": {},
"ghcr.io/devcontainers-contrib/features/pre-commit": {},
"ghcr.io/devcontainers-contrib/features/neovim-apt-get": {},
"ghcr.io/devcontainers-contrib/features/copier": {}
},
"onCreateCommand": ".devcontainer/on-create.sh",
"postCreateCommand": ".devcontainer/post-create.sh",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.debugpy",
"ms-toolsai.jupyter",
"charliermarsh.ruff",
"eamodio.gitlens",
"redhat.vscode-yaml",
"bierner.github-markdown-preview",
"GitHub.copilot",
"GitHub.vscode-pull-request-github"
]
}
}
}
12 changes: 12 additions & 0 deletions .devcontainer/direnvrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
layout_poetry() {
if [[ ! -f pyproject.toml ]]; then
log_status 'No pyproject.toml found. Will initialize poetry in no-interactive mode'
poetry init -n -q
poetry run pip install -U pip wheel setuptools
fi
poetry run echo >> /dev/null
local VENV=$(dirname $(poetry run which python))
export VIRTUAL_ENV=$(echo "$VENV" | rev | cut -d'/' -f2- | rev)
export POETRY_ACTIVE=1
PATH_add "$VENV"
}
29 changes: 29 additions & 0 deletions .devcontainer/on-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /bin/bash
# this runs ONCE at devcontainer creation time, and it runs during pre-build phase which
# means it does not have access to user context
# ===========================

# finish config of direnv settings (would be nice to improve the devcontainer "feature")
echo "CONFIGURING DIRENV..."
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
eval "$(direnv hook bash)"
mkdir -p ~/.config/direnv/
cp /workspaces/{{project_name}}/.devcontainer/direnvrc ~/.config/direnv/direnvrc

echo "UPDATE PIP"
pip install --upgrade pip

echo "INSTALLING COMMITIZEN"
pipx install commitizen
pipx inject commitizen cz-conventional-gitmoji
echo 'eval "$(register-python-argcomplete cz)"' >> ~/.zshrc
echo 'eval "$(register-python-argcomplete cz)"' >> ~/.bashrc

echo "POETRY INSTALL"
poetry config virtualenvs.in-project true
direnv allow .
poetry install

echo "CONFIGURING PRE-COMMIT"
pre-commit install --install-hooks
1 change: 1 addition & 0 deletions .devcontainer/on-create.sh.jinja
13 changes: 13 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/bash
# this runs ONCE after the container is created, and runs in the user's context inside the container
# ===========================

git config -–global core.editor "nano"
git config --global pager.branch false
git config --global alias.ba branch
git config --global alias.co checkout
git config --global alias.st status
git config --global alias.sa stash
git config --global alias.cp cherry-pick
git config --global alias.mt mergetool
git config --global alias.pl pull --rebase
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
**/.venv
**/.tox
**/.tox.docker
**/.tmp
**/.mypy_cache
**/.pytest_cache
**/.coverage
**/.idea
**/.direnv
**/.vscode
**/*.pyc

**/src/python/*.egg-info
**/build/
**/dist

.git
.coverage
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig defines consistent coding styles for various IDEs.
# https://editorconfig.org/
# Pycharm supports this file by default while VS Code requires an extension:
# https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig
root = true

[*]
# unix-style newlines with a newline ending every file
end_of_line = lf
# makes sure files end in a newline on save
insert_final_newline = true
charset = utf-8
max_line_length = 99

[*.py]
indent_style = space
indent_size = 4

[{*.yaml,*.yml,.pages}]
indent_style = space
indent_size = 2
7 changes: 7 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
layout_poetry

# get path to the root of the project even if deep into the path
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# add bin directory to the path
export PATH="${SCRIPT_DIR}/bin:$PATH"
27 changes: 27 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
target-branch: main
groups:
github-actions:
patterns:
- "*"
commit-message:
prefix: ":arrow_up: dep-bump"
include: scope

- package-ecosystem: pip
directory: "/" # location of package manifests
schedule:
interval: monthly
target-branch: main
groups:
package-dependencies:
patterns:
- "*"
commit-message:
prefix: ":arrow_up: dep-bump"
include: scope
116 changes: 116 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: CI
on:
push:
branches: [ main ]
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
branches: [ main ]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit:
runs-on: ubuntu-latest
name: pre-commit
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U pre-commit
pre-commit install --install-hooks
- name: pre-commit
run: |
pre-commit run --all-files
env:
SKIP: "ruff,ruff-format,pyright"

run-tests:
runs-on: ubuntu-latest
name: run-tests
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U poetry
poetry install
- name: ruff-check
run: |
poetry run ruff check --no-fix --output-format=github
- name: ruff-format
run: |
poetry run ruff format --check
- name: pyright
run: |
poetry run pyright
- name: pytest
run: |
poetry run coverage run -m pytest
- name: coverage
run: |
poetry run coverage xml -o .tmp/reports/coverage.xml
build-docs:
runs-on: ubuntu-latest
name: build-docs
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U poetry
poetry install
- name: build-docs
run: |
bin/build-docs
- name: upload-gh-pages
uses: actions/upload-pages-artifact@v3
with:
path: dist/site

deploy-docs:
needs: [run-tests, build-docs, pre-commit]
runs-on: ubuntu-latest
name: deploy-docs
permissions:
pages: write
id-token: write
if: github.ref_name == 'main'
steps:
- name: deploy-gh-pages
id: deployment
uses: actions/deploy-pages@v4

codeql:
uses: ./.github/workflows/codeql.yml
secrets: inherit
permissions:
contents: read
actions: read
security-events: write
Loading

0 comments on commit 1fcd07b

Please sign in to comment.