mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Update script/github_pr_errors with better rerun instructions
The script now recommends using the commands from `docs/development/testing/handling-flaky-tests/README.md` to be closer to CI conditions. [skip ci]
This commit is contained in:
+36
-19
@@ -54,7 +54,7 @@ class Options
|
||||
|
||||
Use this script with xargs to run failing specs locally:
|
||||
|
||||
#{$0} | xargs --no-run-if-empty bundle exec rspec
|
||||
#{$0} | xargs --no-run-if-empty bin/rspec
|
||||
|
||||
|
||||
Options:
|
||||
@@ -523,7 +523,7 @@ class Formatter
|
||||
def display_errors_from_report(report)
|
||||
display_failures_explanation(report.failures_explanation)
|
||||
display_errors(report.errors)
|
||||
display_checkout_test_commit_information(report) if Options.display_rerun_info
|
||||
display_rerun_env_setup(report) if Options.display_rerun_info
|
||||
end
|
||||
|
||||
def display_failures_explanation(failures_explanation)
|
||||
@@ -641,24 +641,36 @@ class Formatter
|
||||
].join
|
||||
end
|
||||
|
||||
def display_checkout_test_commit_information(report)
|
||||
if report.merge_branch_sha
|
||||
warn <<~INSTRUCTIONS.white.dark
|
||||
GitHub Action run merged #{report.merge_branch_sha} into #{report.head_sha} before running.
|
||||
def display_rerun_env_setup(report)
|
||||
warn <<~INSTRUCTIONS.white.dark
|
||||
To be closer to CI conditions, run these commands first:
|
||||
```
|
||||
#{checkout_test_commit_commands(report)}
|
||||
#{reset_test_database_command}
|
||||
#{precompile_assets_command}
|
||||
```
|
||||
Then start a load-stress tool and run a test group using the rspec command above.
|
||||
INSTRUCTIONS
|
||||
end
|
||||
|
||||
To be with the exact same source files as CI, use these commands (warning: stash your modifications first):
|
||||
git checkout -B repro_ci_failures #{report.head_sha}
|
||||
git merge --no-edit --no-verify #{report.merge_branch_sha}
|
||||
def checkout_test_commit_commands(report)
|
||||
if report.merge_branch_sha
|
||||
<<~INSTRUCTIONS
|
||||
# GitHub Action run merged #{report.merge_branch_sha} into #{report.head_sha} (#{report.head_branch} branch)
|
||||
git checkout -B repro_ci_failures #{report.head_sha}
|
||||
git merge --no-edit --no-verify #{report.merge_branch_sha}
|
||||
INSTRUCTIONS
|
||||
else
|
||||
warn <<~INSTRUCTIONS.white.dark
|
||||
To be with the exact same source files as CI, use this command:
|
||||
git checkout #{report.head_sha}
|
||||
INSTRUCTIONS
|
||||
"git checkout #{report.head_sha}"
|
||||
end
|
||||
warn <<~INSTRUCTIONS.white.dark
|
||||
Then run a test group with the rspec command above.
|
||||
INSTRUCTIONS
|
||||
end
|
||||
|
||||
def reset_test_database_command
|
||||
"bin/rails db:drop db:create db:migrate RAILS_ENV=test"
|
||||
end
|
||||
|
||||
def precompile_assets_command
|
||||
"bin/rails assets:clobber openproject:plugins:register_frontend assets:precompile"
|
||||
end
|
||||
|
||||
def display_tests_group_info(tests_group)
|
||||
@@ -670,9 +682,14 @@ class Formatter
|
||||
def display_tests_group_rerun_commands(tests_group)
|
||||
return unless tests_group
|
||||
|
||||
warn "To run the tests group in the same order as CI, use this command:".white.dark
|
||||
warn "CI=true TZ=UTC bundle exec rspec --seed #{tests_group.seed} #{tests_group.files.join(' ')}".white.dark
|
||||
warn ""
|
||||
warn <<~COMMANDS.white.dark
|
||||
To run the tests group in conditions closer to CI, use this command:
|
||||
```
|
||||
CI=true TZ=UTC OPENPROJECT_LOG__LEVEL=info CAPYBARA_PUMA_THREADS=0:4 \
|
||||
DISABLE_SPRING=1 OPENPROJECT_DISABLE_DEV_ASSET_PROXY=1 \
|
||||
bin/rspec --seed #{tests_group.seed} #{tests_group.files.join(' ')}
|
||||
```
|
||||
COMMANDS
|
||||
end
|
||||
|
||||
def status_icon(job)
|
||||
|
||||
Reference in New Issue
Block a user