actions
This commit is contained in:
116
.github/actions/api-quality/action.yml
vendored
Normal file
116
.github/actions/api-quality/action.yml
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
name: API Quality
|
||||
description: Run Python uv quality checks for API services (format, lint, typecheck, tests).
|
||||
|
||||
inputs:
|
||||
python_version:
|
||||
description: Python version to use.
|
||||
required: false
|
||||
default: "3.13"
|
||||
uv_version:
|
||||
description: uv version to install.
|
||||
required: false
|
||||
default: "latest"
|
||||
working_directory:
|
||||
description: Working directory for commands.
|
||||
required: false
|
||||
default: "."
|
||||
cache_dependency_path:
|
||||
description: Path used for cache key hashing.
|
||||
required: false
|
||||
default: "uv.lock"
|
||||
env:
|
||||
description: >
|
||||
Multiline env vars, one per line: KEY=VALUE
|
||||
required: false
|
||||
default: ""
|
||||
uv_sync_args:
|
||||
description: Arguments for uv sync.
|
||||
required: false
|
||||
default: "--frozen --dev"
|
||||
format_command:
|
||||
description: Command for format checking.
|
||||
required: false
|
||||
default: "uv run ruff format --check ."
|
||||
lint_command:
|
||||
description: Command for linting.
|
||||
required: false
|
||||
default: "uv run ruff check ."
|
||||
typecheck_command:
|
||||
description: Command for type checking.
|
||||
required: false
|
||||
default: "uv run mypy ."
|
||||
test_command:
|
||||
description: Command for tests.
|
||||
required: false
|
||||
default: "uv run pytest"
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Load env vars
|
||||
if: ${{ inputs.env != '' }}
|
||||
shell: bash
|
||||
run: |
|
||||
while IFS= read -r line; do
|
||||
[ -z "$line" ] && continue
|
||||
case "$line" in \#*) continue;; esac
|
||||
if [[ "$line" != *=* ]]; then
|
||||
echo "Invalid env line: $line" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "$line" >> "$GITHUB_ENV"
|
||||
done <<< "${{ inputs.env }}"
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ inputs.python_version }}
|
||||
|
||||
- name: Install uv
|
||||
shell: bash
|
||||
env:
|
||||
UV_VERSION: ${{ inputs.uv_version }}
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
if [ -z "$UV_VERSION" ] || [ "$UV_VERSION" = "latest" ]; then
|
||||
python -m pip install uv
|
||||
else
|
||||
python -m pip install "uv==$UV_VERSION"
|
||||
fi
|
||||
|
||||
- name: Cache uv downloads
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/uv
|
||||
key: uv-${{ runner.os }}-${{ hashFiles(inputs.cache_dependency_path) }}
|
||||
restore-keys: |
|
||||
uv-${{ runner.os }}-
|
||||
|
||||
- name: Sync dependencies
|
||||
shell: bash
|
||||
run: uv sync ${{ inputs.uv_sync_args }}
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
|
||||
- name: Run format check
|
||||
if: ${{ inputs.format_command != '' }}
|
||||
shell: bash
|
||||
run: ${{ inputs.format_command }}
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
|
||||
- name: Run lint
|
||||
if: ${{ inputs.lint_command != '' }}
|
||||
shell: bash
|
||||
run: ${{ inputs.lint_command }}
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
|
||||
- name: Run typecheck
|
||||
if: ${{ inputs.typecheck_command != '' }}
|
||||
shell: bash
|
||||
run: ${{ inputs.typecheck_command }}
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
|
||||
- name: Run tests
|
||||
if: ${{ inputs.test_command != '' }}
|
||||
shell: bash
|
||||
run: ${{ inputs.test_command }}
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
65
.github/workflows/node-ci.yml
vendored
65
.github/workflows/node-ci.yml
vendored
@@ -40,13 +40,12 @@ on:
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
quality:
|
||||
setup:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
outputs:
|
||||
node-cache-hit: ${{ steps.cache.outputs.cache-hit }}
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Load env vars
|
||||
if: ${{ inputs.env != '' }}
|
||||
@@ -54,10 +53,6 @@ jobs:
|
||||
while IFS= read -r line; do
|
||||
[ -z "$line" ] && continue
|
||||
case "$line" in \#*) continue;; esac
|
||||
if [[ "$line" != *=* ]]; then
|
||||
echo "Invalid env line: $line" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "$line" >> "$GITHUB_ENV"
|
||||
done <<< "${{ inputs.env }}"
|
||||
|
||||
@@ -74,41 +69,51 @@ jobs:
|
||||
printf '%s\n' "${{ secrets.ssh_known_hosts }}" >> ~/.ssh/known_hosts
|
||||
chmod 644 ~/.ssh/known_hosts
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ inputs.node_version }}
|
||||
cache: pnpm
|
||||
cache-dependency-path: ${{ inputs.cache_dependency_path }}
|
||||
|
||||
- name: Enable corepack
|
||||
run: corepack enable
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
|
||||
- name: Install pnpm
|
||||
run: corepack prepare pnpm@${{ inputs.pnpm_version }} --activate
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
- run: corepack enable
|
||||
- run: corepack prepare pnpm@${{ inputs.pnpm_version }} --activate
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
|
||||
- name: Run format check
|
||||
if: ${{ inputs.format_command != '' }}
|
||||
run: ${{ inputs.format_command }}
|
||||
format:
|
||||
needs: setup
|
||||
if: ${{ inputs.format_command != '' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: ${{ inputs.format_command }}
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
|
||||
- name: Run lint
|
||||
if: ${{ inputs.lint_command != '' }}
|
||||
run: ${{ inputs.lint_command }}
|
||||
lint:
|
||||
needs: setup
|
||||
if: ${{ inputs.lint_command != '' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: ${{ inputs.lint_command }}
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
|
||||
- name: Run typecheck
|
||||
if: ${{ inputs.typecheck_command != '' }}
|
||||
run: ${{ inputs.typecheck_command }}
|
||||
typecheck:
|
||||
needs: setup
|
||||
if: ${{ inputs.typecheck_command != '' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: ${{ inputs.typecheck_command }}
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
|
||||
- name: Run tests
|
||||
if: ${{ inputs.test_command != '' }}
|
||||
run: ${{ inputs.test_command }}
|
||||
tests:
|
||||
needs: [setup, lint, typecheck]
|
||||
if: ${{ inputs.test_command != '' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: ${{ inputs.test_command }}
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
|
||||
Reference in New Issue
Block a user