diff options
| -rwxr-xr-x | bin/lint | 1 | ||||
| -rw-r--r-- | config/.bashrc | 5 | ||||
| -rwxr-xr-x | run.sh | 107 |
3 files changed, 48 insertions, 65 deletions
@@ -4,3 +4,4 @@ shellcheck bin/* shellcheck config/.bashrc shellcheck config/.profile shellcheck config/*.sh +shellcheck run.sh diff --git a/config/.bashrc b/config/.bashrc index a4ab7cf..7c30eed 100644 --- a/config/.bashrc +++ b/config/.bashrc @@ -1,6 +1,9 @@ #!/bin/bash -export BUNDLE_JOBS=8 +BUNDLE_JOBS="$(nproc)" +export BUNDLE_JOBS +export BUNDLE_PATH="vendor/bundle" +export BUNDLE_WITHOUT="development test" export DOTNET_CLI_TELEMETRY_OPTOUT=1 export HISTFILESIZE=0 export HISTSIZE=0 @@ -40,26 +40,20 @@ shift $((OPTIND - 1)) COMMAND=$1 shift -# "/run.sh" as a command means the user want the "analyze" command. if [ "$COMMAND" = "/run.sh" ] ; then COMMAND="analyze" fi if [ "$COMMAND" = "analyse" ] ; then COMMAND="analyze" fi - -# "/test/test.sh" as a command means the user want the "test" command. if [ "$COMMAND" = "/test/test.sh" ] ; then COMMAND="test" fi - -# Check number of arguments -if [ "$COMMAND" = "analyze" -a $# -ne 1 ] ; then +if [ "$COMMAND" = "analyze" ] && [ $# -ne 1 ] ; then echo "$usage" exit 1 fi - -if [ "$COMMAND" = "test" -a $# -ne 3 ] ; then +if [ "$COMMAND" = "test" ] && [ $# -ne 3 ] ; then echo "$usage" exit 1 fi @@ -68,86 +62,71 @@ fi case "$COMMAND" in test) # Run integration tests. - exec /test/test.sh $1 $2 $3 + exec /test/test.sh "$1" "$2" "$3" ;; analyze) - # Analyze project - - # Change current directory to the project path. APP_PATH=$1 shift - pushd $APP_PATH > /dev/null + pushd "$APP_PATH" > /dev/null asdf list asdf current if [[ -z "${SETUP_CMD}" ]]; then asdf install - - # Before running license_finder, we need to install dependencies for the project. - if test -f Gemfile ; then - ruby -v - gem --version - bundle --version - bundle config --local path 'vendor/bundle' - bundle config --local without 'development test' - bundle install --jobs $(nproc) - skip_prepare=true - fi - if test -f package.json; then - # Check is npm is being used - if [ -f package-lock.json ] && [ ! -f yarn.lock ] ; then - echo "Installing npm packages with npm ci" - npm ci - fi - # install via yarn - if [ ! -d node_modules ]; then - echo "Installing yarn packages" - yarn install --ignore-engines --ignore-scripts - fi - skip_prepare=true + if test -f package.json; then + if [ -f package-lock.json ] && [ ! -f yarn.lock ] ; then + echo "Installing npm packages with npm ci" + npm ci fi - if find . -name "*.go" -printf "found" -quit |grep found >/dev/null ; then - if [[ ( ! -f glide.lock ) && ( ! -f vendor/manifest ) && (! -f Gopkg.lock ) && (! -f go.mod ) ]]; then - echo "running go get" - # Only install deps if not using glide, govendor or dep - # Symlink the project into GOPATH to allow fetching dependencies. - ln -sf `realpath $APP_PATH` /gopath/src/app - pushd /gopath/src/app > /dev/null - go get || true - skip_prepare=true - fi + if [ ! -d node_modules ]; then + echo "Installing yarn packages" + yarn install --ignore-engines --ignore-scripts fi - if test -f pom.xml ; then - # Install Java Maven dependencies. - mvn install ${MAVEN_CLI_OPTS:--DskipTests} - skip_prepare=true - fi - if [ -f build.gradle ] && [ ! -f gradlew ] ; then - gradle build ${GRADLE_CLI_OPTS:"-x test"} + skip_prepare=true + fi + if find . -name "*.go" -printf "found" -quit |grep found >/dev/null ; then + if [[ ( ! -f glide.lock ) && ( ! -f vendor/manifest ) && (! -f Gopkg.lock ) && (! -f go.mod ) ]]; then + echo "running go get" + # Only install deps if not using glide, govendor or dep + # Symlink the project into GOPATH to allow fetching dependencies. + ln -sf "$(realpath "$APP_PATH")" /gopath/src/app + pushd /gopath/src/app > /dev/null + go get || true skip_prepare=true fi - if [[ $(ls ./*.sln 2> /dev/null) ]]; then - LICENSE_FINDER_CLI_OPTS="--recursive $LICENSE_FINDER_CLI_OPTS" - fi - else - echo "Running '${SETUP_CMD[@]}' to install project dependencies..." - ${SETUP_CMD[@]} + fi + if test -f pom.xml ; then + mvn install "${MAVEN_CLI_OPTS:--DskipTests}" + skip_prepare=true + fi + if [ -f build.gradle ] && [ ! -f gradlew ] ; then + gradle build "${GRADLE_CLI_OPTS:"-x test"}" skip_prepare=true + fi + if [[ $(ls ./*.sln 2> /dev/null) ]]; then + LICENSE_FINDER_CLI_OPTS="--recursive $LICENSE_FINDER_CLI_OPTS" + fi + else + echo "Running '${SETUP_CMD}' to install project dependencies..." + "${SETUP_CMD[@]}" + skip_prepare=true fi - # Run License Finder. - echo "Running license_finder $@ in $PWD" + echo "Running license_finder in $PWD" if [ "$skip_prepare" != true ]; then - prepare="--prepare-no-fail" + prepare="--prepare-no-fail" else - prepare="--no-prepare" + prepare="--no-prepare" fi + ruby -v + gem --version + bundle --version gem install "$LM_HOME/*.gem" license_management ignored_groups add development license_management ignored_groups add test echo "Preparing JSON report..." - license_management report ${prepare} --format=json --save=gl-license-management-report.json ${LICENSE_FINDER_CLI_OPTS} + license_management report ${prepare} --format=json --save=gl-license-management-report.json "${LICENSE_FINDER_CLI_OPTS}" popd > /dev/null ;; |
