Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test pr2 #8

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 179 additions & 0 deletions .github/workflows/test-platforms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# Run kickstart tests in a PR triggered by a "/test-platforms" command from an organization member
#
# /test-platforms - tests all tests affected by the PR or smoke tests if there is no such
# Or specify tests by combination of test names and/or options:
# /test-platforms --testtype TESTTYPE --skip-testtypes TYPE[,TYPE..] TEST1 TEST2
name: test-platforms
on:
issue_comment:
types: [created]

permissions:
contents: read
statuses: write

jobs:
pr-info:
if: startsWith(github.event.comment.body, '/test-platforms')
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 "/kickstart-tests" first word
LAUNCH_ARGS=$(echo "$BODY" | sed -n '1 s/^[^ ]* *//p' | sed 's/[[:space:]]*$//')
echo "launch arguments are: $LAUNCH_ARGS"
echo "launch_args=${LAUNCH_ARGS}" >> $GITHUB_OUTPUT

# - name: Set KS test arguments
# id: ks_test_args
# run: |
# set -eux
# TARGET_BRANCH="${{ fromJson(steps.pr_api.outputs.data).base.ref }}"
#
# if [ "$TARGET_BRANCH" == "master" ]; then
# echo "skip_tests=skip-on-fedora" >> $GITHUB_OUTPUT
# echo "platform=fedora_rawhide" >> $GITHUB_OUTPUT
# elif echo "$TARGET_BRANCH" | grep -qE "fedora-[[:digit:]]+$"; then
# echo "skip_tests=skip-on-fedora" >> $GITHUB_OUTPUT
# echo "platform=fedora_rawhide" >> $GITHUB_OUTPUT
# elif echo "$TARGET_BRANCH" | grep -qE "rhel-8(\.[[:digit:]]+)?$"; then
# echo "skip_tests=skip-on-rhel,skip-on-rhel-8" >> $GITHUB_OUTPUT
# echo "platform=rhel8" >> $GITHUB_OUTPUT
# elif echo "$TARGET_BRANCH" | grep -qE "rhel-9(\.[[:digit:]]+)?$"; then
# echo "skip_tests=skip-on-rhel,skip-on-rhel-9" >> $GITHUB_OUTPUT
# echo "platform=rhel9" >> $GITHUB_OUTPUT
# else
# echo "Branch $TARGET_BRANCH is not supported by kickstart tests yet!"
# exit 1
# fi

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 }}
# TODO: generate test names
launch_args: ${{ steps.parse_launch_args.outputs.launch_args }}
# skip_tests: ${{ steps.ks_test_args.outputs.skip_tests }}
# platform: ${{ steps.ks_test_args.outputs.platform }}


platform:
needs: pr-info
if: needs.pr-info.outputs.allowed_user == 'true' && ! contains(github.event.comment.body, '--waive')
name: Run tests on the platform
runs-on: [self-hosted, kstest-test]
env:
TARGET_BRANCH: ${{ needs.pr-info.outputs.base_ref }}
strategy:
matrix:
#platform: [daily-iso, rawhide, rhel8, rhel9]
platform: [daily-iso]
fail-fast: false

steps:
# 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 repository
uses: actions/checkout@v4
with:
ref: ${{ needs.pr-info.outputs.sha }}
# TODO use just main directory?
path: kickstart-tests

# - name: Rebase to current ${{ env.TARGET_BRANCH }}
# working-directory: ./kickstart-tests
# run: |
# git fetch origin
# 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 }}
#


- name: Get changed tests
working-directory: ./kickstart-tests
id: get_changed_tests
run: |
git fetch origin
# TODO: share with scripts/run-travis.sh
CHANGED_TESTS=$(git diff --name-only origin/$TARGET_BRANCH ${{ needs.pr-info.outputs.sha }} -- *.ks.in $(find -maxdepth 1 -name '*.sh' -perm -u+x) | sed 's/\.ks\.in$//; s/\.sh$//' | sort -u | tr '\n' ' ')
echo "changed_tests=${CHANGED_TESTS}" >> $GITHUB_OUTPUT

