diff options
| -rw-r--r-- | .gitlab-ci.yml | 2 | ||||
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | Gemfile.lock | 2 | ||||
| -rw-r--r-- | README.md | 3 | ||||
| -rwxr-xr-x | bin/docker-build | 9 | ||||
| -rwxr-xr-x | bin/docker-shell | 9 | ||||
| -rwxr-xr-x | bin/test | 9 | ||||
| -rwxr-xr-x | bin/test-all (renamed from bin/test_all) | 16 | ||||
| -rw-r--r-- | lib/license/management.rb | 14 | ||||
| -rw-r--r-- | lib/license/management/version.rb | 2 | ||||
| -rwxr-xr-x | run.sh | 2 |
11 files changed, 57 insertions, 15 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 63e119c..122e713 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,7 +42,7 @@ container_scanning: - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - docker pull $TMP_IMAGE - mkdir results - - ./bin/test + - IMAGE_NAME=$TMP_IMAGE ./bin/test artifacts: paths: - results/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b357e9..39fae56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # GitLab License management changelog +## v1.8.0 + +- Add ability to configure the `license_finder` execution via `LICENSE_FINDER_CLI_OPTS` (!77) + ## v1.7.4 - Install [.NET Core 2.2, 3.0](https://github.com/pivotal/LicenseFinder/pull/632) so that we can install packages for .NET Core 2.2, 3.0 projects. diff --git a/Gemfile.lock b/Gemfile.lock index 4459fda..24efd8e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - license-management (1.7.3) + license-management (1.8.0) license_finder (= 5.6.2) GEM @@ -41,7 +41,7 @@ docker run --rm --volume "/path/to/my/project":/code license-management analyze You can run integration tests on the image like this: ```sh -./bin/test_all +./bin/test-all ``` where: @@ -90,6 +90,7 @@ The License Management tool can be customized with environments variables for so | Environment variable | Project type | Function | |----------------------|--------------|----------| | MAVEN_CLI_OPTS | Java (Maven) | Additional arguments for the mvn executable. If not supplied, defaults to `-DskipTests`. | +| LICENSE_FINDER_CLI_OPTS | * | Additional arguments for the `license_finder` executable. | | LM_JAVA_VERSION | Java (Maven) | Version of Java. If set to `11`, Maven and Gradle use Java 11 instead of Java 8. | | LM_PYTHON_VERSION | Python | Version of Python. If set to `3`, dependencies are installed using Python 3 instead of Python 2.7. | diff --git a/bin/docker-build b/bin/docker-build new file mode 100755 index 0000000..428dda8 --- /dev/null +++ b/bin/docker-build @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +cd "$(dirname "$0")/.." + +IMAGE_NAME=${IMAGE_NAME:-$(basename "$PWD"):latest} + +docker build . -t "$IMAGE_NAME" --pull diff --git a/bin/docker-shell b/bin/docker-shell new file mode 100755 index 0000000..b50e796 --- /dev/null +++ b/bin/docker-shell @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +cd "$(dirname "$0")/.." + +IMAGE_NAME=${IMAGE_NAME:-$(basename "$PWD"):latest} + +docker run --rm -it --entrypoint='' $1 "$IMAGE_NAME" /bin/bash @@ -2,14 +2,17 @@ set -e +cd "$(dirname "$0")/.." + export LM_PYTHON_VERSION=${LM_PYTHON_VERSION:-2} export LM_REPORT_VERSION=${LM_REPORT_VERSION:-1} export QA_RESULTS=${QA_RESULTS:-$QA_PROJECT-v$LM_REPORT_VERSION} -export RESULTS_DIR=${RESULTS_DIR:-`pwd`/results} +export RESULTS_DIR=${RESULTS_DIR:-$(pwd)/results} +export QA_REF=${QA_REF:-master} docker run \ --rm \ --env LM_PYTHON_VERSION \ --env LM_REPORT_VERSION \ - --volume $RESULTS_DIR:/results \ - $TMP_IMAGE test $QA_PROJECT ${QA_RESULTS} $QA_REF + --volume "$RESULTS_DIR":/results \ + "$IMAGE_NAME" test "$QA_PROJECT" "$QA_RESULTS" "$QA_REF" diff --git a/bin/test_all b/bin/test-all index ca47027..16d30e9 100755 --- a/bin/test_all +++ b/bin/test-all @@ -4,21 +4,23 @@ set -e cd "$(dirname "$0")/.." -export RESULTS_DIR=`pwd`/tmp -export TMP_IMAGE=$(basename $PWD):latest +RESULTS_DIR=$(pwd)/tmp +export RESULTS_DIR +IMAGE_NAME=$(basename "$PWD"):latest +export IMAGE_NAME -docker build . -t $TMP_IMAGE --pull +./bin/docker-build REPORT_VERSIONS=(1 1.1 2) for version in "${REPORT_VERSIONS[@]}" do export LM_REPORT_VERSION=$version echo "Report Version $LM_REPORT_VERSION" - QA_PROJECT=go-modules QA_REF=master ./bin/test + QA_PROJECT=go-modules ./bin/test QA_PROJECT=java-maven QA_REF=831c7a04 ./bin/test QA_PROJECT=python-pip QA_REF=04dce91b LM_PYTHON_VERSION=2 ./bin/test QA_PROJECT=python-pip QA_RESULTS="python3-pip-v$version" QA_REF=48e250a1 LM_PYTHON_VERSION=3 ./bin/test - QA_PROJECT=ruby-bundler QA_REF=master ./bin/test - QA_PROJECT=js-yarn QA_REF=master ./bin/test - QA_PROJECT=csharp-nuget-dotnetcore QA_REF=master ./bin/test + QA_PROJECT=ruby-bundler ./bin/test + QA_PROJECT=js-yarn ./bin/test + QA_PROJECT=csharp-nuget-dotnetcore ./bin/test done diff --git a/lib/license/management.rb b/lib/license/management.rb index 64fd4e8..a6e0664 100644 --- a/lib/license/management.rb +++ b/lib/license/management.rb @@ -12,6 +12,20 @@ require 'license/management/version' # This applies a monkey patch to the JsonReport found in the `license_finder` gem. LicenseFinder::JsonReport.prepend(License::Management::Report) +# This monkey patch can be removed once we upgrade to license_finder 5.9.2. Details [here](https://gitlab.com/gitlab-org/gitlab/issues/13748#note_235810786). +module LicenseFinder + class Bundler < PackageManager + def definition + @definition ||= + begin + Dir.chdir(project_path.to_s) do + ::Bundler::Definition.build(detected_package_path, lockfile_path, nil) + end + end + end + end +end + module License module Management def self.root diff --git a/lib/license/management/version.rb b/lib/license/management/version.rb index 8161098..f42933e 100644 --- a/lib/license/management/version.rb +++ b/lib/license/management/version.rb @@ -2,6 +2,6 @@ module License module Management - VERSION = '1.7.4' + VERSION = '1.8.0' end end @@ -194,7 +194,7 @@ case "$COMMAND" in prepare="--prepare" fi echo "Preparing JSON report..." - license_management report ${prepare} --format=json --save=gl-license-management-report.json + license_management report ${prepare} --format=json --save=gl-license-management-report.json ${LICENSE_FINDER_CLI_OPTS} # rvm removes trap in bash: https://github.com/rvm/rvm/issues/4416 declare -f restore_lockfile > /dev/null && restore_lockfile popd > /dev/null |
