77 lines
2.0 KiB
YAML
77 lines
2.0 KiB
YAML
name: Build Python App
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
app:
|
|
required: true
|
|
type: string
|
|
dockerTag:
|
|
required: true
|
|
type: string
|
|
enabled:
|
|
required: true
|
|
type: boolean
|
|
shouldBuild:
|
|
required: true
|
|
type: boolean
|
|
|
|
|
|
jobs:
|
|
build-python:
|
|
if: ${{ inputs.enabled && inputs.shouldBuild }}
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
cd apps/${{ inputs.app }}
|
|
if [ -f requirements.txt ]; then
|
|
pip install -r requirements.txt
|
|
fi
|
|
|
|
# Install test dependencies (pytest, asyncio test libs, etc.)
|
|
- name: Install test dependencies
|
|
run: |
|
|
cd apps/${{ inputs.app }}
|
|
if [ -f requirements-test.txt ]; then
|
|
pip install -r requirements-test.txt
|
|
fi
|
|
|
|
|
|
# Run Python tests
|
|
- name: Run Python tests
|
|
run: |
|
|
cd apps/${{ inputs.app }}
|
|
python -m pytest -q
|
|
|
|
# Build Docker image locally
|
|
- name: Build Docker image locally
|
|
run: |
|
|
docker build \
|
|
-f ./dockerfiles/Python \
|
|
-t local-${{ inputs.app }}:${{ inputs.dockerTag }} \
|
|
--build-arg MODULE_NAME=${{ inputs.app }} \
|
|
.
|
|
|
|
# Smoke-test the container
|
|
- name: Test Docker container
|
|
run: |
|
|
docker run --rm local-${{ inputs.app }}:${{ inputs.dockerTag }} /bin/sh -c "echo 'Smoke test OK'"
|
|
|
|
# Push final image
|
|
- name: Push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./dockerfiles/Python
|
|
build-args: |
|
|
MODULE_NAME=${{ inputs.app }}
|
|
push: true
|
|
tags: |
|
|
bskjon/mediaprocessing-${{ inputs.app }}:v5
|
|
bskjon/mediaprocessing-${{ inputs.app }}:v5-${{ inputs.dockerTag }}
|
|
bskjon/mediaprocessing-${{ inputs.app }}:v5-${{ github.sha }}
|