Skip to content

Commit

Permalink
feat: python-projector
Browse files Browse the repository at this point in the history
  • Loading branch information
kiyoon committed Dec 13, 2024
1 parent 5c568db commit 6627cae
Show file tree
Hide file tree
Showing 47 changed files with 3,689 additions and 5 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/_check-pip-compile-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: (not reusable) Check pip compile sync

on:
push:
branches:
- main
- master
pull_request:

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

jobs:
check-pip-compile:
name: Check pip compile
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: deargen/workflows/actions/check-pip-compile@master
with:
cwd: python-projector
pyproject-toml-file: pyproject.toml
requirements-in-dir: deps
requirements-out-dir: deps/lock
19 changes: 18 additions & 1 deletion .github/workflows/_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
version-tag:
description: Version tag
required: true
default: v0.1.0
default: v0.1.5
dry-run:
description: Dry run
type: boolean
Expand All @@ -20,3 +20,20 @@ jobs:
dry-run: ${{ github.event.inputs.dry-run == 'true' }}
changelog-path: docs/CHANGELOG.md
exclude-types: build,docs,style,other

publish-to-pypi:
if: ${{ github.event.inputs.dry-run == 'false' }}
needs: commit-changelog-and-release
runs-on: ubuntu-24.04
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.version-tag }}
- uses: deargen/workflows/actions/setup-python-and-uv@master
- name: Build and upload to PyPI
run: |
uv build --sdist
uv publish
19 changes: 19 additions & 0 deletions .github/workflows/_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: (not reusable) Linting

on:
push:
branches:
- main
- master
pull_request:

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

jobs:
ruff-lint:
uses: deargen/workflows/.github/workflows/check-ruff.yml@master
with:
check-type: lint
cwd: python-projector
19 changes: 19 additions & 0 deletions .github/workflows/_styles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: (not reusable) Style checking

on: [push, pull_request]

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

jobs:
ruff-format:
uses: deargen/workflows/.github/workflows/check-ruff.yml@master
with:
check-type: format
cwd: python-projector
ruff-isort:
uses: deargen/workflows/.github/workflows/check-ruff.yml@master
with:
check-type: isort
cwd: python-projector
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This repository contains reusable and reference GitHub Actions workflows.

It also includes [`python-projector`](python-projector), a utility wrapper of `uv` etc. that helps manage Python projects. See the README in the directory for more information.

## Style checking and applying fixes

### Ruff lint and style checking
Expand Down
9 changes: 9 additions & 0 deletions actions/apply-pip-compile/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ inputs:
description: Platforms to support (comma-separated)
required: true
default: x86_64-manylinux_2_28,aarch64-apple-darwin,x86_64-apple-darwin,x86_64-pc-windows-msvc
cwd:
description: 'The directory to run uv (and the whole script) in'
required: false

runs:
using: 'composite'
steps:
- shell: bash
run: |
if [[ -n "${{ inputs.cwd }}" ]]; then
cd "${{ inputs.cwd }}"
fi
echo "min_python_version=$(python3 ${{ github.action_path }}/../../scripts/get_min_python_version.py "${{ inputs.pyproject-toml-file }}")" >> "$GITHUB_OUTPUT"
pip3 install uv --break-system-packages
id: get-python-version
Expand All @@ -36,6 +42,9 @@ runs:
name: Run uv pip compile and push
run: |
# set +e # Do not exit shell on failure
if [[ -n "${{ inputs.cwd }}" ]]; then
cd "${{ inputs.cwd }}"
fi
bash ${{ github.action_path }}/../../scripts/compile_requirements.sh \
"${{ inputs.requirements-in-dir }}" \
"${{ inputs.requirements-out-dir }}" \
Expand Down
10 changes: 10 additions & 0 deletions actions/check-pip-compile/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ inputs:
description: Platforms to support (comma-separated)
required: true
default: x86_64-manylinux_2_28,aarch64-apple-darwin,x86_64-apple-darwin,x86_64-pc-windows-msvc
cwd:
description: 'The directory to run uv (and the whole script) in'
required: false

runs:
using: 'composite'
steps:
- shell: bash
run: |
if [[ -n "${{ inputs.cwd }}" ]]; then
cd "${{ inputs.cwd }}"
fi
echo "min_python_version=$(python3 ${{ github.action_path }}/../../scripts/get_min_python_version.py "${{ inputs.pyproject-toml-file }}")" >> "$GITHUB_OUTPUT"
pip3 install uv --break-system-packages
id: get-python-version
Expand All @@ -37,6 +43,10 @@ runs:
run: |
set +e # Do not exit shell on failure
if [[ -n "${{ inputs.cwd }}" ]]; then
cd "${{ inputs.cwd }}"
fi
out=$(bash ${{ github.action_path }}/../../scripts/compile_requirements.sh \
"${{ inputs.requirements-in-dir }}" \
"${{ inputs.requirements-out-dir }}" \
Expand Down
171 changes: 171 additions & 0 deletions python-projector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@

### Python ###
# 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/
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/
cover/

# 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
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .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

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__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
/docs/reference

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

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

### Python Patch ###
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml


# End of https://www.toptal.com/developers/gitignore/api/python

8 changes: 8 additions & 0 deletions python-projector/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"charliermarsh.ruff",
"jgclark.vscode-todo-highlight",
"usernamehw.errorlens",
"timonwong.shellcheck"
]
}
14 changes: 14 additions & 0 deletions python-projector/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"ruff.organizeImports": true,
"editor.formatOnSave": true,
"python.analysis.inlayHints.functionReturnTypes": true,
"python.analysis.inlayHints.pytestParameters": true,
"python.analysis.inlayHints.variableTypes": true
}
Loading

0 comments on commit 6627cae

Please sign in to comment.