Skip to content

Improvements to Container CD #6

Improvements to Container CD

Improvements to Container CD #6

Workflow file for this run

# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
name: Example Integration Tests
on:
pull_request: null
permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
example-diff:
runs-on: ubuntu-latest
outputs:
examples: ${{ steps.example-list.outputs.FOLDERS }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Output Modified example Directories
id: example-list
run: |
# Get diff array filtered by specific filetypes
DIFF=$(git diff --diff-filter=d \
--name-only ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} \
-- '*/*Dockerfile' '*.py' '*.yaml' '*.yml' '*.sh' '*/*requirements.txt' '*.json' '*.ts' '*.js' | \
jq -R '.' | jq -sc '.' \
)
# Search for compose files in each file to determine the container examples
DOCKER_COMPOSE_PATHS=()
for path in $(echo $DIFF | jq -r '.[]'); do
while [[ "$path" != "." ]]; do
DIR_PATH=$(dirname "$path")
if [ -n "$(find "$DIR_PATH" -maxdepth 1 -name 'docker-compose.yaml' -print -quit)" ] && [ "$DIR_PATH" != "." ]; then
DOCKER_COMPOSE_PATHS+=("$DIR_PATH")
path="."
else
path="$DIR_PATH"
fi
done
done
# Convert the array to a JSON array
DOCKER_COMPOSE_PATHS_JSON=$(printf '%s\n' "${DOCKER_COMPOSE_PATHS[@]}" | jq -R '.' | jq -sc 'unique_by(.)')
echo "FOLDERS=$DOCKER_COMPOSE_PATHS_JSON" >> $GITHUB_OUTPUT
pipeline-ci:
needs: example-diff
if: needs.example-diff.outputs.examples != '[""]'
strategy:
matrix:
example: ${{ fromJson(needs.example-diff.outputs.examples) }}
experimental: [true]
fail-fast: false
uses: opea/genaiexamples/.github/workflows/container-ci.yaml@main

Check failure on line 57 in .github/workflows/example-ci.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/example-ci.yml

Invalid workflow file

error parsing called workflow ".github/workflows/example-ci.yml" -> "opea/genaiexamples/.github/workflows/container-ci.yaml@main" : workflow was not found. See https://docs.github.com/actions/learn-github-actions/reusing-workflows#access-to-reusable-workflows for more information.
with:
example_dir: ${{ matrix.example }}
scan: true
test: true
publish: false
secrets: inherit
status-check:
needs: [example-diff, pipeline-ci]
runs-on: ubuntu-latest
if: always()
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
&& needs.example-diff.outputs.examples != '[""]'
}}