Skip to content

Components workflow

Components workflow #7

Workflow file for this run

name: Components workflow
on:
workflow_call:
inputs:
component_dir:
description: "Dir in root directory"
type: string
required: true
build_version:
description: "Specifies the build version to apply to all binaries produced by this workflow"
type: string
required: true
publish_binaries:
description: "Enable publishing binaries to repos"
type: boolean
default: false
ref:
description: 'The branch, tag or SHA to checkout'
type: string
default: ""
secrets:
AWS_ROLE:
required: true
AWS_REGION:
required: true
REGISTRY:
required: true
workflow_dispatch:
inputs:
ref:
description: 'The branch, tag or SHA to checkout'
required: true
default: "main"
component_dir:
description: "Path to the component (relative to the root of the repository)"
required: true
permissions: { } # No permissions by default on workflow level
env:
COMPONENT_DIR: ${{ inputs.component_dir }}
jobs:
component-check:
name: Component workflow
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
timeout-minutes: 30
env:
TAG: ${{ inputs.build_version || github.sha }}
REGISTRY: ${{ secrets.REGISTRY }}
PYTHON_BUILDER_IMAGE: builder-images/python-builder:v0.1
GO_BUILDER_IMAGE: builder-images/go-builder:v0.1
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
ref: ${{ inputs.ref || '' }}
- name: Read component config
id: component-config
uses: ./.github/actions/read-component-config
with:
component_dir: ${{ env.COMPONENT_DIR }}
- name: Initial cleanup
if: steps.component-config.outputs.cleanup_type == 'initial' || steps.component-config.outputs.cleanup_type == 'all'
uses: ./.github/actions/cleanup-runner
with:
type: 'initial'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df # v4.2.1
with:
role-to-assume: ${{ secrets.AWS_ROLE }}
role-session-name: Github
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
- name: Check if Python/Go project
id: check-python-go
run: |
BUILDER_IMAGE=""
if [ -f "${COMPONENT_DIR}/setup.py" ] || [ -f "${COMPONENT_DIR}/pyproject.toml" ] || [ -f "${COMPONENT_DIR}/.python" ]; then
BUILDER_IMAGE=${REGISTRY}/${PYTHON_BUILDER_IMAGE}
elif [ -f "${COMPONENT_DIR}/go.mod" ] || [ -f "${COMPONENT_DIR}/.go" ]; then
BUILDER_IMAGE=${REGISTRY}/${GO_BUILDER_IMAGE}
fi
echo "BUILDER_IMAGE=${BUILDER_IMAGE}" >> $GITHUB_ENV
echo "BUILDER_IMAGE=${BUILDER_IMAGE}"
- name: Static code analysis
run: make builder -C "${COMPONENT_DIR}" static-code-analysis
- name: Unit testing
run: make builder -C "${COMPONENT_DIR}" test-unit
- name: Integration testing
run: |
if [[ "${{ steps.component-config.outputs.integration_builder }}" == "false" ]]; then
sudo apt-get update && sudo apt-get install -y ffmpeg && make -C "${COMPONENT_DIR}" test-integration
else
make builder -C "${COMPONENT_DIR}" test-integration
fi
- name: Pre-build cleanup
if: steps.component-config.outputs.cleanup_type == 'pre-build' || steps.component-config.outputs.cleanup_type == 'all'
uses: ./.github/actions/cleanup-runner
with:
type: 'pre-build'
- name: Build image
id: build-image
run: |
OUTPUT=$(make -C "${COMPONENT_DIR}" build-image)
if echo "$OUTPUT" | grep -q "Skipping"; then
echo "SKIP_IMAGE=true" >> $GITHUB_OUTPUT
fi
- name: Push image
if: steps.build-image.outputs.SKIP_IMAGE != 'true' && inputs.publish_binaries
run: make -C "${COMPONENT_DIR}" publish-image
- name: Lint chart
if: steps.build-image.outputs.SKIP_IMAGE != 'true'
run: make -C "${COMPONENT_DIR}" lint-chart
- name: Publish chart
if: steps.build-image.outputs.SKIP_IMAGE != 'true' && inputs.publish_binaries
run: make -C "${COMPONENT_DIR}" publish-chart