Skip to content

Commit

Permalink
Change branch master to main (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
adangel authored Sep 19, 2024
1 parent bb59c62 commit 51847c4
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .ci/inc/fetch_ci_scripts.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function fetch_ci_scripts() {
local inc_dir
local inc_url
inc_dir="$(dirname "$0")/inc"
inc_url="${PMD_CI_SCRIPTS_URL:-https://raw.githubusercontent.com/pmd/build-tools/master/scripts}/inc"
inc_url="${PMD_CI_SCRIPTS_URL:-https://raw.githubusercontent.com/pmd/build-tools/main/scripts}/inc"

mkdir -p "${inc_dir}"

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- master
tags:
- '**'
pull_request:
Expand Down Expand Up @@ -40,7 +39,7 @@ jobs:
run: |
echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
echo "MAVEN_OPTS=-Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3" >> $GITHUB_ENV
echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/master/scripts" >> $GITHUB_ENV
echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/26/scripts" >> $GITHUB_ENV
- name: Check Environment
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: |
echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
echo "MAVEN_OPTS=-Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3" >> $GITHUB_ENV
echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/master/scripts" >> $GITHUB_ENV
echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/main/scripts" >> $GITHUB_ENV
- name: Check Environment
shell: bash
run: |
Expand Down
11 changes: 11 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

## New and Noteworthy

#### New Git default branch - "main"

We are joining the Git community and updating "master" to "main". Using the term "master" for the main
development branch can be offensive to some people. Existing versions of Git have been always capable of
working with any branch name and since 2.28.0 (July 2020) the default initial branch is configurable
(`init.defaultBranch`). Since October 2020, the default branch for new repositories on GitHub
is "main". Finally, PMD will also use this new name for the main branch in all our own repositories.

Note: The regression tester will also use branch `main` by default now for fetching repositories from the list of
projects. You might need to add `<tag>master</tag>` for some projects.

## Enhancements
* [#123](https://github.com/pmd/pmd-regression-tester/pull/123): Support ruby 3.3.0
* [#125](https://github.com/pmd/pmd-regression-tester/pull/125): Update rubocop configuration
Expand Down
12 changes: 6 additions & 6 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ home :: https://pmd.github.io
code :: https://github.com/pmd/pmd-regression-tester
bugs :: https://github.com/pmd/pmd-regression-tester/issues

build-status :: {<img src="https://github.com/pmd/pmd-regression-tester/workflows/build/badge.svg?branch=master" alt="Build Status" />}[https://github.com/pmd/pmd-regression-tester/actions?query=workflow%3Abuild]
build-status :: {<img src="https://github.com/pmd/pmd-regression-tester/workflows/build/badge.svg?branch=main" alt="Build Status" />}[https://github.com/pmd/pmd-regression-tester/actions?query=workflow%3Abuild]

gem-version :: {<img src="https://badge.fury.io/rb/pmdtester.svg" alt="Gem Version" />}[https://rubygems.org/gems/pmdtester]

Expand All @@ -29,9 +29,9 @@ on a list of standard projects(Spring Framework, Hibernate, Solr, etc.)
-l, --list-of-project path to the file which contains the list of standard projects
-m, --mode the mode of the tool: 'local', 'online' or 'single'
single: Set this option to 'single' if your patch branch contains changes
for any option that can't work on master/base branch
for any option that can't work on main/base branch
online: Set this option to 'online' if you want to download
the PMD report of master/base branch rather than generating it locally
the PMD report of main/base branch rather than generating it locally
local: Default option is 'local', PMD reports for the base and patch branches are generated locally.

-t, --threads Sets the number of threads used by PMD. Set threads to 0 to disable multi-threading processing.
Expand All @@ -49,15 +49,15 @@ on a list of standard projects(Spring Framework, Hibernate, Solr, etc.)

==== Run local mode

pmdtester -b master -p YOUR_DEVELOPMENT_BRANCH -r PATH_TO_LOCAL_PMD_REPO -a
pmdtester -b main -p YOUR_DEVELOPMENT_BRANCH -r PATH_TO_LOCAL_PMD_REPO -a

==== Run single mode

pmdtester -p YOUR_DEVELOPMENT_BRANCH -pc CONFIG_ONLY_CONTAINS_NEW_PMD_JAVA_RULE -m single

==== Run online mode

pmdtester -b master -p YOUR_DEVELOPMENT_BRANCH -r PATH_TO_LOCAL_PMD_REPO -m online -a
pmdtester -b main -p YOUR_DEVELOPMENT_BRANCH -r PATH_TO_LOCAL_PMD_REPO -m online -a

=== Output
The tool creates the following folders:
Expand Down Expand Up @@ -159,7 +159,7 @@ The tool creates the following folders:
* Update History.md and lib/pmdtester.rb for the next development version,
run again "bundle exec rake verify"
* Commit ("Prepare next development version x.y.z-SNAPSHOT").
* Push to master.
* Push to main.
* Push the tag. Github Actions will build and publish the new gem
* A github release is automatically created, verify it on https://github.com/pmd/pmd-regression-tester/releases
* To make pmd's main CI use the new version (in [pmd/pmd](https://github.com/pmd/pmd/)), go to the root directory and run `bundle lock --update`. Commit these changes.
Expand Down
7 changes: 5 additions & 2 deletions lib/pmdtester/builders/pmd_report_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ def initialize(projects, options, branch_config, branch_name)
def get_pmd_binary_file
logger.info "#{@pmd_branch_name}: Start packaging PMD"
Dir.chdir(@local_git_repo) do
build_branch_sha = Cmd.execute_successfully("git rev-parse #{@pmd_branch_name}^{commit}")

checkout_build_branch # needs a clean working tree, otherwise fails

# first checkout the build branch - that might create a local branch from remote, if
# a local branch doesn't exist yet. The following "git rev-parse" command only works
# for local branches.
build_branch_sha = Cmd.execute_successfully("git rev-parse #{@pmd_branch_name}^{commit}")

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

distro_path = saved_distro_path(build_branch_sha)
Expand Down
4 changes: 2 additions & 2 deletions lib/pmdtester/parsers/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def parse(argv)
mode_message = <<-DOC
the mode of the tool: 'local', 'online' or 'single'
single: Set this option to 'single' if your patch branch contains changes
for any option that can't work on master/base branch
for any option that can't work on main/base branch
online: Set this option to 'online' if you want to download
the PMD report of master/base branch rather than generating it locally
the PMD report of main/base branch rather than generating it locally
local: Default option is 'local', PMD reports for the base and patch branches are generated locally.
DOC

Expand Down
2 changes: 1 addition & 1 deletion lib/pmdtester/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def initialize(project) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/
@type = project.at_xpath('type').text
@connection = project.at_xpath('connection').text

@tag = project.at_xpath('tag')&.text || 'master'
@tag = project.at_xpath('tag')&.text || 'main'

webview_url_element = project.at_xpath('webview-url')
@webview_url = default_webview_url
Expand Down
10 changes: 5 additions & 5 deletions test/integration_test_pmd_report_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ def setup
`rake clean`
end

# Tests whether we can build successfully PMD from the sources of the master branch.
# The master branch should always be buildable by the regression tester. For older
# Tests whether we can build successfully PMD from the sources of the main branch.
# The main branch should always be buildable by the regression tester. For older
# versions, we can rely on baselines.
#
# Note 1: Although a base branch is configured here, this is not used. Only the patch
# branch is built.
# Note 2: We use a limited set of projects and rules, to make the test faster.
def test_build_master_branch
def test_build_main_branch
argv = ['-r', 'target/repositories/pmd',
'-b', 'pmd_releases/6.55.0',
'-p', 'master',
'-p', 'main',
'-c', 'test/resources/integration_test_pmd_report_builder/pmd7-config.xml',
'-l', 'test/resources/integration_test_pmd_report_builder/project-test.xml',
'--error-recovery',
Expand All @@ -34,6 +34,6 @@ def test_build_master_branch
builder.build

assert_equal(0, $CHILD_STATUS.exitstatus)
assert_path_exist('target/reports/master/checkstyle/pmd_report.xml')
assert_path_exist('target/reports/main/checkstyle/pmd_report.xml')
end
end
6 changes: 3 additions & 3 deletions test/integration_test_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def setup

def test_local_mode
argv = '-r target/repositories/pmd -b pmd_releases/6.41.0 -bc config/design.xml ' \
'-p master -pc config/design.xml -l test/resources/integration_test_runner/project-test.xml ' \
'-p main -pc config/design.xml -l test/resources/integration_test_runner/project-test.xml ' \
'--threads ' + Etc.nprocessors.to_s

system("bundle exec bin/pmdtester #{argv}")

assert_equal(0, $CHILD_STATUS.exitstatus)
assert_path_exist('target/reports/master/checkstyle/pmd_report.xml')
assert_path_exist('target/reports/master/pmd/pmd_report.xml')
assert_path_exist('target/reports/main/checkstyle/pmd_report.xml')
assert_path_exist('target/reports/main/pmd/pmd_report.xml')
assert_path_exist('target/reports/pmd_releases_6.41.0/checkstyle/pmd_report.xml')
assert_path_exist('target/reports/pmd_releases_6.41.0/checkstyle/config.xml')
assert_path_exist('target/reports/pmd_releases_6.41.0/pmd/pmd_report.xml')
Expand Down
40 changes: 20 additions & 20 deletions test/manual_integration_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# pmd regression tester is always called in online mode, comparing the pull request against
# the latest baseline.
#
# Test case 5 is creating a new baseline from master.
# Test case 5 is creating a new baseline from main.
#
# The test file is deliberately called "manual_integration_tests" so that it is not picked
# up by "bundle exec rake integration-test". It has to be run manually via
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_case_5_create_baseline
checkout_pmd_branch
argv = ['--mode', 'single',
'--local-git-repo', PMD_REPO_PATH,
'--patch-branch', 'master',
'--patch-branch', 'main',
'--patch-config', "#{PMD_REPO_PATH}/.ci/files/all-regression-rules.xml",
'--list-of-project', "#{PMD_REPO_PATH}/.ci/files/project-list.xml",
'--html-flag',
Expand All @@ -197,12 +197,12 @@ def test_case_5_create_baseline

print "#############################: test_case_5_create_baseline\n"
assert_path_not_exist('target/reports/diff')
assert_master_baseline
assert_main_baseline
end

private

def run_pmd_tester(base_branch_name = 'master')
def run_pmd_tester(base_branch_name = 'main')
argv = ['--local-git-repo', PMD_REPO_PATH,
'--list-of-project', "#{PMD_REPO_PATH}/.ci/files/project-list.xml",
'--base-branch', base_branch_name,
Expand All @@ -224,7 +224,7 @@ def run_pmd_tester(base_branch_name = 'master')

#
# This is the same message as in
# https://github.com/pmd/pmd/blob/master/Dangerfile
# https://github.com/pmd/pmd/blob/main/Dangerfile
#
def create_summary_message
'This changeset ' \
Expand All @@ -237,7 +237,7 @@ def create_summary_message
"#{@summary[:configerrors][:removed]} configuration errors."
end

def checkout_pmd_branch(branch = 'master')
def checkout_pmd_branch(branch = 'main')
system("git clone https://github.com/pmd/pmd #{PMD_REPO_PATH}") unless File.directory?(PMD_REPO_PATH)
Dir.chdir(PMD_REPO_PATH) do
system('git fetch --all')
Expand All @@ -251,7 +251,7 @@ def checkout_pmd_branch(branch = 'master')
end
end

def prepare_patch_branch(patch_file, local_branch, base_branch = 'master')
def prepare_patch_branch(patch_file, local_branch, base_branch = 'main')
absolute_patch_file = File.absolute_path("#{PATCHES_PATH}/#{patch_file}")
assert_path_exist(absolute_patch_file)

Expand All @@ -263,20 +263,20 @@ def prepare_patch_branch(patch_file, local_branch, base_branch = 'master')
end
end

def assert_master_baseline
assert_master_baseline_project('checkstyle', 40 * 1024 * 1024)
assert_master_baseline_project('openjdk-11', 80 * 1024 * 1024)
assert_master_baseline_project('spring-framework', 100 * 1024 * 1024)
assert_master_baseline_project('java-regression-tests', 100 * 1024)
assert_master_baseline_project('apex-link', 10 * 1024)
assert_master_baseline_project('fflib-apex-common', 400 * 1024)
assert_master_baseline_project('Schedul-o-matic-9000', 20 * 1024)
def assert_main_baseline
assert_main_baseline_project('checkstyle', 40 * 1024 * 1024)
assert_main_baseline_project('openjdk-11', 80 * 1024 * 1024)
assert_main_baseline_project('spring-framework', 100 * 1024 * 1024)
assert_main_baseline_project('java-regression-tests', 100 * 1024)
assert_main_baseline_project('apex-link', 10 * 1024)
assert_main_baseline_project('fflib-apex-common', 400 * 1024)
assert_main_baseline_project('Schedul-o-matic-9000', 20 * 1024)
end

def assert_master_baseline_project(project_name, report_size_in_bytes)
assert_path_exist("target/reports/master/#{project_name}/config.xml")
assert_path_exist("target/reports/master/#{project_name}/report_info.json")
assert_path_exist("target/reports/master/#{project_name}/pmd_report.xml")
assert(File.size("target/reports/master/#{project_name}/pmd_report.xml") > report_size_in_bytes)
def assert_main_baseline_project(project_name, report_size_in_bytes)
assert_path_exist("target/reports/main/#{project_name}/config.xml")
assert_path_exist("target/reports/main/#{project_name}/report_info.json")
assert_path_exist("target/reports/main/#{project_name}/pmd_report.xml")
assert(File.size("target/reports/main/#{project_name}/pmd_report.xml") > report_size_in_bytes)
end
end
Binary file added test/resources/runner/main-baseline.zip
Binary file not shown.
Binary file removed test/resources/runner/master-baseline.zip
Binary file not shown.
1 change: 1 addition & 0 deletions test/resources/runner/project-list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ xsi:noNamespaceSchemaLocation="projectlist_1_1_0.xsd">
<name>checkstyle</name>
<type>git</type>
<connection>https://github.com/checkstyle/checkstyle</connection>
<tag>master</tag>
<exclude-pattern>.*/target/test-classes/com/puppycrawl/tools/checkstyle/.*</exclude-pattern>
<exclude-pattern>.*/target/generated-sources/.*</exclude-pattern>
<exclude-pattern>.*/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/javaparser/InputJavaParserNoFreezeOnDeeplyNestedLambdas.java</exclude-pattern>
Expand Down
20 changes: 10 additions & 10 deletions test/test_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ class TestOptions < Test::Unit::TestCase
include PmdTester
def test_short_option
command_line =
%w[-r /path/to/repo -b pmd_releases/6.2.0 -p master
%w[-r /path/to/repo -b pmd_releases/6.2.0 -p main
-c config/all-java.xml -l config/project_list.txt -t 4]
opts = Options.new(command_line)
assert_equal('/path/to/repo', opts.local_git_repo)
assert_equal('pmd_releases/6.2.0', opts.base_branch)
assert_equal('master', opts.patch_branch)
assert_equal('main', opts.patch_branch)
assert_equal('config/all-java.xml', opts.config)
assert_equal('config/project_list.txt', opts.project_list)
assert_equal(4, opts.threads)
Expand All @@ -21,19 +21,19 @@ def test_short_option
def test_long_option
command_line =
%w[--local-git-repo /path/to/repo --base-branch pmd_releases/6.2.0
--patch-branch master --config config/all-java.xml
--patch-branch main --config config/all-java.xml
--list-of-project config/project_list.txt --threads 4]
opts = Options.new(command_line)
assert_equal('/path/to/repo', opts.local_git_repo)
assert_equal('pmd_releases/6.2.0', opts.base_branch)
assert_equal('master', opts.patch_branch)
assert_equal('main', opts.patch_branch)
assert_equal('config/all-java.xml', opts.config)
assert_equal('config/project_list.txt', opts.project_list)
assert_equal(4, opts.threads)
end

def test_default_value
command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p master]
command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p main]
opts = Options.new(command_line)
assert_equal(Options::DEFAULT_CONFIG_PATH, opts.base_config)
assert_equal(Options::DEFAULT_CONFIG_PATH, opts.patch_config)
Expand All @@ -43,33 +43,33 @@ def test_default_value
end

def test_download_url_with_trailing_slash
command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p master --baseline-download-url https://example.com/]
command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p main --baseline-download-url https://example.com/]
opts = Options.new(command_line)
assert_equal('https://example.com/', opts.baseline_download_url_prefix)
end

def test_download_url_without_trailing_slash
command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p master --baseline-download-url https://example.com]
command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p main --baseline-download-url https://example.com]
opts = Options.new(command_line)
assert_equal('https://example.com/', opts.baseline_download_url_prefix)
end

def test_enable_error_recovery
command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p master --error-recovery]
command_line = %w[-r /path/to/repo -b pmd_releases/6.2.0 -p main --error-recovery]
opts = Options.new(command_line)
assert_true(opts.error_recovery)
end

def test_single_mode
command_line =
%w[-r /path/to/repo -p master -pc config.xml -l list.xml -f -m single]
%w[-r /path/to/repo -p main -pc config.xml -l list.xml -f -m single]
opts = Options.new(command_line)
assert_equal(true, opts.html_flag)
end

def test_invalid_mode
argv =
%w[-r /path/to/repo -b pmd_releases/6.2.0 -p master
%w[-r /path/to/repo -b pmd_releases/6.2.0 -p main
-c config/all-java.xml -l config/project_list.txt -m invalid_mode]
begin
Options.new(argv)
Expand Down
Loading

0 comments on commit 51847c4

Please sign in to comment.