webui-tests #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ====================================== | |
# WARNING! | |
# THIS FILE IS GENERATED FROM A TEMPLATE | |
# DO NOT EDIT THIS FILE MANUALLY! | |
# ====================================== | |
# The template is located in: webui-tests.yml.j2 | |
# Run webui end2end tests in a PR | |
# Triggered by a "/webui-test <LAUNCH ARGS>" comment from an organization member. | |
# Currently the only <LAUNCH ARG> is supported - "os" URL for InstallationSource | |
name: webui-tests | |
on: | |
issue_comment: | |
types: [created] | |
permissions: | |
contents: read | |
statuses: write | |
checks: write | |
jobs: | |
pr-info: | |
if: startsWith(github.event.comment.body, '/webui-test') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Query comment author repository permissions | |
uses: octokit/[email protected] | |
id: user_permission | |
with: | |
route: GET /repos/${{ github.repository }}/collaborators/${{ github.event.sender.login }}/permission | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# restrict running of tests to users with admin or write permission for the repository | |
# see https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-permissions-for-a-user | |
# store output if user is allowed in allowed_user job output so it has to be checked in downstream job | |
- name: Check if user does have correct permissions | |
if: contains('admin write', fromJson(steps.user_permission.outputs.data).permission) | |
id: check_user_perm | |
run: | | |
echo "User '${{ github.event.sender.login }}' has permission '${{ fromJson(steps.user_permission.outputs.data).permission }}' allowed values: 'admin', 'write'" | |
echo "allowed_user=true" >> $GITHUB_OUTPUT | |
- name: Get information for pull request | |
uses: octokit/[email protected] | |
id: pr_api | |
with: | |
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Parse launch arguments | |
id: parse_launch_args | |
# Do not use comment body directly in the shell command to avoid possible code injection. | |
env: | |
BODY: ${{ github.event.comment.body }} | |
run: | | |
# extract first line and cut out the "/webui-test" first word | |
LAUNCH_ARGS=$(echo "$BODY" | sed -n '1 s/^[^ ]* *//p') | |
echo "launch arguments are: $LAUNCH_ARGS" | |
echo "launch_args=${LAUNCH_ARGS}" >> $GITHUB_OUTPUT | |
outputs: | |
allowed_user: ${{ steps.check_user_perm.outputs.allowed_user }} | |
base_ref: ${{ fromJson(steps.pr_api.outputs.data).base.ref }} | |
sha: ${{ fromJson(steps.pr_api.outputs.data).head.sha }} | |
launch_args: ${{ steps.parse_launch_args.outputs.launch_args }} | |
run: | |
needs: pr-info | |
if: needs.pr-info.outputs.allowed_user == 'true' && ! contains(github.event.comment.body, '--waive') | |
runs-on: [self-hosted, kstest] | |
timeout-minutes: 65 | |
env: | |
STATUS_NAME: Permian WebUI e2e | |
TARGET_BRANCH: ${{ needs.pr-info.outputs.base_ref }} | |
# ocp-master-xxl: 32GB RAM / 4GB RAM per VM | |
TEST_JOBS: 8 | |
# The timeout should be a few minutes less then the job's timeout-minutes | |
# so that we get partial results and logs in case of the timeout. | |
LAUNCHER_TIMEOUT_MINUTES: 60 | |
# URL to the unpacked installation image | |
# TODO: use preview image | |
STATIC_REPO_URL: "https://fedorapeople.org/groups/anaconda/webui_permian_tests/sources/periodic/x86_64/" | |
CONTAINER_TAG: master | |
ISO_BUILD_CONTAINER_NAME: 'quay.io/rhinstaller/anaconda-iso-creator' | |
steps: | |
# we post statuses manually as this does not run from a pull_request event | |
# https://developer.github.com/v3/repos/statuses/#create-a-status | |
- name: Create in-progress status | |
uses: octokit/[email protected] | |
with: | |
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' | |
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}' | |
description: 'gathering repositories [${{ runner.name }}]' | |
state: pending | |
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# self-hosted runners don't do this automatically; also useful to keep stuff around for debugging | |
# need to run sudo as the launch script and the container create root/other user owned files | |
- name: Clean up previous run | |
run: | | |
sudo podman ps -q --all --filter='ancestor=kstest-runner' | xargs -tr sudo podman rm -f | |
sudo podman volume rm --all || true | |
sudo rm -rf * .git | |
- name: Clone anaconda repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.pr-info.outputs.sha }} | |
fetch-depth: 0 | |
path: anaconda | |
- name: Rebase to current ${{ env.TARGET_BRANCH }} | |
working-directory: ./anaconda | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git log --oneline -1 origin/${{ env.TARGET_BRANCH }} | |
git rebase origin/${{ env.TARGET_BRANCH }} | |
# TODO: use main branch when the webui workflow is merged there | |
- name: Clone Permian repository | |
uses: actions/checkout@v3 | |
with: | |
repository: rhinstaller/permian | |
path: permian | |
ref: devel | |
- name: Clone tplib repository | |
uses: actions/checkout@v3 | |
with: | |
repository: rhinstaller/tplib | |
path: tplib | |
- name: Post status building artifacts | |
uses: octokit/[email protected] | |
with: | |
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' | |
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}' | |
description: 'TODO building artifacts [${{ runner.name }}]' | |
state: pending | |
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build anaconda-rpm container (for RPM build) | |
working-directory: ./anaconda | |
run: | | |
# set static tag to avoid complications when looking what tag is used | |
make -f Makefile.am anaconda-rpm-build CI_TAG=$CONTAINER_TAG | |
- name: Build Anaconda RPM files | |
working-directory: ./anaconda | |
run: | | |
# output of the build will be stored in ./result/build/01-rpm-build/*.rpm | |
make -f Makefile.am container-rpms-scratch CI_TAG=$CONTAINER_TAG | |
mkdir -p ./anaconda_rpms/ | |
cp -av ./result/build/01-rpm-build/*.rpm ./anaconda_rpms/ | |
- name: Build anaconda-iso-creator container image | |
working-directory: ./anaconda | |
run: | | |
# set static tag to avoid complications when looking what tag is used | |
sudo make -f Makefile.am anaconda-iso-creator-build CI_TAG=$CONTAINER_TAG | |
- name: Build the boot.iso | |
working-directory: ./anaconda | |
run: | | |
mkdir -p images | |
# /var/tmp tmpfs speeds up lorax and avoids https://bugzilla.redhat.com/show_bug.cgi?id=1906364 | |
sudo podman run -i --rm --privileged \ | |
--tmpfs /var/tmp:rw,mode=1777 \ | |
-v `pwd`/anaconda_rpms:/anaconda-rpms:ro \ | |
-v `pwd`/images:/images:z \ | |
--entrypoint /lorax-build-webui \ | |
$ISO_BUILD_CONTAINER_NAME:$CONTAINER_TAG | |
- name: Clean up after lorax | |
if: always() | |
run: | | |
# remove container images together with the container | |
sudo podman rmi -f $ISO_BUILD_CONTAINER_NAME:$CONTAINER_TAG || true | |
sudo podman rmi -f $RPM_BUILD_CONTAINER_NAME:$CONTAINER_TAG || true | |
- name: Create Permian settings file | |
working-directory: ./permian | |
run: | | |
cat <<EOF > settings.ini | |
[AnacondaWebUI] | |
anaconda_repo=file://${{ github.workspace }}/anaconda | |
hypervisor_vm_limit=${{ env.TEST_JOBS }} | |
test_timeout=${{ env.LAUNCHER_TIMEOUT_MINUTES }} | |
[library] | |
directPath=${{ github.workspace }}/anaconda/ui/webui/test/end2end | |
EOF | |
- name: Post status running tests | |
uses: octokit/[email protected] | |
with: | |
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' | |
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}' | |
description: 'running pipeline [${{ runner.name }}]' | |
state: pending | |
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run webui end2end tests | |
working-directory: ./permian | |
run: | | |
PYTHONPATH=${PYTHONPATH:-}:${{ github.workspace }}/tplib \ | |
./pipeline --debug-log permian.log \ | |
--settings settings.ini \ | |
-o github.pull-request=${{ github.event.issue.number }} \ | |
-o github.repository=${{ github.repository }} \ | |
-o github.token=${{ secrets.GITHUB_TOKEN }} \ | |
run_event '{ | |
"type":"github.pr.anaconda", | |
"bootIso": { | |
"x86_64": "file://${{ github.workspace }}/anaconda/images/boot.iso" | |
} | |
}' | |
- name: Collect logs | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: 'logs' | |
path: | | |
permian/permian.log | |
permian/local_logs/ | |
permian/pipeline_data | |
permian/static/ | |
permian/index.html | |
permian/xunit*.xml | |
permian/*.dump | |
# Permian exit code doesn't reflect the test results | |
- name: Check tests results | |
working-directory: ./permian | |
shell: bash {0} | |
run: | | |
fails=$( grep -E '<failure .* type="failure"/>|<error .* type="error"/>' xunit*.xml ) | |
if [ -n "$fails" ]; then | |
exit 111 | |
else | |
exit 0 | |
fi | |
- name: Set result status | |
if: always() | |
uses: octokit/[email protected] | |
with: | |
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' | |
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}' | |
description: 'finished [${{ runner.name }}]' | |
state: ${{ job.status }} | |
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
waive: | |
runs-on: ubuntu-latest | |
needs: pr-info | |
if: needs.pr-info.outputs.allowed_user == 'true' && contains(github.event.comment.body, '--waive') | |
steps: | |
- name: Get the waiving reason | |
id: get_reason | |
env: | |
BODY: ${{ github.event.comment.body }} | |
run: | | |
REASON=$(echo "$BODY" | sed -e "s#/kickstart-test --waive ##") | |
echo "reason=Waived, $REASON" >> $GITHUB_OUTPUT | |
- name: Set status | |
uses: octokit/[email protected] | |
with: | |
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' | |
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}' | |
description: '${{ steps.get_reason.outputs.reason }}' | |
state: ${{ job.status }} | |
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |