mirror of
https://github.com/Sea-Haven-Industries/.github.git
synced 2026-10-01 02:53:12 +00:00
Enables Python CDK repos (po-ingest, workorder-ingest) to use the same reusable workflow. Adds run-cdk-synth, cdk-dir, and node-version inputs. Refactors dependency install to be shared between pytest and cdk synth paths.
90 lines
2.4 KiB
YAML
90 lines
2.4 KiB
YAML
name: CI — Python / SAM
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
python-version:
|
|
description: "Python version to use"
|
|
type: string
|
|
default: "3.12"
|
|
source-dirs:
|
|
description: "Space-separated directories for ruff (default: repo root)"
|
|
type: string
|
|
default: "."
|
|
run-tests:
|
|
description: "Run pytest"
|
|
type: boolean
|
|
default: false
|
|
run-sam-validate:
|
|
description: "Run sam validate --lint"
|
|
type: boolean
|
|
default: true
|
|
sam-template:
|
|
description: "Path to SAM template file"
|
|
type: string
|
|
default: "template.yaml"
|
|
run-cdk-synth:
|
|
description: "Run cdk synth (for Python CDK repos)"
|
|
type: boolean
|
|
default: false
|
|
cdk-dir:
|
|
description: "Directory containing cdk.json"
|
|
type: string
|
|
default: "cdk"
|
|
node-version:
|
|
description: "Node.js version for CDK CLI"
|
|
type: string
|
|
default: "22"
|
|
|
|
jobs:
|
|
ci:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ inputs.python-version }}
|
|
|
|
- name: Install ruff
|
|
run: pip install ruff
|
|
|
|
- name: Ruff check
|
|
run: ruff check ${{ inputs.source-dirs }}
|
|
|
|
- name: Ruff format check
|
|
run: ruff format --check ${{ inputs.source-dirs }}
|
|
|
|
- name: Install Python dependencies
|
|
if: ${{ inputs.run-tests || inputs.run-cdk-synth }}
|
|
run: |
|
|
if [ "${{ inputs.run-tests }}" = "true" ]; then
|
|
pip install pytest
|
|
fi
|
|
for req in $(find . -name requirements.txt -not -path './.aws-sam/*'); do
|
|
pip install -r "$req"
|
|
done
|
|
|
|
- name: Run tests
|
|
if: ${{ inputs.run-tests }}
|
|
run: pytest
|
|
|
|
- name: Setup Node.js
|
|
if: ${{ inputs.run-cdk-synth }}
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ inputs.node-version }}
|
|
|
|
- name: CDK synth
|
|
if: ${{ inputs.run-cdk-synth }}
|
|
working-directory: ${{ inputs.cdk-dir }}
|
|
run: npx -y cdk synth --quiet
|
|
|
|
- name: Setup SAM CLI
|
|
if: ${{ inputs.run-sam-validate }}
|
|
uses: aws-actions/setup-sam@v2
|
|
|
|
- name: SAM validate
|
|
if: ${{ inputs.run-sam-validate }}
|
|
run: sam validate --lint --template ${{ inputs.sam-template }}
|