Skip to content

Commit

Permalink
init project (#1)
Browse files Browse the repository at this point in the history
* init

* init project

* add publish script

* add pr-lint flow
  • Loading branch information
lucemia authored Jun 14, 2024
1 parent e76efba commit bce3801
Show file tree
Hide file tree
Showing 23 changed files with 1,215 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
allow:
- dependency-type: "all"
- package-ecosystem: "github-actions"
directory: "/" # Typically GitHub Actions workflows are located in .github/workflows
schedule:
interval: "weekly"
20 changes: 20 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: dependabot-auto-merge
on: [push, pull_request]

jobs:
dependabot:
name: "Dependabot"
permissions: write-all
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}} # Detect that the PR author is dependabot
steps:
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL" # Use Github CLI to merge automatically the PR
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Enable auto-approve for Dependabot PRs
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
25 changes: 25 additions & 0 deletions .github/workflows/pr-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Commitlint PR Title

on:
pull_request:
types: [opened, edited, labeled, unlabeled]

jobs:
commitlint:
runs-on: ubuntu-latest

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install pr-lint
run: pip install pr-lint

- name: Run Commitlint on PR title
run: pr-lint
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
PR_NUMBER: ${{ github.event.number }}
44 changes: 44 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install Poetry & export Requirements
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry self add poetry-dynamic-versioning[plugin]
- name: Build package
run: poetry build
- name: Publish package
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
# - run: poetry install --with dev
# - run: poetry run mkdocs gh-deploy --force
71 changes: 71 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
# - id: check-added-large-files
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-yaml
- id: end-of-file-fixer
exclude: "__snapshots__/"
- id: fix-encoding-pragma
args: [--remove]
- id: mixed-line-ending
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
exclude: "__snapshots__/"
- id: pretty-format-json
args: [--autofix]
exclude: "__snapshots__/"
# this is not technically always safe but usually is
# use comments `# isort: off` and `# isort: on` to disable/re-enable isort
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: [--line-length=120, --profile=black]

# this is slightly dangerous because python imports have side effects
# and this tool removes unused imports, which may be providing
# necessary side effects for the code to run
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
hooks:
- id: autoflake
args:
- "--in-place"
- "--expand-star-imports"
- "--remove-duplicate-keys"
- "--remove-unused-variables"
- "--remove-all-unused-imports"

- repo: https://github.com/psf/black
rev: 24.1.0
hooks:
- id: black
args: [--line-length=120, --exclude=""]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.8.0"
hooks:
- id: mypy
exclude: migrations/|commands/|scripts/|sandbox/|samples|sdk
additional_dependencies:
- "pygithub"
- "pytest"
- "syrupy"
- "typer"
args:
[
--pretty,
--show-error-codes,
--implicit-optional,
--follow-imports=silent,
--warn-redundant-casts,
--warn-unused-ignores,
--disallow-any-generics,
--check-untyped-defs,
--no-implicit-reexport,
--disallow-untyped-defs,
]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# pr-lint
# pr-lint
Loading

0 comments on commit bce3801

Please sign in to comment.