Skip to content

Changed test needs

Changed test needs #3

Workflow file for this run

name: Build and Deploy Evaluation Function to Lambda Feedback
on:
workflow_call:
inputs:
template-repository-name:
type: string
description: "The name of the repository where the template is located"
required: true
environment:
type: string
description: "Deploy to staging or production"
required: true
default: staging
region:
type: string
description: "The AWS region to deploy to"
required: false
build-file:
type: string
description: "The path to the Dockerfile to build"
required: false
default: "Dockerfile"
build-context:
type: string
description: "The context to use for the Docker build"
required: false
default: "."
build-target:
type: string
description: "The target stage of the image to build"
required: false
build-args:
type: string
description: "The build arguments to pass to the Docker build"
required: false
build-platforms:
type: string
description: "The platforms to build the image for"
default: "aws"
required: false
version-bump:
type: string
description: "Used for prod: The version number to bump (major, minor or patch)"
required: false
default: "patch"
branch:
type: string
description: "Used for prod: The branch to deploy"
required: false
default: "main"
lfs:
type: boolean
description: "Support git LFS"
default: false
required: false
test-api-endpoint:
type: string
description: "The base API URL for running tests against an evaluation function (staging endpoint)"
required: false
run-tests:
type: boolean
description: "Set to true to run the pre-production validation tests."
required: false
default: false
secrets:
aws-key-id:
description: "The AWS access key ID"
required: true
aws-secret-key:
description: "The AWS secret access key"
required: true
function-admin-api-key:
description: "The API key for the Lambda Feedback function admin API"
required: true
build-secrets:
description: "The Docker secrets to use for the build"
required: false
gcp_credentials:
description: "The JSON key for deploying to GCP"
required: false
TEST_API_ENDPOINT:
description: "The staging evaluation function to use to test against the database"
required: false
DB_USER:
description: "Database User for fetching test data"
required: false
DB_PASSWORD:
description: "Database Password for fetching test data"
required: false
DB_HOST:
description: "Database Host for fetching test data"
required: false
DB_PORT:
description: "Database Port for fetching test data"
required: false
DB_NAME:
description: "Database Name for fetching test data"
required: false
jobs:

Check failure on line 102 in .github/workflows/deploy.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/deploy.yml

Invalid workflow file

