WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

OST trigger

OST trigger #109

Workflow file for this run

#
# This is a reusable worflow to be triggered from other projects or manually.
# See example-trigger.yaml for how to use it in other projects.
# If you call this via a different trigger than on: issue_comment you can use the optional parameter:
# comment - full comment body, e.g. "/ost he-basic-suite-master el9stream"
#
name: OST trigger
on:
workflow_call:
inputs:
comment:
required: false
type: string
pr_url:
required: false
type: string
workflow_dispatch:
inputs:
pr_url:
description: "PR url(s - comma separated)"
type: string
comment:
required: true
default: "/ost basic-suite-master el9stream"
type: string
permissions:
pull-requests: write
jobs:
trigger-ost:
env:
GITHUB_REPORT_FILE: md_report.md
OST_DEPLOYMENT: /opt/actions-runner/_work/ost_deployment
runs-on: ost-trigger
if: github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
( github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/ost') && (
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR')
)
steps:
- name: Set environment variables
env:
PR_URL: "${{ github.event.issue.pull_request.url }}${{ inputs.pr_url }}"
COMMENT: "${{ github.event.comment.body }}${{ inputs.comment }}"
run: |
SUITE=$(echo "$COMMENT" | cut -d " " -s -f2)
DISTRO=$(echo "$COMMENT" | cut -d " " -s -f3)
SUITE=${SUITE:-basic-suite-master}
DISTRO=${DISTRO:-el9stream}
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
OST_REPO="oVirt/ovirt-system-tests"
OST_REF="master"
if [ -n "$PR_URL" ]; then
IFS=',' read -ra PR_URLS <<< "$PR_URL"
for url in "${PR_URLS[@]}"; do
if [[ "$url" == *"$OST_REPO"* ]]; then
OST_REF=$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
$url | jq -r '.head.ref')
fi
done
fi
echo "SUITE=$SUITE" >> $GITHUB_ENV
echo "DISTRO=$DISTRO" >> $GITHUB_ENV
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
echo "COMMENT=$COMMENT" >> $GITHUB_ENV
echo "RUN_URL=$RUN_URL" >> $GITHUB_ENV
echo "OST_REF=$OST_REF" >> $GITHUB_ENV
echo "==== RUN PARAMS ========"
echo "PR_URL: $PR_URL"
echo "COMMENT: $COMMENT"
echo "SUITE: $SUITE"
echo "DISTRO: $DISTRO"
echo "========================"
- name: Checkout
uses: actions/checkout@v4
with:
repository: oVirt/ovirt-system-tests
ref: ${{ env.OST_REF }}
- name: Setup ost
run: |
/usr/bin/bash common/helpers/ost-image-packages.sh $SUITE $DISTRO
if [ -f ost_image_vars.json ]; then
jq . ost_image_vars.json
/usr/bin/bash setup_for_ost.sh ost_image_vars.json -y
else
/usr/bin/bash setup_for_ost.sh -y
fi
- name: Comment on PR that ost is running
if: github.event_name != 'workflow_dispatch'
run: |
HERE="[here]($RUN_URL)"
MSG=":hourglass_flowing_sand: Running ost suite **'$SUITE'** on distro **'$DISTRO'**. \n\nFollow the progress $HERE."
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
${{ github.event.issue.url }}/comments \
-d "{\"body\":\"${MSG}\"}"
- name: Run ${{ env.SUITE }} on ${{ env.DISTRO }} for [${{ env.PR_URL }}]
id: run-tests
continue-on-error: true
run: |
./ost.sh destroy
cat md-report.ini >> pytest.ini
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
if [ -n "$PR_URL" ]; then
if [[ "$PR_URL" == *","* ]]; then
PR_URL=$(echo "$PR_URL" | sed 's/ //g')
PR_URL=$(echo "$PR_URL" | sed 's/,/ --custom-repo /g')
fi
PR_URL="--custom-repo $PR_URL"
fi
/usr/bin/bash ost.sh run $SUITE $DISTRO $PR_URL
- name: Create artifacts archive
run: tar -czf exported-artifacts.tar.gz exported-artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ost-artifacts
path: exported-artifacts.tar.gz
- name: Add report to summary
shell: bash
run: |
cat $GITHUB_REPORT_FILE
if [ -f "$GITHUB_REPORT_FILE" ]; then
echo "<details><summary>Test Report</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat "$GITHUB_REPORT_FILE" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
fi
- name: Add report to PR
if: always() && github.event_name != 'workflow_dispatch'
shell: bash
run: |
MESSAGE=":sob::broken_heart: ost suite **'$SUITE'** on distro **'$DISTRO'** failed."
if [ "${{ steps.run-tests.outcome }}" == "success" ]; then
MESSAGE=":sunglasses::muscle: ost suite **'$SUITE'** on distro **'$DISTRO'** finished successfully."
fi
MESSAGE="$MESSAGE ([details]($RUN_URL))"
JSON_PAYLOAD=$(jq -n --arg body "$MESSAGE" '{"body": $body}')
echo "JSON_PAYLOAD: $JSON_PAYLOAD"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
${{ github.event.issue.url }}/comments \
-d "$JSON_PAYLOAD"
- name: Fail workflow if tests failed
if: steps.run-tests.outcome == 'failure'
run: |
echo "Tests failed. Failing the workflow."
exit 1