Skip to content

Commit

Permalink
[MOSIP-29967] added dev-check.yml
Browse files Browse the repository at this point in the history
Signed-off-by: Rakshitha650 <[email protected]>
  • Loading branch information
Rakshitha650 committed Nov 29, 2023
1 parent c263025 commit b5246bd
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/dev-check.yml
Original file line number Diff line number Diff line change
@@ -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</$version>")
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

0 comments on commit b5246bd

Please sign in to comment.