Skip to content

Commit

Permalink
AI Lab Recipe Catalog change test pipeline (#2360)
Browse files Browse the repository at this point in the history
* chore(test,ci): adding pipeline for catalog recipe change

Signed-off-by: Tibor Dancs <[email protected]>

* chore(test,ci): pr-review changes

Signed-off-by: Tibor Dancs <[email protected]>

---------

Signed-off-by: Tibor Dancs <[email protected]>
  • Loading branch information
ScrewTSW authored Jan 22, 2025
1 parent fe0a514 commit a33c8ea
Show file tree
Hide file tree
Showing 2 changed files with 302 additions and 0 deletions.
285 changes: 285 additions & 0 deletions .github/workflows/recipe-catalog-change-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
name: Run recipe tests on catalog change

on:
workflow_call:
inputs:
trigger-workflow-run-id:
required: true
type: string
trigger-workflow-fork:
required: true
type: string
trigger-workflow-repo_name:
required: true
type: string
trigger-workflow-branch:
required: true
type: string

jobs:
windows:
name: recipe-catalog-windows-${{ matrix.windows-version }}-${{ matrix.windows-featurepack }}
runs-on: ubuntu-latest
env:
MAPT_VERSION: v0.7.2
MAPT_IMAGE: quay.io/redhat-developer/mapt
strategy:
fail-fast: false
matrix:
windows-version: ['11']
windows-featurepack: ['23h2-ent']

steps:
- name: Get Podman version used by Desktop
run: |
version=$(curl https://raw.githubusercontent.com/containers/podman-desktop/main/extensions/podman/packages/extension/src/podman5.json | jq -r '.version')
echo "Default Podman Version from Podman Desktop: ${version}"
echo "PD_PODMAN_VERSION=${version}" >> $GITHUB_ENV
- name: Set the default env. variables
env:
DEFAULT_FORK: 'containers'
DEFAULT_BRANCH: 'main'
DEFAULT_EXT_TESTS: '1'
DEFAULT_NPM_TARGET: 'test:e2e'
DEFAULT_ENV_VARS: 'TEST_PODMAN_MACHINE=true,ELECTRON_ENABLE_INSPECT=true'
DEFAULT_PODMAN_OPTIONS: 'INIT=1,START=1,ROOTFUL=1,NETWORKING=0'
DEFAULT_RUN_TEST_AS_ADMIN: '1'
DEFAULT_EXT_REPO_OPTIONS: 'REPO=podman-desktop-extension-ai-lab,FORK=containers,BRANCH=main'
DEFAULT_PODMAN_VERSION: "${{ env.PD_PODMAN_VERSION || '5.3.1' }}"
DEFAULT_URL: "https://github.com/containers/podman/releases/download/v$DEFAULT_PODMAN_VERSION/podman-$DEFAULT_PODMAN_VERSION-setup.exe"
DEFAULT_PDE2E_IMAGE_VERSION: 'v0.0.3-windows'
DEFAULT_AZURE_VM_SIZE: 'Standard_D8as_v5'
run: |
echo "FORK=${{ env.DEFAULT_FORK }}" >> $GITHUB_ENV
echo "BRANCH=${{ env.DEFAULT_BRANCH }}" >> $GITHUB_ENV
echo "NPM_TARGET=${{ env.DEFAULT_NPM_TARGET }}" >> $GITHUB_ENV
echo "ENV_VARS=${{ env.DEFAULT_ENV_VARS }}" >> $GITHUB_ENV
echo "PODMAN_URL=${{ env.DEFAULT_URL }}" >> $GITHUB_ENV
echo "PDE2E_IMAGE_VERSION=${{ env.DEFAULT_PDE2E_IMAGE_VERSION }}" >> $GITHUB_ENV
echo "EXT_TESTS=${{ env.DEFAULT_EXT_TESTS }}" >> $GITHUB_ENV
echo "RUN_TEST_AS_ADMIN=${{ env.DEFAULT_RUN_TEST_AS_ADMIN }}" >> $GITHUB_ENV
if [[ -z "${{ inputs.trigger-workflow-repo_name }}" ]] && [[ -z "${{ inputs.trigger-workflow-fork }}" ]] && [[ -z "${{ inputs.trigger-workflow-branch }}" ]]; then
echo "DEFAULT_EXT_REPO_OPTIONS=REPO=${{ inputs.trigger-workflow-repo_name }},FORK=${{ inputs.trigger-workflow-fork }},BRANCH=${{ inputs.trigger-workflow-branch }}" >> $GITHUB_ENV
fi
echo "${{ env.DEFAULT_PODMAN_OPTIONS }}" | awk -F ',' \
'{for (i=1; i<=NF; i++) {split($i, kv, "="); print "PODMAN_"kv[1]"="kv[2]}}' >> $GITHUB_ENV
echo "${{ env.DEFAULT_EXT_REPO_OPTIONS }}" | awk -F ',' \
'{for (i=1; i<=NF; i++) {split($i, kv, "="); print "EXT_"kv[1]"="kv[2]}}' >> $GITHUB_ENV
echo "AZURE_VM_SIZE=${{ env.DEFAULT_AZURE_VM_SIZE }}" >> $GITHUB_ENV
- name: Download gh context
id: download-gh-context-artifact
uses: actions/download-artifact@v4
with:
name: gh-context
run-id: ${{inputs.trigger-workflow-run-id}}
github-token: ${{ github.token }}

- name: Correlate
run: |
# Get origin commit sha for testing
commit_sha=$(cat gh_context.json | jq -r '.event.after')
if [[ -z "${commit_sha}" ]] || [[ "${commit_sha}" == null ]]; then
# on first PR creation .event.after is empty, then .sha is used as commit instead
commit_sha=$(cat gh_context.json | jq -r '.event.pull_request.head.sha')
fi
echo "commit_sha=${commit_sha}" >> "$GITHUB_ENV"
# Set status_context
status_context="ci/gh/e2e/windows-${{matrix.windows-version}}-${{matrix.windows-featurepack}}"
echo "status_context=${status_context}" >> "$GITHUB_ENV"
- name: Add status to the PR check
run: |
set -xuo
# Status msg
data="{\"state\":\"pending\""
data="${data},\"description\":\"recipe tests on catalog change on Windows 11\""
data="${data},\"context\":\"${{ env.status_context }}\""
data="${data},\"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
# Create status by API call
curl -L -v -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.commit_sha }} \
-d "${data}"
- name: Create instance
run: |
# Create instance
podman run -d --name windows-create --rm \
-v ${PWD}:/workspace:z \
-e ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }} \
-e ARM_SUBSCRIPTION_ID=${{ secrets.ARM_SUBSCRIPTION_ID }} \
-e ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }} \
-e ARM_CLIENT_SECRET='${{ secrets.ARM_CLIENT_SECRET }}' \
${{ env.MAPT_IMAGE }}:${{ env.MAPT_VERSION }} azure \
windows create \
--project-name 'windows-desktop' \
--backed-url 'file:///workspace' \
--conn-details-output '/workspace' \
--windows-version '${{ matrix.windows-version }}' \
--windows-featurepack '${{ matrix.windows-featurepack }}' \
--vmsize '${{ env.AZURE_VM_SIZE }}' \
--tags project=podman-desktop \
--spot
# Check logs
podman logs -f windows-create
- name: Check instance system info
run: |
ssh -i id_rsa \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o ServerAliveInterval=30 \
-o ServerAliveCountMax=1200 \
$(cat username)@$(cat host) "systeminfo"
- name: Emulate X session
run: |
# use fake rdp to emulate an active x session
podman run -d --name x-session \
-e RDP_HOST=$(cat host) \
-e RDP_USER=$(cat username) \
-e RDP_PASSWORD=$(cat userpassword) \
quay.io/rhqp/frdp:v0.0.1
# Wait until the x session has been created
podman wait --condition running x-session
# Check logs for the x session
podman logs x-session
- name: Download Podman, do not initialize
run: |
podman run --rm -d --name pde2e-podman-run \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=pd-e2e \
-e TARGET_CLEANUP=false \
-e TARGET_RESULTS=results \
-e OUTPUT_FOLDER=/data \
-e DEBUG=true \
-v $PWD:/data:z \
quay.io/odockal/pde2e-podman:${{ env.PDE2E_IMAGE_VERSION }} \
pd-e2e/podman.ps1 \
-downloadUrl ${{ env.PODMAN_URL }} \
-targetFolder pd-e2e \
-resultsFolder results \
-initialize 0 \
-rootful 0 \
-start 0 \
-installWSL 0
# check logs
podman logs -f pde2e-podman-run
- name: Build Podman Desktop Electron Inspect Enabled binary
run: |
podman run --rm -d --name pde2e-builder-run \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=pd-e2e \
-e TARGET_CLEANUP=false \
-e TARGET_RESULTS=results \
-e OUTPUT_FOLDER=/data \
-e DEBUG=true \
-v $PWD:/data:z \
quay.io/odockal/pde2e-builder:${{ env.PDE2E_IMAGE_VERSION }} \
pd-e2e/builder.ps1 \
-targetFolder pd-e2e \
-resultsFolder results \
-fork ${{ env.FORK }} \
-branch ${{ env.BRANCH }} \
-envVars ${{ env.ENV_VARS }}
# check logs
podman logs -f pde2e-builder-run
- name: Run Podman Desktop Playwright E2E tests
run: |
podman run -d --name pde2e-runner-run \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e TARGET_FOLDER=pd-e2e \
-e TARGET_RESULTS=results \
-e OUTPUT_FOLDER=/data \
-e DEBUG=true \
-v $PWD:/data:z \
quay.io/odockal/pde2e-runner:${{ env.PDE2E_IMAGE_VERSION }} \
pd-e2e/runner.ps1 \
-targetFolder pd-e2e \
-resultsFolder results \
-podmanPath $(cat results/podman-location.log) \
-pdPath "$(cat results/pde2e-binary-path.log | tr '\n' " ")" \
-fork ${{ env.FORK }} \
-branch ${{ env.BRANCH }} \
-extRepo ${{ env.EXT_REPO }} \
-extFork ${{ env.EXT_FORK }} \
-extBranch ${{ env.EXT_BRANCH }} \
-extTests ${{ env.EXT_TESTS }} \
-npmTarget ${{ env.NPM_TARGET }} \
-initialize ${{ env.PODMAN_INIT }} \
-rootful ${{ env.PODMAN_ROOTFUL }} \
-start ${{ env.PODMAN_START }} \
-userNetworking ${{ env.PODMAN_NETWORKING }} \
-envVars ${{ env.ENV_VARS }} \
-runAsAdmin ${{ env.RUN_TEST_AS_ADMIN }}
# check logs
podman logs -f pde2e-runner-run
- name: Destroy instance
if: always()
run: |
# Destroy instance
podman run -d --name windows-destroy --rm \
-v ${PWD}:/workspace:z \
-e ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }} \
-e ARM_SUBSCRIPTION_ID=${{ secrets.ARM_SUBSCRIPTION_ID }} \
-e ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }} \
-e ARM_CLIENT_SECRET='${{ secrets.ARM_CLIENT_SECRET }}' \
${{ env.MAPT_IMAGE }}:${{ env.MAPT_VERSION }} azure \
windows destroy \
--project-name 'windows-desktop' \
--backed-url 'file:///workspace'
# Check logs
podman logs -f windows-destroy
- name: Update status of the PR check
if: always()
run: |
set -xuo
# Status msg
data="{\"state\":\"success\""
if [[ ${{steps.test-report.outcome}} != "success" ]]; then
data="{\"state\":\"failure\""
fi
data="${data},\"description\":\"Finished ${{inputs.qe-type}}-${{inputs.preset}} on Windows\""
data="${data},\"context\":\"${{ env.status_context }}\""
data="${data},\"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"
# Create status by API call
curl -L -v -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.commit_sha }} \
-d "${data}"
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: always() # always run even if the previous step fails
with:
annotate_only: true
fail_on_failure: true
include_passed: true
detailed_summary: true
require_tests: true
report_paths: '**/*results.xml'

- name: Upload test artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: results-e2e-${{ matrix.windows-version }}${{ matrix.windows-featurepack }}
path: |
results/*
!results/**/*.gguf
17 changes: 17 additions & 0 deletions .github/workflows/recipe-catalog-change-trigger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: recipe-catalog-change-windows-trigger

on:
pull_request:
paths:
- 'packages/backend/src/assets/ai.json'

jobs:
windows-e2e-recipe-change:
uses: containers/podman-desktop-extension-ai-lab/.github/workflows/recipe-catalog-change-template.yaml@main
strategy:
fail-fast: false
with:
trigger-workflow-run-id: ${{ github.event.action.run_id }}
trugger-workflow-fork: ${{ github.event.pull_request.head.repo.organization }}
trigger-workflow-repo_name: ${{ github.event.pull_request.head.repo.name }}
trigger-workflow-branch: ${{ github.event.pull_request.head.ref }}

0 comments on commit a33c8ea

Please sign in to comment.