You have an error in your yaml syntax on line 102
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
evaluation_function_name: ${{ inputs.build-platforms == 'aws' && steps.evaluation_function_name.outputs.name || steps.normalize-function-name.outputs.name }}
region: ${{ steps.set-region.outputs.region }}
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: ${{inputs.lfs}}
- name: Set up boilerplate config.json
if: github.repository == inputs.template-repository-name
run: |
functionName=$(echo "${{ github.event.repository.name }}" | sed -E 's/([A-Z])([A-Z]*)/\L\1\2/g' | sed -E 's/-([a-z])/\U\1/g' | tr -d '-')
echo "{\"EvaluationFunctionName\": \"$functionName\"}" > config.json
- name: Check for config.json
run: |
if [[ ! -f "config.json" ]]; then echo "Error: config.json not found."; exit 1; fi
- name: Read config.json
id: config
run: |
echo 'config<<EOF' >> $GITHUB_OUTPUT
cat ./config.json >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Get Evaluation Function Name
id: evaluation_function_name
run: |
functionName="${{fromJson(steps.config.outputs.config).EvaluationFunctionName}}"
if [[ -z "$functionName" ]]; then echo "Set EvaluationFunctionName in config.json"; exit 1; fi
echo "name=$functionName" >> "$GITHUB_OUTPUT"
- name: Setup normalize function name
if: inputs.build-platforms != 'aws'
id: setup-normalize-function-name
uses: Entepotenz/change-string-case-action-min-dependencies@v1
with:
string: ${{ steps.evaluation_function_name.outputs.name }}
- name: Normalize function name
if: inputs.build-platforms != 'aws'
id: normalize-function-name
run: echo name=${{steps.setup-normalize-function-name.outputs.lowercase}} >> $GITHUB_OUTPUT
- name: Set default region based on platform
id: set-region
run: |
if [[ -n "${{ inputs.region }}" ]]; then
region="${{ inputs.region }}"
elif [[ "${{ inputs.build-platforms }}" == "aws" ]]; then
region="eu-west-2"
else
region="europe-west2"
fi
echo "region=$region" >> "$GITHUB_OUTPUT"
- name: Validate AWS secrets for AWS platform
if: inputs.build-platforms == 'aws'
run: |
if [[ -z "${{ secrets.aws-key-id }}" ]]; then
echo "Error: aws-key-id secret is required when build-platforms is 'aws'"
exit 1
fi
if [[ -z "${{ secrets.aws-secret-key }}" ]]; then
echo "Error: aws-secret-key secret is required when build-platforms is 'aws'"
exit 1
fi
if [[ -z "${{ secrets.function-admin-api-key }}" ]]; then
echo "Error: function-admin-api-key secret is required when build-platforms is 'aws'"
exit 1
fi
deploy-staging:
if: ${{inputs.environment == 'staging' || inputs.environment == 'production'}}
uses: ./.github/workflows/staging_deploy.yml
needs: setup
with:
evaluation_function_name: ${{ needs.setup.outputs.evaluation_function_name }}
template-repository-name: ${{ inputs.template-repository-name }}
region: ${{ needs.setup.outputs.region }}
build-file: ${{ inputs.build-file }}
build-context: ${{ inputs.build-context }}
build-target: ${{ inputs.build-target }}
build-args: ${{inputs.build-args}}
build-platforms: ${{inputs.build-platforms}}
lfs: ${{inputs.lfs}}
secrets:
aws-key-id: ${{ secrets.aws-key-id }}
aws-secret-key: ${{ secrets.aws-secret-key }}
function-admin-api-key: ${{ secrets.function-admin-api-key }}
build-secrets: ${{ secrets.build-secrets }}
gcp_credentials: ${{ secrets.gcp_credentials }}
run-pre-production-tests:
name: 🧪 Run Staging Validation Tests
if: ${{ inputs.environment == 'production' && needs.deploy-staging.result == 'success' && inputs.run-tests }}
uses: lambda-feedback/Database-Testing/.github/workflows/test_evaluation_function.yml@main
needs: [setup, deploy-staging]
with:
eval_function: ${{ needs.setup.outputs.evaluation_function_name }}
sql_limit: 500
secrets:
TEST_API_ENDPOINT: ${{ secrets.TEST_API_ENDPOINT }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_HOST: ${{ secrets.DB_HOST }}
DB_PORT: ${{ secrets.DB_PORT }}
DB_NAME: ${{ secrets.DB_NAME }}
deploy-production:
if: >
${{ inputs.environment == 'production' &&
( (inputs.run-tests && needs.run-pre-production-tests.result == 'success') ||
(!inputs.run-tests && needs.deploy-staging.result == 'success')
) }}
uses: ./.github/workflows/production_deploy.yml
needs:
- setup
- deploy-staging
- ${{ fromJSON(format('["{0}"]', inputs.run-tests == true && 'run-pre-production-tests' || ''))[0] }}
with:
evaluation_function_name: ${{ needs.setup.outputs.evaluation_function_name }}
template-repository-name: ${{ inputs.template-repository-name }}
region: ${{ needs.setup.outputs.region }}
build-file: ${{ inputs.build-file }}
build-context: ${{ inputs.build-context }}
build-target: ${{ inputs.build-target }}
build-args: ${{inputs.build-args}}
build-platforms: ${{inputs.build-platforms}}
version-bump: ${{inputs.version-bump}}
branch: ${{inputs.branch}}
lfs: ${{inputs.lfs}}
secrets:
aws-key-id: ${{ secrets.aws-key-id }}
aws-secret-key: ${{ secrets.aws-secret-key }}
function-admin-api-key: ${{ secrets.function-admin-api-key }}
build-secrets: ${{ secrets.build-secrets }}
gcp_credentials: ${{ secrets.gcp_credentials }}