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

chore: add third-party dependencies check #336

Merged
merged 23 commits into from
Nov 4, 2022
Merged
27 changes: 9 additions & 18 deletions .github/workflows/check-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,21 @@ jobs:
STATIC_DIR: hugegraph-loader/assembly/static
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
- name: mvn install
run:
run: |
mvn install:install-file -Dfile=$STATIC_DIR/lib/ojdbc8-12.2.0.1.jar -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar
mvn install -pl hugegraph-client -am -DskipTests=true
- name: mvn dependency:copy-dependencies
run:
mvn dependency:copy-dependencies -DincludeScope=runtime -DoutputDirectory=${{ github.workspace }}/current_dependencies
- name: generate current_dependencies.txt
mvn install -DskipTests=true
- name: generate current dependencies
run: |
ls ${{ github.workspace }}/current_dependencies |egrep -v "^hugegraph" |sort > ~/current_dependencies.txt
cat ~/current_dependencies.txt
mvn dependency:copy-dependencies -DincludeScope=runtime -DoutputDirectory=${{ github.workspace }}/current_dependencies
simon824 marked this conversation as resolved.
Show resolved Hide resolved
ls ${{ github.workspace }}/current_dependencies |egrep -v "^hugegraph|hubble" |sort > ${{ github.workspace }}/tool/dependencies/current-dependencies.txt
simon824 marked this conversation as resolved.
Show resolved Hide resolved
cat ${{ github.workspace }}/tool/dependencies/current-dependencies.txt
simon824 marked this conversation as resolved.
Show resolved Hide resolved
- name: check third dependencies
run: |
#by using commond join ,to check whether there are new third-party dependencies,compared with file(tool/dependencies/known-dependencies.txt)
sort ${{ github.workspace }}/tool/dependencies/known-dependencies.txt > ~/known-dependencies.txt
join -t : -o 1.1 2.1 -a2 ~/known-dependencies.txt ~/current_dependencies.txt > ~/result.txt
#print new third-party dependencies name if it exists
awk -F ":" '{if($1=="")print $2" is not in file known-dependencies.txt!"}' ~/result.txt
result=`awk -F ":" '{if($1=="")print $2}' ~/result.txt |wc -l`
#if has new third-party,the Action will fail
if [[ $result == 0 ]];then echo "All third dependencies is known!" ;else exit 1;fi
bash ${{ github.workspace }}/tool/dependencies/check_dependencies.sh
8 changes: 8 additions & 0 deletions hugegraph-hubble/hubble-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
<hubble-fe.dir>${project.basedir}/../hubble-fe</hubble-fe.dir>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hubble-be</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down
32 changes: 32 additions & 0 deletions tool/dependencies/check_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
simon824 marked this conversation as resolved.
Show resolved Hide resolved
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

basepath=$(cd `dirname $0`; pwd)

# check whether there are new third-party dependencies by diff command,
# diff generated 'current-dependencies.txt' file with 'known-dependencies.txt' file.
diff -w -B -U0 <(sort < ${basepath}/known-dependencies.txt) \
<(sort < ${basepath}/current-dependencies.txt) > ${basepath}/result.txt

# if has new third-party,the Action will fail and print diff
if [ -s ${basepath}/result.txt ]; then
cat ${basepath}/result.txt
exit 1
else
echo 'All third dependencies is known!'
fi
Loading