-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
name: Format Code | ||
description: Checks and ensures the code is formatted according to the defined style guidelines. | ||
|
||
inputs: | ||
python_version: | ||
description: Python version to use | ||
default: "3.12" | ||
required: false | ||
poetry_install_options: | ||
description: Options for installing dependencies via poetry | ||
required: false | ||
default: "--only=code_quality --no-root" | ||
poetry_export_options: | ||
description: Options for exporting dependencies to check for hash | ||
changes for cache invalidation | ||
required: false | ||
default: "--only=code_quality" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up environment | ||
uses: ./actions/python/setup/poetry | ||
with: | ||
python-version: ${{ inputs.python_version }} | ||
poetry-install-options: ${{ inputs.poetry_install_options }} | ||
poetry-export-options: ${{ inputs.poetry_export_options }} | ||
|
||
- name: Check code style | ||
shell: bash | ||
run: poetry run ruff format --check | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
name: Lint Code | ||
description: Lints the code to ensure code quality and adherence to standards. | ||
|
||
inputs: | ||
python_version: | ||
description: Python version to use | ||
default: "3.12" | ||
required: false | ||
poetry_install_options: | ||
description: Options for installing dependencies via poetry | ||
required: false | ||
default: "--only=code_quality --no-root" | ||
poetry_export_options: | ||
description: Options for exporting dependencies to check for hash | ||
changes for cache invalidation | ||
required: false | ||
default: "--only=code_quality" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up environment | ||
uses: ./actions/python/setup/poetry | ||
with: | ||
python-version: ${{ inputs.python_version }} | ||
poetry-install-options: ${{ inputs.poetry_install_options }} | ||
poetry-export-options: ${{ inputs.poetry_export_options }} | ||
|
||
- name: Check code quality | ||
shell: bash | ||
run: poetry run ruff check . | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
name: Spell Check | ||
description: Runs a spell check on the codebase to identify spelling errors. | ||
|
||
inputs: | ||
python_version: | ||
description: Python version to use | ||
default: "3.12" | ||
required: false | ||
poetry_install_options: | ||
description: Options for installing dependencies via poetry | ||
required: false | ||
default: "--only=code_quality --no-root" | ||
poetry_export_options: | ||
description: Options for exporting dependencies to check for hash | ||
changes for cache invalidation | ||
required: false | ||
default: "--only=code_quality" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up environment | ||
uses: ./.github/actions/setup/poetry | ||
with: | ||
python-version: ${{ inputs.python_version }} | ||
poetry-install-options: ${{ inputs.poetry_install_options }} | ||
poetry-export-options: ${{ inputs.poetry_export_options }} | ||
|
||
- name: Check spellings | ||
shell: bash | ||
run: poetry run typos . | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
name: Type Check | ||
description: Runs a type check on the codebase to ensure type safety and | ||
correctness. | ||
|
||
inputs: | ||
python_version: | ||
description: Python version to use | ||
default: "3.12" | ||
required: false | ||
poetry_install_options: | ||
description: Options for installing dependencies via poetry | ||
required: false | ||
default: "--with=code_quality --with=types --no-root" | ||
poetry_export_options: | ||
description: Options for exporting dependencies to check for hash | ||
changes for cache invalidation | ||
required: false | ||
default: "--with=code_quality --with=types" | ||
file_path: | ||
description: The path to the file or directory to type check | ||
required: false | ||
default: " . " | ||
|
||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up environment | ||
uses: ./.github/actions/setup/poetry | ||
with: | ||
python-version: ${{ inputs.python_version }} | ||
poetry-install-options: ${{ inputs.poetry_install_options }} | ||
poetry-export-options: ${{ inputs.poetry_export_options }} | ||
|
||
- name: Check types | ||
shell: bash | ||
run: poetry run mypy ${{ inputs.file_path }} | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
name: Setup Python and Poetry Action | ||
description: Configure system, Python, Poetry and deps and cache management. | ||
|
||
inputs: | ||
os: | ||
default: ubuntu-latest | ||
description: The operating system to use | ||
python_version: | ||
default: '3.11' | ||
description: The version of Python to use | ||
poetry_version: | ||
default: '1.8.2' | ||
description: The version of Poetry to install | ||
poetry_install_options: | ||
default: '' | ||
description: Additional options to pass to poetry install | ||
poetry_export_options: | ||
default: '' | ||
description: Options to pass to poetry export for hash generation for cache | ||
invalidation | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: 'actions/setup-python@v5' | ||
id: setup-python | ||
with: | ||
python_version: '${{ inputs.python_version }}' | ||
|
||
- name: Setup pipx environment Variables | ||
id: pipx-env-setup | ||
# pipx default home and bin dir are not writable by the cache action | ||
# so override them here and add the bin dir to PATH for later steps. | ||
# This also ensures the pipx cache only contains poetry | ||
run: | | ||
SEP="${{ !startsWith(runner.os, 'windows') && '/' || '\\' }}" | ||
PIPX_CACHE="${{ github.workspace }}${SEP}pipx_cache" | ||
echo "pipx-cache-path=${PIPX_CACHE}" >> $GITHUB_OUTPUT | ||
echo "pipx-version=$(pipx --version)" >> $GITHUB_OUTPUT | ||
echo "PIPX_HOME=${PIPX_CACHE}${SEP}home" >> $GITHUB_ENV | ||
echo "PIPX_BIN_DIR=${PIPX_CACHE}${SEP}bin" >> $GITHUB_ENV | ||
echo "PIPX_MAN_DIR=${PIPX_CACHE}${SEP}man" >> $GITHUB_ENV | ||
echo "${PIPX_CACHE}${SEP}bin" >> $GITHUB_PATH | ||
shell: bash | ||
|
||
- name: Pipx cache | ||
id: pipx-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.pipx-env-setup.outputs.pipx-cache-path }} | ||
key: ${{ runner.os }}-python- | ||
${{ steps.setup-python.outputs.python_version }}- | ||
pipx-${{ steps.pipx-env-setup.outputs.pipx-version }}- | ||
poetry-${{ inputs.poetry_version }} | ||
|
||
- name: Install poetry | ||
if: steps.pipx-cache.outputs.cache-hit != 'true' | ||
id: install-poetry | ||
shell: bash | ||
run: | | ||
pipx install poetry \ | ||
--python "${{ steps.setup-python.outputs.python-path }}" | ||
- name: Read poetry cache location | ||
id: poetry-cache-location | ||
shell: bash | ||
run: | | ||
echo "poetry-venv-location=$(poetry config virtualenvs.path)" \ | ||
>> $GITHUB_OUTPUT | ||
- name: Generate hash only for required deps | ||
run: | | ||
poetry export ${{ inputs.poetry_export_options }} \ | ||
--format=requirements.txt --output=requirements.txt | ||
echo "DEP_HASH=$(sha256sum requirements.txt | cut -d ' ' -f 1)" \ | ||
>> $GITHUB_ENV | ||
shell: bash | ||
|
||
- name: Poetry cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.poetry-cache-location.outputs.poetry-venv-location }} | ||
key: ${{ runner.os }}-[python- | ||
${{ steps.setup-python.outputs.python_version }}]-[ | ||
${{ env.DEP_HASH }}]-[${{ inputs.poetry_install_options }}] | ||
|
||
- name: Poetry install | ||
if: steps.poetry-cache.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: poetry install ${{ inputs.poetry_install_options }} --no-interaction | ||
... |