From b5246bd6dbdf52d1ed83b2597f2168927f886724 Mon Sep 17 00:00:00 2001 From: Rakshitha650 Date: Wed, 29 Nov 2023 16:27:22 +0530 Subject: [PATCH] [MOSIP-29967] added dev-check.yml Signed-off-by: Rakshitha650 --- .github/workflows/dev-check.yml | 68 +++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/dev-check.yml diff --git a/.github/workflows/dev-check.yml b/.github/workflows/dev-check.yml new file mode 100644 index 0000000000..a1e12c3e90 --- /dev/null +++ b/.github/workflows/dev-check.yml @@ -0,0 +1,68 @@ +name: Manual Workflow To Check Dependencies + +on: + workflow_dispatch: + inputs: + MESSAGE: + description: 'Triggered For Dependency Check' + required: false + default: 'dependency check' + SNAPSHOT_TAG: + description: 'tag to be find' + required: true + +jobs: + check-dependencies: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' + + - name: Install xmlstartlet and xmllint + run: | + sudo apt-get update + sudo apt-get install xmlstarlet libxml2-utils + + - name: Check if the *SNAPSHOT is present in the dependency section of the POM file. + run: | + # Find all pom.xml files + pomfiles=$(find ./ -type f -name "*pom.xml") + + snapshot_dependencies=() + + # Function to resolve a version and add it to snapshot_dependencies if it's a SNAPSHOT + resolve_version() { + local version=$1 + local pomfile=$2 + + output=$(mvn help:evaluate -Dexpression=$version -f $pomfile | grep -vE "INFO|WARNING") + + if [[ $output == *"ERROR"* ]]; then + echo "VERSION $version not found; EXITING" + exit 1 + elif [[ $output == *"-SNAPSHOT"* ]]; then + echo "Adding VERSION $version to snapshot_dependencies list" + snapshot_dependencies+=("\n$pomfile: <$version>$output") + fi + } + for pomfile in $pomfiles; do + echo "===================================== $pomfile ==========================================" + # Use xmlstarlet to extract dependency versions + dv=$(xmlstarlet sel -N s="http://maven.apache.org/POM/4.0.0" -t -v "//s:project/s:dependencies/s:dependency/s:version" $pomfile | grep '[${}]' | sed 's/[${}]//g') + echo "Dependency versions in $pomfile = $dv" | sed -z 's/\n/ /g' + for v in $dv; do + echo -e "\nv=$v" + resolve_version "$v" "$pomfile" + done + done + if [[ ${#snapshot_dependencies[@]} -gt 0 ]]; then + echo -e "Snapshot dependencies found: ${snapshot_dependencies[*]}" + exit 1 + fi \ No newline at end of file