ansible-collections / ibm_zos_core

Red Hat Ansible Certified Content for IBM Z
75 stars 44 forks source link

[Bug] [ pipeline ] Fragment checking assumes every PR is going to need a fragment #1502

Open ddimatos opened 1 month ago

ddimatos commented 1 month ago

Is there an existing issue for this?

Bug description

Encountered a changelog fragment failure, the branch i am testing is not going to have a new fragment and possibly no fragments after a change log is created.

The pipeline logic assumes a run is going to introduce a new changelog fragment as in a new feature but we do have release PRs that don't.

Logic below needs to be updated, possibly a manual skip, id suggest to key off the summary fragment used in a release but that is not gauranteed to be there because generally after a Changelog is created and the release focal is happy, they remove all fragments.

        stage('Check for fragments') {
            ansibleTestingImage.inside("-u jenkins -e TARGET_HOST=${TARGET_HOST}"){
                dir("${REPO}/changelogs/fragments") {
                    sh (script: 'git checkout ${PULL_REQUEST_BASE_BRANCH};')
                    // sh (script: 'git checkout ${PULL_REQUEST_BASE_BRANCH};')
                    sh (script: 'git pull origin ${PULL_REQUEST_BASE_BRANCH};')
                    sh (script: 'git fetch')
                    echo '---------------Check for fragments in base--------------------------------'
                    ls_base = sh (script: 'ls -1 | wc -l', returnStdout: true)
                    echo 'fragments in base: ' + ls_base
                    // sh (script: 'git checkout ${PULL_REQUEST_BASE_BRANCH}')
                    echo '---------------Check for fragments in branch------------------------------'
                    sh (script: 'git checkout ${BRANCH}')
                    // sh (script: 'git checkout ${BRANCH}')
                    sh (script: 'git pull origin ${BRANCH}')
                    sh (script: 'git fetch')
                    ls_all = sh (script: 'ls -1 | wc -l', returnStdout: true)
                    echo 'fragments in branch: ' + ls_all
                    echo '--------------------------------------------------------------------------'
                    if ( ls_all > ls_base ) {
                        echo 'Changelog entries found'
                    }else{
                        error("Changelog fragment error: fragment not added")
                    }
                    echo '--------------------------------------------------------------------------'
                }
            }
        }

Log:

---------------Check for fragments in base--------------------------------
[Pipeline] sh
+ ls -1
+ wc -l
[Pipeline] echo
fragments in base: 77

[Pipeline] echo
---------------Check for fragments in branch------------------------------
[Pipeline] sh

My actual wc - from the fragment dir:

~/git/gh/ibm_zos_core/changelogs/fragments $: ls -1 | wc -l
      71

Looks like its probably comparing against dev, I am working off of staging-1.10.0-beta.1.

IBM z/OS Ansible core Version

v1.8.0 (default)

IBM Z Open Automation Utilities

v1.2.5 (default)

IBM Enterprise Python

v3.11.x (default)

ansible-version

v2.16.x (default)

z/OS version

v2.5 (default)

Ansible module

No response

Playbook verbosity output.

No response

Ansible configuration.

No response

Contents of the inventory

No response

Contents of group_vars or host_vars

No response

richp405 commented 1 month ago

thoughts: DD considers compare to main RP considers breaking out number from branch.