Skip to content

Commit e26c2c4

Browse files
committed
Fix reusing already built PMD binary in CI
The binary pmd-dist/taget/pmd-bin-x.y.z-SNAPSHOT.zip can be reused in CI builds but wasn't due to relative paths and wrong search directory.
1 parent 05535b3 commit e26c2c4

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

History.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
## Fixed Issues
66

77
* [#81](https://github.com/pmd/pmd-regression-tester/pull/81): Dynamically generated rulesets are not applied on diffs
8-
9-
## External Contributions
10-
118
* [#82](https://github.com/pmd/pmd-regression-tester/pull/82): Summary hash uses wrong key names
9+
* An already built PMD binary was not reused in CI
1210

1311
# 1.1.0 / 2020-12-05
1412

lib/pmdtester/builders/pmd_report_builder.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ def get_pmd_binary_file
3131

3232
raise "Wrong branch #{get_last_commit_sha}" unless build_branch_sha == get_last_commit_sha
3333

34+
distro_path = saved_distro_path(build_branch_sha)
3435
logger.debug "#{@pmd_branch_name}: PMD Version is #{@pmd_version} " \
3536
"(sha=#{build_branch_sha})"
36-
distro_path = saved_distro_path(build_branch_sha)
37+
logger.debug "#{@pmd_branch_name}: distro_path=#{distro_path}"
3738
if File.directory?(distro_path)
3839
logger.info "#{@pmd_branch_name}: Skipping packaging - saved version exists " \
3940
" in #{distro_path}"
@@ -53,7 +54,9 @@ def build_pmd(into_dir:)
5354
# in CI there might have been a build performed already. In that case
5455
# we reuse the build result, otherwise we build PMD freshly
5556
pmd_dist_target = "pmd-dist/target/pmd-bin-#{@pmd_version}.zip"
56-
if File.exist?("#{@local_git_repo}/#{pmd_dist_target}")
57+
binary_exists = File.exist?(pmd_dist_target)
58+
logger.debug "#{@pmd_branch_name}: Does the file #{pmd_dist_target} exist? #{binary_exists} (cwd: #{Dir.getwd})"
59+
if binary_exists
5760
# that's a warning, because we don't know, whether this build really
5861
# belongs to the current branch or whether it's from a previous branch.
5962
# In CI, that's not a problem, because the workspace is always fresh.

test/test_pmd_report_builder.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ def record_expectations_project_build(sha1, error = false)
145145
end
146146

147147
def record_expectations(sha1_head, sha1_base, zip_file_exists)
148-
Dir.expects(:chdir).with('target/repositories/pmd').yields.once
149148
PmdTester::Cmd.stubs(:execute).with('git rev-parse master^{commit}').returns(sha1_base).once
150149
# inside checkout_build_branch
151150
PmdTester::Cmd.stubs(:execute).with('git checkout master')

0 commit comments

Comments
 (0)