diff options
| author | mo khan <mo.khan@gmail.com> | 2020-09-14 17:24:09 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-09-14 17:24:09 -0600 |
| commit | b399512a961b2932e3d399a891a44f3535b26def (patch) | |
| tree | a30afc74e5a40b50aad78d497e3dac789086c2cf /lib/e2e | |
| parent | 853ae09d4c6d0220a3f77492065961e65f96e860 (diff) | |
test: scan simple maven project
Diffstat (limited to 'lib/e2e')
| -rw-r--r-- | lib/e2e/dependency_scanning_report.rb | 14 | ||||
| -rw-r--r-- | lib/e2e/docker.rb | 8 |
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/e2e/dependency_scanning_report.rb b/lib/e2e/dependency_scanning_report.rb new file mode 100644 index 0000000..9f6e4be --- /dev/null +++ b/lib/e2e/dependency_scanning_report.rb @@ -0,0 +1,14 @@ +class DependencyScanningReport + def initialize(project_path:) + report_path = project_path.join('gl-dependency-scanning-report.json') + @content = report_path.exist? ? JSON.parse(report_path.read) : {} + end + + def to_h + @content + end + + def to_s + JSON.pretty_generate(to_h) + end +end diff --git a/lib/e2e/docker.rb b/lib/e2e/docker.rb index 3c4d589..be85e53 100644 --- a/lib/e2e/docker.rb +++ b/lib/e2e/docker.rb @@ -18,10 +18,14 @@ class Docker end end - def run(image:, project_path: Pathname.pwd, env: {}) + def run(image:, project_path: Pathname.pwd, env: {}, debug: ENV.fetch('DEBUG', 'false') == 'true') env_options = DEFAULT_ENV.merge(env).map { |(key, value)| "--env #{key}=#{value}" } - command = expand([:docker, :run, '-it', '--rm', "--volume=#{project_path}:/tmp/app", '--network=host', env_options, image, '/analyzer run']) Dir.chdir pwd do + command = if debug + expand([:docker, :run, '-it', "--entrypoint=''", '--rm', "--volume=#{project_path}:/tmp/app", '--network=host', env_options, image, '/bin/bash -l']) + else + expand([:docker, :run, '--rm', "--volume=#{project_path}:/tmp/app", '--network=host', env_options, image, '/analyzer run']) + end system(command, exception: true) end end |
