RELEASE_TESTING.MD
Before releasing a new version of KtLint, the release candidate is tested on a selection of open source projects to improve the quality of the release, and the documentation is tested for dead links.
mkdir sample-projects
cd sample-projects
sample-projects directory, create a shell command script exec-in-each-project.sh with content below. This script is used to run the same command in each of the sample projects:
# Examples of usage
#
# Outstanding changes per project
# ./exec-in-each-project.sh "git status"
#
# Rollback outstanding changes per project
# ./exec-in-each-project.sh "git reset --hard"
#
# Run ktlint standard rules
# ktlint --version && ktlint "**/*.kt" -v --relative -F
#
# Commit changes of standard rules:
# ./exec-in-each-project.sh "git commit -m \"ktlint (0.43.2) -F\""
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && $@" \;
git clone https://github.com/google/iosched.git
git clone https://github.com/android/uamp.git
git clone https://github.com/siempredelao/StaticAnalysisTest
git clone https://github.com/Kotlin/kotlinx.coroutines.git
git clone https://github.com/square/okhttp.git
git clone https://github.com/detekt/detekt.git
git clone https://github.com/ExpediaGroup/graphql-kotlin.git
git clone https://github.com/Kotlin/kotlinx.serialization.git
alias ktlint-prev="ktlint-1.7.1 $@" # Replace with the latest release version
~/git/ktlint is the directory in which the ktlint project is checked out and that ~/git/ktlint/ktlint refers to the ktlint CLI-module.alias ktlint-dev="echo 'ktlint-dev version:';ls -aslh ~/git/ktlint/ktlint/ktlint-cli/build/run/ktlint;echo ' ';~/git/ktlint/ktlint/ktlint-cli/build/run/ktlint $@"
~/git/ktlint/pinterest/ktlint is the directory in which the ktlint project is checked out../exec-in-each-project.sh "git reset --hard origin"
./exec-in-each-project.sh "git pull"
Pre-requisites:
ktlint:
ktlint-prev --version
ktlint-dev (more or less) matches with the datetime of this compilation.
ktlint-dev --version
Formatting projects in which ktlint is not used may result in a huge amount of fixes. The main focus of this test is to see what the effects are when upgrading ktlint in a project already formatted with latest released ktlint version.
.editorconfig in the integration test directory with content below. Also follow up the instructions mentioned:
root = true
[graphql-kotlin/**/*.{kt,kts}]
ktlint_standard_no-unused-imports = disabled
[kotlinx.coroutines/**/*.{kt,kts}]
ktlint_standard_no-wildcard-imports = disabled
[*.{kt,kts}]
# The open source projects that are used for release testing of ktlint contain a few '.editorconfig' files which need to
# be changed:
# 1) Disable the "root = true" property so that each project ultimately falls back on this file. In this way offending
# rules can be easily enabled/disabled for all test projects
ktlint_code_style = ktlint_official
ktlint_experimental = enabled
ktlint_standard = enabled
./exec-in-each-project.sh "git add --all && git commit -m \"Update .editorconfig to fallback to integration test settings\""
ktlint-prev --format --relative # Do not call this command via the "./exec-in-each-project.sh" script.
./exec-in-each-project.sh "git add --all && git commit -m \"Format with previous ktlint version (round #)\""
rm baseline.xml
ktlint-prev --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script.
ktlint-prev -F --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script.
baseline.xml no files are changed (in step 4 and 5 all violations which could be autocorrected have already been committed). Remaining violations which could not be autocorrected are saved in the baseline.xml which is stored outside the project directories.
./exec-in-each-project.sh "git status"
ktlint-dev --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want to use the one combined baseline.xml file for all projects.
Internal Error (...) in file '...' at position '0:0. Please create a ticket at https://github.com/pinterest/ktlint/issues ...
ktlint-dev -F --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want to use the one combined baseline.xml file for all projects.
Internal Error (...) in file '...' at position '0:0. Please create a ticket at https://github.com/pinterest/ktlint/issues ...
./exec-in-each-project.sh "git add --all && git commit -m \"Fixed with latest development version\""
rm baseline.xml
ktlint-dev --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want to use the one combined baseline.xml file for all projects.
Internal Error (...) in file '...' at position '0:0. Please create a ticket at https://github.com/pinterest/ktlint/issues ...
ktlint-dev --baseline=baseline.xml --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want one combined baseline.xml file for all projects.
No violations should be reported in this run.
13. Rerun format with latest development version without baseline:
shell ktlint-dev -F --relative # Do not call this command via the "./exec-in-each-project.sh" script as we want to use the one combined baseline.xml file for all projects.
As the baseline is removed, thousands of violations are to be expected. Check at least in the summary that no internal errors are thrown like below:
plain Internal Error (...) in file '...' at position '0:0. Please create a ticket at https://github.com/pinterest/ktlint/issues ...
As the baseline is removed, thousands of violations are to be reported and/or autocorrected. Check at least in the summary that no internal errors are thrown like below:
The documentation for KtLint should be checked for dead links.
Follow the instructions for building the documentation in /docs/readme.md, and use a tool such as Broken Link Checker Tool to find broken links.