From ab09d770a5318cbf2401f6d800e61bc2c38cb275 Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Fri, 19 Apr 2024 08:17:10 +0200 Subject: [PATCH 1/7] workflows: move logic from GH workflows into scripts The generate-launch-arguments.py script can be used also for workflows not using permian (tmt). TODO: update the workflows --- scripts/generate-launch-args.py | 130 ++++++++++++++++++++++++++++++ scripts/generate-permian-query.py | 8 ++ 2 files changed, 138 insertions(+) create mode 100755 scripts/generate-launch-args.py diff --git a/scripts/generate-launch-args.py b/scripts/generate-launch-args.py new file mode 100755 index 00000000..de3136b2 --- /dev/null +++ b/scripts/generate-launch-args.py @@ -0,0 +1,130 @@ +#!/usr/bin/python3 + +import argparse +import shlex +import subprocess +import re +import os + +OS_VARIANT_TO_PLATFORM = { + 'daily-iso': 'fedora_rawhide', + 'rawhide': 'fedora_rawhide', + 'rhel8': 'rhel8', + 'rhel9': 'rhel9', + 'rhel10': 'rhel10', +} + +OS_VARIANT_TO_DISABLED = { + 'daily-iso': 'SKIP_TESTTYPES_DAILY_ISO', + 'rawhide': 'SKIP_TESTTYPES_RAWHIDE', + 'rhel8': 'SKIP_TESTTYPES_RHEL8', + 'rhel9': 'SKIP_TESTTYPES_RHEL9', + 'rhel10': 'SKIP_TESTTYPES_RHEL10', +} + +RE_MASTER = re.compile('^master$') +RE_FEDORA = re.compile('fedora-[0-9]+$') +RE_RHEL8 = re.compile('rhel-8(.[0-9]+)?$') +RE_RHEL9 = re.compile('rhel-9(.[0-9]+)?$') +RE_RHEL10 = re.compile('rhel-10(.[0-9]+)?$') + +SKIP_FILE = "containers/runner/skip-testtypes" + + +def get_skip_testtypes(skip_file, variable): + if not os.path.exists(skip_file): + raise ValueError("Disabled tests file {} not found".format(skip_file)) + command = shlex.split("bash -c 'source {}; echo ${}'".format(skip_file, variable)) + taglist = subprocess.run(command, capture_output=True, encoding="utf8") + return taglist.stdout.strip().split(',') + + +def get_arguments_for_branch(branch, skip_file): + platform = None + skip_testtypes = [] + + if RE_MASTER.match(branch): + platform = "fedora_rawhide" + skipvar = 'SKIP_TESTTYPES_RAWHIDE' + elif RE_FEDORA.match(branch): + platform = "fedora_rawhide" + skipvar = 'SKIP_TESTTYPES_RAWHIDE' + elif RE_RHEL8.match(branch): + platform = "rhel8" + skipvar = 'SKIP_TESTTYPES_RHEL8' + elif RE_RHEL9.match(branch): + platform = "rhel9" + skipvar = 'SKIP_TESTTYPES_RHEL9' + elif RE_RHEL10.match(branch): + platform = "rhel10" + skipvar = 'SKIP_TESTTYPES_RHEL10' + else: + platform = None + skipvar = None + + if skipvar: + skip_testtypes = get_skip_testtypes(skip_file, skipvar) + + return (platform, skip_testtypes) + + +def parse_args(): + _parser = argparse.ArgumentParser( + description="Generate kickstart tests launch script arguments for given os variant or git branch. " + "Determines the platform and updates the skipped tests." + ) + _parser.add_argument("--skip-testtypes", "-s", type=str, metavar="TYPE[,TYPE..]", + help="skip tests with TYPE (tag)") + _parser.add_argument("--testtype", "-t", type=str, metavar="TYPE", + help="only run tests with TYPE (tag)") + _parser.add_argument("tests", nargs='*', metavar="TESTNAME", + help="names of test to be run") + _parser.add_argument("--branch", "-b", type=str, metavar="GIT-BRANCH", + help="Anaconda git branch (for example rhel-10)") + _parser.add_argument("--os-variant", "-r", type=str, metavar="OS_VARIANT", + help="os variant of the boot.iso to be tested (for example rhel9)") + _parser.add_argument("--force", "-f", action="store_true", + help="do not skip any tests based on os variant or branch") + _parser.add_argument("--skip-file", type=str, metavar="PATH", + help="file containing data about disabled tests") + return _parser.parse_args() + + +if __name__ == "__main__": + + args = parse_args() + + skip_file = args.skip_file or SKIP_FILE + + launch_args = [] + platform_args = [] + testtype_args = [] + skip_testtypes_args = [] + + platform = None + disabled_testtypes = [] + if args.os_variant: + platform = OS_VARIANT_TO_PLATFORM[args.os_variant] + disabled_testtypes = get_skip_testtypes(skip_file, OS_VARIANT_TO_DISABLED[args.os_variant]) + elif args.branch: + platform, disabled_testtypes = get_arguments_for_branch(args.branch, skip_file) + if not platform: + raise ValueError("Platform for branch {} is not defined".format(args.branch)) + + if platform: + platform_args = ["--platform", platform] + + if args.testtype: + testtype_args = ["--testtype", args.testtype] + + skip_testtypes = [] if args.force else disabled_testtypes + if args.skip_testtypes: + skip_testtypes.extend(args.skip_testtypes.split(',')) + if skip_testtypes: + skip_testtypes_args = ["--skip-testtypes", ",".join(skip_testtypes)] + + launch_args = platform_args + skip_testtypes_args + testtype_args + args.tests + + print( + " ".join(launch_args) + ) diff --git a/scripts/generate-permian-query.py b/scripts/generate-permian-query.py index 51156ea4..816e0a49 100755 --- a/scripts/generate-permian-query.py +++ b/scripts/generate-permian-query.py @@ -13,6 +13,10 @@ def parse_args(): nargs=1, action="append", help="skip tests with TYPE (tag)") _parser.add_argument("--testtype", "-t", type=str, metavar="TYPE", help="only run tests with TYPE (tag)") + _parser.add_argument("--platform", "-p", type=str, metavar="PLATFORM", + help="platform to be used for tests") + _parser.add_argument("--print-platform", action="store_true", + help="print the platform option") _parser.add_argument("tests", nargs='*', metavar="TESTNAME", help="names of test to be run") return _parser.parse_args() @@ -22,6 +26,10 @@ def parse_args(): args = parse_args() + if args.print_platform: + print(args.platform) + exit() + conditions = [] if args.tests: conditions = [ From d4d529598ea6a686bb886f95a612ae50a0b179e6 Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Fri, 19 Apr 2024 09:24:36 +0200 Subject: [PATCH 2/7] error handling for --print-platform --- scripts/generate-permian-query.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/generate-permian-query.py b/scripts/generate-permian-query.py index 816e0a49..59d4a295 100755 --- a/scripts/generate-permian-query.py +++ b/scripts/generate-permian-query.py @@ -13,7 +13,7 @@ def parse_args(): nargs=1, action="append", help="skip tests with TYPE (tag)") _parser.add_argument("--testtype", "-t", type=str, metavar="TYPE", help="only run tests with TYPE (tag)") - _parser.add_argument("--platform", "-p", type=str, metavar="PLATFORM", + _parser.add_argument("--platform", "-p", type=str, metavar="PLATFORM", default="", help="platform to be used for tests") _parser.add_argument("--print-platform", action="store_true", help="print the platform option") @@ -27,8 +27,11 @@ def parse_args(): args = parse_args() if args.print_platform: - print(args.platform) - exit() + if args.platform: + print(args.platform) + exit() + else: + exit(1) conditions = [] if args.tests: From fcf07c581c7d281cc28a98894f1204a0ae50d073 Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Fri, 19 Apr 2024 11:48:42 +0200 Subject: [PATCH 3/7] run on kstest-test --- .github/workflows/test-platforms.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-platforms.yml b/.github/workflows/test-platforms.yml index 6f92211d..fc6ac781 100644 --- a/.github/workflows/test-platforms.yml +++ b/.github/workflows/test-platforms.yml @@ -74,7 +74,7 @@ jobs: needs: pr-info if: needs.pr-info.outputs.allowed_user == 'true' name: Run tests on the platform - runs-on: [self-hosted, kstest] + runs-on: [self-hosted, kstest-test] env: STATUS_NAME: test-platforms TARGET_BRANCH: ${{ needs.pr-info.outputs.base_ref }} From 92aa4323cc14b14c49f5e335244ccc150499ff3c Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Fri, 19 Apr 2024 12:09:34 +0200 Subject: [PATCH 4/7] rename platform -> os version --- .github/workflows/test-platforms.yml | 84 ++++++++++++++-------------- README.rst | 4 +- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/.github/workflows/test-platforms.yml b/.github/workflows/test-platforms.yml index fc6ac781..79d3d18c 100644 --- a/.github/workflows/test-platforms.yml +++ b/.github/workflows/test-platforms.yml @@ -1,12 +1,12 @@ -# Run kickstart tests in a PR triggered by a "/test-platforms" command from an organization member +# Run kickstart tests in a PR triggered by a "/test-os-variants" command from an organization member # -# /test-platforms - execute all tests affected by the PR or smoke tests if there is no such. +# /test-os-variants - execute 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 +# /test-os-variants --testtype TESTTYPE --skip-testtypes TYPE[,TYPE..] TEST1 TEST2 # # For dry run use: -# /test-platforms-dry -name: test-platforms +# /test-os-variants-dry +name: test-os-variants on: issue_comment: types: [created] @@ -17,7 +17,7 @@ permissions: jobs: pr-info: - if: startsWith(github.event.comment.body, '/test-platforms') + if: startsWith(github.event.comment.body, '/test-os-variants') runs-on: ubuntu-latest steps: - name: Query comment author repository permissions @@ -52,13 +52,13 @@ jobs: env: BODY: ${{ github.event.comment.body }} run: | - # extract first line and cut out the "/test-platforms" first word + # extract first line and cut out the "/test-os-variants" 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 # check for dry run mode DRY_RUN=False - echo "$BODY" | grep -q "/test-platforms-dry" && DRY_RUN=True + echo "$BODY" | grep -q "/test-os-variants-dry" && DRY_RUN=True echo "Dry run: ${DRY_RUN}" echo "dry_run=${DRY_RUN}" >> $GITHUB_OUTPUT @@ -70,19 +70,19 @@ jobs: dry_run: ${{ steps.parse_launch_args.outputs.dry_run }} - platform: + os-variant: needs: pr-info if: needs.pr-info.outputs.allowed_user == 'true' - name: Run tests on the platform + name: Run on os variant runs-on: [self-hosted, kstest-test] env: - STATUS_NAME: test-platforms + STATUS_NAME: test-os-variants TARGET_BRANCH: ${{ needs.pr-info.outputs.base_ref }} TEST_JOBS: 16 GITHUB_TOKEN: /home/github/github-token strategy: matrix: - platform: [daily-iso, rawhide, rhel8, rhel9, rhel10] + os-variant: [daily-iso, rawhide, rhel8, rhel9, rhel10] fail-fast: false steps: @@ -137,30 +137,30 @@ jobs: CHANGED_TESTS=$(git diff --name-only $BASE_COMMIT HEAD -- *.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_specs + - name: Get skipped tests for os variant ${{ matrix.os-variant }} + id: get_os_variant_specs working-directory: ./kickstart-tests run: | set -eux source ./containers/runner/skip-testtypes - if [ ${{ matrix.platform }} == "daily-iso" ]; then + if [ ${{ matrix.os-variant }} == "daily-iso" ]; then echo "skip_tests=skip-on-fedora" >> $GITHUB_OUTPUT echo "disabled_testtypes=$SKIP_TESTTYPES_DAILY_ISO" >> $GITHUB_OUTPUT echo "platform=fedora_rawhide" >> $GITHUB_OUTPUT - elif [ ${{ matrix.platform }} == "rawhide" ]; then + elif [ ${{ matrix.os-variant }} == "rawhide" ]; then echo "skip_tests=skip-on-fedora" >> $GITHUB_OUTPUT echo "disabled_testtypes=$SKIP_TESTTYPES_RAWHIDE" >> $GITHUB_OUTPUT echo "platform=fedora_rawhide" >> $GITHUB_OUTPUT - elif [ ${{ matrix.platform }} == "rhel8" ]; then + elif [ ${{ matrix.os-variant }} == "rhel8" ]; then echo "skip_tests=skip-on-rhel,skip-on-rhel-8" >> $GITHUB_OUTPUT echo "disabled_testtypes=$SKIP_TESTTYPES_RHEL8" >> $GITHUB_OUTPUT echo "platform=rhel8" >> $GITHUB_OUTPUT - elif [ ${{ matrix.platform }} == "rhel9" ]; then + elif [ ${{ matrix.os-variant }} == "rhel9" ]; then echo "skip_tests=skip-on-rhel,skip-on-rhel-9" >> $GITHUB_OUTPUT echo "disabled_testtypes=$SKIP_TESTTYPES_RHEL9" >> $GITHUB_OUTPUT echo "platform=rhel9" >> $GITHUB_OUTPUT - elif [ ${{ matrix.platform }} == "rhel10" ]; then + elif [ ${{ matrix.os-variant }} == "rhel10" ]; then echo "skip_tests=skip-on-rhel,skip-on-rhel-10" >> $GITHUB_OUTPUT echo "disabled_testtypes=$SKIP_TESTTYPES_RHEL10" >> $GITHUB_OUTPUT echo "platform=rhel10" >> $GITHUB_OUTPUT @@ -176,7 +176,7 @@ jobs: set -eux CHANGED_TESTS="${{ steps.get_changed_tests.outputs.changed_tests }}" - DISABLED_TESTTYPES="${{ steps.get_platform_specs.outputs.disabled_testtypes }}" + DISABLED_TESTTYPES="${{ steps.get_os_variant_specs.outputs.disabled_testtypes }}" LAUNCH_ARGS="${{ needs.pr-info.outputs.launch_args }}" if [ -n "${LAUNCH_ARGS}" ]; then @@ -195,7 +195,7 @@ jobs: source ./containers/runner/skip-testtypes PERMIAN_QUERY=$(scripts/generate-permian-query.py \ --skip-testtypes $SKIP_TESTTYPES_ANACONDA_PR \ - --skip-testtypes ${{ steps.get_platform_specs.outputs.skip_tests }} \ + --skip-testtypes ${{ steps.get_os_variant_specs.outputs.skip_tests }} \ ${LAUNCH_ARGS} ) if [ $? == 0 ]; then echo "launch_args=$LAUNCH_ARGS" >> $GITHUB_OUTPUT @@ -219,40 +219,40 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Fetch boot.iso and configure its local location - - name: Fetch boot.iso if available for platform ${{ matrix.platform }} - id: boot_iso_for_platform + - name: Fetch boot.iso if available for os variant ${{ matrix.os-variant }} + id: boot_iso_for_os_variant run: | set -eux - BOOT_ISO_PATH="${{ github.workspace }}/${{ matrix.platform }}.boot.iso" + BOOT_ISO_PATH="${{ github.workspace }}/${{ matrix.os-variant }}.boot.iso" BOOT_ISO_URL="file://$BOOT_ISO_PATH" - if [ "${{ matrix.platform }}" == "daily-iso" ]; then + if [ "${{ matrix.os-variant }}" == "daily-iso" ]; then ${{ github.workspace }}/kickstart-tests/containers/runner/fetch_daily_iso.sh $GITHUB_TOKEN $BOOT_ISO_PATH echo "boot_iso=\"bootIso\":{\"x86_64\":\"${BOOT_ISO_URL}\"}," >> $GITHUB_OUTPUT - elif [ "${{ matrix.platform }}" == "rawhide" ]; then + elif [ "${{ matrix.os-variant }}" == "rawhide" ]; then curl -L https://download.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/images/boot.iso --output $BOOT_ISO_PATH echo "boot_iso=\"bootIso\":{\"x86_64\":\"${BOOT_ISO_URL}\"}," >> $GITHUB_OUTPUT else - echo "Boot.iso for ${{ matrix.platform }} can't be fetched." + echo "Boot.iso for ${{ matrix.os-variant }} can't be fetched." echo "boot_iso=" >> $GITHUB_OUTPUT fi - # Configure location of installation repositories for the platform + # Configure location of installation repositories for the os variant # Also default boot.iso is defined by the value of urls.installation_tree # of kstestParams event structure. - - name: Set installation tree for the platform + - name: Set installation tree for the os variant id: set_installation_urls working-directory: ./kickstart-tests run: | set -eux - if [ "${{ matrix.platform }}" == "rhel8" ] || \ - [ "${{ matrix.platform }}" == "rhel9" ] || \ - [ "${{ matrix.platform }}" == "rhel10" ]; then - source ./scripts/defaults-${{ matrix.platform }}.sh + if [ "${{ matrix.os-variant }}" == "rhel8" ] || \ + [ "${{ matrix.os-variant }}" == "rhel9" ] || \ + [ "${{ matrix.os-variant }}" == "rhel10" ]; then + source ./scripts/defaults-${{ matrix.os-variant }}.sh echo "installation_tree=${KSTEST_URL}" >> $GITHUB_OUTPUT echo "modular_url=${KSTEST_MODULAR_URL}" >> $GITHUB_OUTPUT else - echo "Installation tree location for ${{ matrix.platform }} not configured" - if [ -z "${{ steps.boot_iso_for_platform.outputs.boot_iso }}" ]; then + echo "Installation tree location for ${{ matrix.os-variant }} not configured" + if [ -z "${{ steps.boot_iso_for_os_variant.outputs.boot_iso }}" ]; then echo "No boot.iso source is defined" exit 2 fi @@ -285,9 +285,9 @@ jobs: "configurations":[{"architecture":"x86_64"}], "point_person":"rvykydal@redhat.com" }, - ${{ steps.boot_iso_for_platform.outputs.boot_iso }} + ${{ steps.boot_iso_for_os_variant.outputs.boot_iso }} "kstestParams":{ - "platform":"${{ steps.get_platform_specs.outputs.platform }}", + "platform":"${{ steps.get_os_variant_specs.outputs.platform }}", "urls":{ "x86_64":{ "installation_tree":"${{ steps.set_installation_urls.outputs.installation_tree }}", @@ -309,7 +309,7 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: - name: 'logs-${{ matrix.platform }}' + name: 'logs-${{ matrix.os-variant }}' # skip the /anaconda subdirectories, too large path: | kickstart-tests/data/logs/kstest*.log @@ -322,17 +322,17 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: - name: 'logs-permian-${{ matrix.platform }}' + name: 'logs-permian-${{ matrix.os-variant }}' path: | permian/permian.log result: - needs: [platform, pr-info] + needs: [os-variant, pr-info] if: ${{ always() && needs.pr-info.outputs.allowed_user == 'true' }} name: Set result status runs-on: ubuntu-latest env: - STATUS_NAME: test-platforms + STATUS_NAME: test-os-variants steps: - name: Show overall status uses: octokit/request-action@v2.x @@ -340,7 +340,7 @@ jobs: route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}' description: 'finished' - state: ${{ needs.platform.result }} + state: ${{ needs.os-variant.result }} target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.rst b/README.rst index 0bf472c5..7ad1e313 100644 --- a/README.rst +++ b/README.rst @@ -373,8 +373,8 @@ PR runs do *not* auto-retry test failures. This avoids introducing unstable tests, and PRs usually just run a few tests so that flakes are much less likely to ruin the result. -To test a PR on all supported platforms (including rhel) there is a -`test-platforms`_ workflow running the tests on a comment in a PR. +To test a PR on all supported os versions (including rhel) there is a +`test-os-versions`_ workflow running the tests on a comment in a PR. Running it requires admin repository permissions. Service jobs From a1e0a203e5a75670889273c3508f36ad85761d35 Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Fri, 19 Apr 2024 12:23:47 +0200 Subject: [PATCH 5/7] move the file --- .github/workflows/{test-platforms.yml => test-os-variants.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{test-platforms.yml => test-os-variants.yml} (100%) diff --git a/.github/workflows/test-platforms.yml b/.github/workflows/test-os-variants.yml similarity index 100% rename from .github/workflows/test-platforms.yml rename to .github/workflows/test-os-variants.yml From cfb7519beb30609504d46182c269d349d0d184ed Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Fri, 19 Apr 2024 12:02:17 +0200 Subject: [PATCH 6/7] test-os-variants: move logic from the workflow --- .github/workflows/test-os-variants.yml | 86 ++++++++------------------ 1 file changed, 26 insertions(+), 60 deletions(-) diff --git a/.github/workflows/test-os-variants.yml b/.github/workflows/test-os-variants.yml index 79d3d18c..90591a6d 100644 --- a/.github/workflows/test-os-variants.yml +++ b/.github/workflows/test-os-variants.yml @@ -46,16 +46,16 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Parse launch arguments - id: parse_launch_args + - name: Parse comment arguments + id: parse_comment_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 "/test-os-variants" 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 + ARGS=$(echo "$BODY" | sed -n '1 s/^[^ ]* *//p' | sed 's/[[:space:]]*$//') + echo "comment arguments are: $ARGS" + echo "comment_args=${ARGS}" >> $GITHUB_OUTPUT # check for dry run mode DRY_RUN=False echo "$BODY" | grep -q "/test-os-variants-dry" && DRY_RUN=True @@ -66,8 +66,8 @@ jobs: 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 }} - dry_run: ${{ steps.parse_launch_args.outputs.dry_run }} + comment_args: ${{ steps.parse_comment_args.outputs.comment_args }} + dry_run: ${{ steps.parse_comment_args.outputs.dry_run }} os-variant: @@ -137,73 +137,39 @@ jobs: CHANGED_TESTS=$(git diff --name-only $BASE_COMMIT HEAD -- *.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 os variant ${{ matrix.os-variant }} - id: get_os_variant_specs - working-directory: ./kickstart-tests - run: | - set -eux - - source ./containers/runner/skip-testtypes - if [ ${{ matrix.os-variant }} == "daily-iso" ]; then - echo "skip_tests=skip-on-fedora" >> $GITHUB_OUTPUT - echo "disabled_testtypes=$SKIP_TESTTYPES_DAILY_ISO" >> $GITHUB_OUTPUT - echo "platform=fedora_rawhide" >> $GITHUB_OUTPUT - elif [ ${{ matrix.os-variant }} == "rawhide" ]; then - echo "skip_tests=skip-on-fedora" >> $GITHUB_OUTPUT - echo "disabled_testtypes=$SKIP_TESTTYPES_RAWHIDE" >> $GITHUB_OUTPUT - echo "platform=fedora_rawhide" >> $GITHUB_OUTPUT - elif [ ${{ matrix.os-variant }} == "rhel8" ]; then - echo "skip_tests=skip-on-rhel,skip-on-rhel-8" >> $GITHUB_OUTPUT - echo "disabled_testtypes=$SKIP_TESTTYPES_RHEL8" >> $GITHUB_OUTPUT - echo "platform=rhel8" >> $GITHUB_OUTPUT - elif [ ${{ matrix.os-variant }} == "rhel9" ]; then - echo "skip_tests=skip-on-rhel,skip-on-rhel-9" >> $GITHUB_OUTPUT - echo "disabled_testtypes=$SKIP_TESTTYPES_RHEL9" >> $GITHUB_OUTPUT - echo "platform=rhel9" >> $GITHUB_OUTPUT - elif [ ${{ matrix.os-variant }} == "rhel10" ]; then - echo "skip_tests=skip-on-rhel,skip-on-rhel-10" >> $GITHUB_OUTPUT - echo "disabled_testtypes=$SKIP_TESTTYPES_RHEL10" >> $GITHUB_OUTPUT - echo "platform=rhel10" >> $GITHUB_OUTPUT - else - echo "Platform is not supported by kickstart tests yet!" - exit 1 - fi - - - name: Generate test selection + - name: Generate test selection for os variant ${{ matrix.os-variant }} id: generate_query working-directory: ./kickstart-tests run: | set -eux CHANGED_TESTS="${{ steps.get_changed_tests.outputs.changed_tests }}" - DISABLED_TESTTYPES="${{ steps.get_os_variant_specs.outputs.disabled_testtypes }}" - LAUNCH_ARGS="${{ needs.pr-info.outputs.launch_args }}" + COMMENT_ARGS="${{ needs.pr-info.outputs.comment_args }}" - if [ -n "${LAUNCH_ARGS}" ]; then + if [ -n "${COMMENT_ARGS}" ]; then echo "description=Running tests required by the PR comment explicitly." >> $GITHUB_OUTPUT elif [ -n "${CHANGED_TESTS}" ]; then echo "description=Running tests affected by changes (excluding disabled)." >> $GITHUB_OUTPUT - LAUNCH_ARGS="${CHANGED_TESTS}" - if [ -n "${DISABLED_TESTTYPES}" ]; then - LAUNCH_ARGS="--skip-testtypes ${DISABLED_TESTTYPES} ${LAUNCH_ARGS}" - fi + COMMENT_ARGS="${CHANGED_TESTS}" else echo "description=Running smoke tests (no affected tests found)." >> $GITHUB_OUTPUT - LAUNCH_ARGS="--testtype smoke" + COMMENT_ARGS="--testtype smoke" fi - source ./containers/runner/skip-testtypes - PERMIAN_QUERY=$(scripts/generate-permian-query.py \ - --skip-testtypes $SKIP_TESTTYPES_ANACONDA_PR \ - --skip-testtypes ${{ steps.get_os_variant_specs.outputs.skip_tests }} \ - ${LAUNCH_ARGS} ) - if [ $? == 0 ]; then - echo "launch_args=$LAUNCH_ARGS" >> $GITHUB_OUTPUT - echo "query=$PERMIAN_QUERY" >> $GITHUB_OUTPUT + LAUNCH_ARGS=$(scripts/generate-launch-args.py ${COMMENT_ARGS} \ + --os-variant ${{ matrix.os-variant }} ) || RC=$? + if [ -z ${RC} ] || [ ${RC} == 0 ]; then + echo "Generated launch arguments: $LAUNCH_ARGS" else - echo "Parsing of the request arguments failed" + echo "Generating of the arguments failed. See the workflow file for usage." exit 1 fi + PERMIAN_QUERY=$(scripts/generate-permian-query.py $LAUNCH_ARGS) + echo "Generated permian query: $PERMIAN_QUERY" + echo "query=$PERMIAN_QUERY" >> $GITHUB_OUTPUT + PLATFORM=$(scripts/generate-permian-query.py --print-platform $LAUNCH_ARGS) + echo "Generated platform: $PLATFORM" + echo "platform=$PLATFORM" >> $GITHUB_OUTPUT # we post statuses manually as this does not run from a pull_request event # https://developer.github.com/v3/repos/statuses/#create-a-status @@ -211,7 +177,7 @@ jobs: uses: octokit/request-action@v2.x with: route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' - context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}' + context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.comment_args }}' description: '${{ steps.generate_query.outputs.description }}' state: pending target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' @@ -287,7 +253,7 @@ jobs: }, ${{ steps.boot_iso_for_os_variant.outputs.boot_iso }} "kstestParams":{ - "platform":"${{ steps.get_os_variant_specs.outputs.platform }}", + "platform":"${{ steps.generate_query.outputs.platform }}", "urls":{ "x86_64":{ "installation_tree":"${{ steps.set_installation_urls.outputs.installation_tree }}", @@ -338,7 +304,7 @@ jobs: uses: octokit/request-action@v2.x with: route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}' - context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}' + context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.comment_args }}' description: 'finished' state: ${{ needs.os-variant.result }} target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' From b5582e51ea269f96c0b948b946bbd366424f3ef6 Mon Sep 17 00:00:00 2001 From: Radek Vykydal Date: Fri, 19 Apr 2024 13:33:27 +0200 Subject: [PATCH 7/7] modify payload tests --- hmc.sh | 2 ++ rpm-ostree-container-bootc.sh | 2 ++ rpm-ostree-container-luks.sh | 2 ++ rpm-ostree-container-silverblue.sh | 2 ++ rpm-ostree.sh | 2 ++ 5 files changed, 10 insertions(+) diff --git a/hmc.sh b/hmc.sh index 82529b08..10b64606 100755 --- a/hmc.sh +++ b/hmc.sh @@ -21,6 +21,8 @@ # shellcheck disable=SC2034 TESTTYPE="manual payload" +# modified + . ${KSTESTDIR}/functions.sh kernel_args() { diff --git a/rpm-ostree-container-bootc.sh b/rpm-ostree-container-bootc.sh index 336cd157..f4bac73d 100755 --- a/rpm-ostree-container-bootc.sh +++ b/rpm-ostree-container-bootc.sh @@ -20,6 +20,8 @@ # shellcheck disable=SC2034 TESTTYPE="payload ostree bootc reboot skip-on-rhel-8 skip-on-rhel-10" +# modifies + . ${KSTESTDIR}/functions.sh copy_interesting_files_from_system() { diff --git a/rpm-ostree-container-luks.sh b/rpm-ostree-container-luks.sh index 9759fe7d..5e787acb 100755 --- a/rpm-ostree-container-luks.sh +++ b/rpm-ostree-container-luks.sh @@ -20,6 +20,8 @@ # shellcheck disable=SC2034 TESTTYPE="payload ostree bootc luks reboot skip-on-rhel-8 skip-on-rhel-10" +#modified + . ${KSTESTDIR}/functions.sh copy_interesting_files_from_system() { diff --git a/rpm-ostree-container-silverblue.sh b/rpm-ostree-container-silverblue.sh index 4b75b295..eb60475b 100755 --- a/rpm-ostree-container-silverblue.sh +++ b/rpm-ostree-container-silverblue.sh @@ -21,6 +21,8 @@ # shellcheck disable=SC2034 TESTTYPE="payload ostree skip-on-rhel" +# modified + . ${KSTESTDIR}/functions.sh kernel_args() { diff --git a/rpm-ostree.sh b/rpm-ostree.sh index 068d19e0..26e1a0ca 100755 --- a/rpm-ostree.sh +++ b/rpm-ostree.sh @@ -21,6 +21,8 @@ # shellcheck disable=SC2034 TESTTYPE="payload ostree skip-on-rhel gh1023" +# modifies + . ${KSTESTDIR}/functions.sh kernel_args() {