Merge pull request #57 from aimingmed/feature/backend-frontend-structure

test ci workflows
This commit is contained in:
Hong Kai LEE 2025-04-16 14:58:05 +08:00 committed by GitHub
commit f140aec0c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 23 additions and 22 deletions

View File

@ -14,11 +14,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Global environment variables accessible in the calling job
env:
PROJECT_NAME: aimingmed-ai
REPO: https://github.com/aimingmed # Updated repo for aimingmed-ai
jobs:
# This job defines the matrix and calls the reusable workflow for each image build
build:
@ -45,6 +40,9 @@ jobs:
- IMAGE_NAME: frontend-aimingmedai
BUILD_CONTEXT: ./app/frontend
DOCKERFILE: ./app/frontend/Dockerfile.test
- IMAGE_NAME: tests-aimingmedai
BUILD_CONTEXT: ./app/tests
DOCKERFILE: ./app/tests/Dockerfile
# Call the reusable workflow
uses: ./.github/workflows/template_build.yml # Path to the reusable workflow file
@ -52,7 +50,7 @@ jobs:
with:
# Pass values from the matrix context and global env
project_name: aimingmed-ai
repo: https://github.com/aimingmed
image_repo: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')
image_name: ${{ matrix.image_config.IMAGE_NAME }}
build_context: ${{ matrix.image_config.BUILD_CONTEXT }}
dockerfile: ${{ matrix.image_config.DOCKERFILE }}
@ -67,8 +65,8 @@ jobs:
# Call the reusable workflow for testing
uses: ./.github/workflows/template_test.yml # Path to the reusable workflow file
with:
projectName: ${{ env.PROJECT_NAME }}
repo: ${{ env.ARTIFACTORY_REPO }}
projectName: aimingmed-ai
image_repo: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')
# Pass test environment variables as JSON string
testEnvs: >
[
@ -91,8 +89,8 @@ jobs:
"env": {
"ENVIRONMENT": "dev",
"TESTING": "1",
"DEEPSEEK_API_KEY": "${{ secrets.DEEPSEEK_API_KEY }}",
"TAVILY_API_KEY": "${{ secrets.TAVILY_API_KEY }}"
"DEEPSEEK_API_KEY": "",
"TAVILY_API_KEY": ""
}
},
@ -105,4 +103,5 @@ jobs:
"LOG_LEVEL": "DEBUG"
}
}
]
]

View File

@ -10,7 +10,7 @@ on:
project_name:
required: true
type: string
repo:
image_repo:
required: true
type: string
image_name:
@ -28,11 +28,7 @@ on:
commit_sha:
required: true
type: string
secrets:
DEEPSEEK_API_KEY:
required: true
TAVILY_API_KEY:
required: true
jobs:
build-single-image:
# This job executes the build steps for the specific image configuration passed via inputs
@ -76,7 +72,7 @@ jobs:
# Define tags consistently using inputs
id: tags
run: |
echo "image_repo_path=ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')/${{ inputs.image_name }}" >> $GITHUB_OUTPUT
echo "image_repo_path=${{ inputs.image_repo }}/${{ inputs.image_name }}" >> $GITHUB_OUTPUT
echo "tag_build_id=${{ inputs.build_id }}" >> $GITHUB_OUTPUT
echo "tag_commit_sha=${{ inputs.commit_sha }}" >> $GITHUB_OUTPUT

View File

@ -6,7 +6,7 @@ on:
projectName:
required: true
type: string
repo:
image_repo:
required: true
type: string
images: # JSON string defining services for compose
@ -35,6 +35,7 @@ on:
required: false
type: string
default: results.xml
jobs:
compose_and_test:
@ -42,7 +43,7 @@ jobs:
runs-on: ubuntu-latest
env:
# Env vars needed for compose file generation/execution
REPO: ${{ inputs.repo }}
IMAGE_REPO: ${{ inputs.image_repo }}
PROJECT_NAME: ${{ inputs.projectName }}
TAG: ${{ github.run_id }} # Use run_id as the build tag
@ -64,8 +65,12 @@ jobs:
run: |
# Load Inputs (parse JSON strings)
$imagesJson = '${{ inputs.images }}'
$deepseekApiKey = '${{ secrets.DEEPSEEK_API_KEY }}'
$tavilyApiKey = '${{ secrets.TAVILY_API_KEY }}'
# Substitute secrets *before* parsing JSON using environment variables
# Be very careful with escaping if secrets contain special JSON characters
$imagesJson = $imagesJson -replace '"DEEPSEEK_API_KEY": ""', "`"DEEPSEEK_API_KEY`": `"$deepseekApiKey`""
$imagesJson = $imagesJson -replace '"TAVILY_API_KEY": ""', "`"TAVILY_API_KEY`": `"$tavilyApiKey`""
Write-Host "Substituted Images JSON: $imagesJson" # Debugging - remove sensitive info if public
$images = $imagesJson | ConvertFrom-Json
@ -80,7 +85,8 @@ jobs:
foreach ($img in $images) {
$serviceName = $img.name
$svc = @{}
$svc.image = "${{ env.REPO }}/${{ env.PROJECT_NAME }}/$($serviceName):${{ env.TAG }}" # Use run_id tag
$svc.image = "${{ env.IMAGE_REPO }}/$($serviceName):${{ env.TAG }}" # Use run_id tag
if ($img.depends_on) {
$svc.depends_on = $img.depends_on
}
@ -159,7 +165,7 @@ jobs:
$ENV_ARGS \
-v "$STAGING_DIR:$RESULTS_PATH" \
--rm \
"${{ inputs.repo }}/${{ inputs.projectName }}/${{ inputs.testContainerName }}:${{ github.run_id }}" \
"${{ env.IMAGE_REPO }}/$($serviceName)/${{ inputs.testContainerName }}:${{ github.run_id }}" \
"$test_dir"
# Add error handling if needed (e.g., exit script if a test run fails)
if [ $? -ne 0 ]; then

0
app/tests/tests/.gitkeep Normal file
View File