- name: Get skipped tests for platform ${{ matrix.platform }}
id: get_platform_skiptest
working-directory: ./kickstart-tests
run: |
set -eux

if [ ${{ matrix.platform }} == "daily-iso" ]; then
echo "skip_tests=skip-on-fedora" >> $GITHUB_OUTPUT
elif [ ${{ matrix.platform }} == "rawhide" ]; then
echo "skip_tests=skip-on-fedora" >> $GITHUB_OUTPUT
elif [ ${{ matrix.platform }} == "rhel8" ]; then
echo "skip_tests=skip-on-rhel,skip-on-rhel-8" >> $GITHUB_OUTPUT
elif [ ${{ matrix.platform }} == "rhel9" ]; then
echo "skip_tests=skip-on-rhel,skip-on-rhel-9" >> $GITHUB_OUTPUT
else
echo "Platform is not supported by kickstart tests yet!"
exit 1
fi

- name: Generate query arguments for "${{ steps.get_changed_tests.outputs.changed_tests }}"
id: generate_query
working-directory: ./kickstart-tests
run: |
set -eux
source ./containers/runner/skip-testtypes
PERMIAN_QUERY=$(scripts/generate-permian-query.py \
--skip-testtypes $SKIP_TESTTYPES_ANACONDA_PR \
--skip-testtypes ${{ steps.get_platform_skiptest.outputs.skip_tests }} \
${{ steps.get_changed_tests.outputs.changed_tests }} )
if [ $? == 0 ]; then
echo "query=$PERMIAN_QUERY" >> $GITHUB_OUTPUT
else
echo "Parsing of the request arguments failed"
exit 1
fi



# TODO: use supplied arguments (overriding)
# TODO: timeouts?
# TODO: implement progress from anaconda repo
2 changes: 2 additions & 0 deletions container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
# shellcheck disable=SC2034
TESTTYPE="bootloader packaging coverage skip-on-rhel"

# modified

. ${KSTESTDIR}/functions.sh
9 changes: 8 additions & 1 deletion dns.ks.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#version=DEVEL
#test name: dns
# Test domain name resolution.
# Test domain name resolution:
# - origin of /etc/resolv.conf (rhbz#2018913, rhbz#1989472)
# - dns resolution in %post scripts (RHEL-26651)

# Use defaults.
%ksappend repos/default.ks
Expand All @@ -19,6 +21,11 @@ else
check_resolv_conf_is_by_resolved
fi

curl fedoraproject.org
if [[ $? != 0 ]]; then
echo '*** curl fedoraproject.org failed' >> /root/RESULT
fi

# No error was written to /root/RESULT file, everything is OK
if [[ ! -e /root/RESULT ]]; then
echo SUCCESS > /root/RESULT
Expand Down
2 changes: 2 additions & 0 deletions hmc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# shellcheck disable=SC2034
TESTTYPE="manual payload"

# modified

. ${KSTESTDIR}/functions.sh

kernel_args() {
Expand Down
2 changes: 2 additions & 0 deletions keyboard.ks.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#version=DEVEL
#modified

#test name: keyboard
%ksappend repos/default.ks
network --bootproto=dhcp
Expand Down
3 changes: 3 additions & 0 deletions scripts/generate-permian-query.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def parse_args():
+ " or ".join(['tc.name == "{}"'.format(test) for test in args.tests])
+ ")"
]
if args.skip_testtypes:
skiptypes = ','.join(itertools.chain(*args.skip_testtypes)).split(',')
conditions.extend(['"{}" not in tc.tags'.format(skiptype) for skiptype in skiptypes])
else:
if args.testtype:
conditions.extend(['"{}" in tc.tags'.format(args.testtype), '"knownfailure" not in tc.tags'])
Expand Down