Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for Circleci rerun failed tests feature #146

Merged
merged 14 commits into from
Dec 4, 2023

Conversation

ArturT
Copy link
Member

@ArturT ArturT commented Dec 1, 2023

  • Add docs for Circleci rerun failed tests feature
  • Add info about advanced CircleCI features in the installation guide for the Ruby projects

story

https://trello.com/c/XFXyRYPu

@ArturT ArturT requested a review from 3v0k4 December 1, 2023 20:19
Copy link
Contributor

@3v0k4 3v0k4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic that integrates that easily. Great job 🙏

This is a great first step. But what if we actually did it inside the gem, so that users don't have to set up anything?

docusaurus/docs/ruby/circleci.md Outdated Show resolved Hide resolved
docusaurus/docs/knapsack_pro-ruby/guide/index.md Outdated Show resolved Hide resolved
docusaurus/docs/ruby/circleci.md Outdated Show resolved Hide resolved
docusaurus/docs/ruby/circleci.md Outdated Show resolved Hide resolved
# highlight-start
# Use circleci CLI to find out if we need to run all tests or rerun failed tests
# We are telling circleci to split the tests across 1 node to get the full list of all tests for consideration. We leave the splitting to Knapsack Pro.
circleci tests glob "spec/**/*_spec.rb" | circleci tests run --index 0 --total 1 --command ">/tmp/tests_to_run.txt xargs echo" --verbose > /tmp/tests_to_run.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that with -n1 you won't need the sed later:

Suggested change
circleci tests glob "spec/**/*_spec.rb" | circleci tests run --index 0 --total 1 --command ">/tmp/tests_to_run.txt xargs echo" --verbose > /tmp/tests_to_run.txt
circleci tests glob "spec/**/*_spec.rb" | circleci tests run --index 0 --total 1 --command ">/tmp/tests_to_run.txt xargs -n1 echo" --verbose > /tmp/tests_to_run.txt

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works. Cool. 🚀

docusaurus/docs/ruby/circleci.md Outdated Show resolved Hide resolved
docusaurus/docs/ruby/circleci.md Outdated Show resolved Hide resolved
sed -i 's/ /\n/g' /tmp/tests_to_run.txt

# tell Knapsack Pro to run only tests from the file (and still use Knapsack Pro Queue Mode magic)
if [[ -s "/tmp/tests_to_run.txt" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is checking if the file exists and is non-empty. Should that be always the case?

What if we remove the if and let Knapsack Pro raise an error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point.

Comment on lines 106 to 107
- We use [`KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE`](reference.md#knapsack_pro_test_file_list_source_file) to feed Knapsack Pro with a list of test files to run.
- Optionally, you can use [`KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES`](split-by-test-examples.md) to split slow test files by test examples automatically.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd either mention both in the snippet, or here. Currently, KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES is present in both.

If the links in the snippet cannot be made clickable, I'd leave them both down here.

Suggested change
- We use [`KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE`](reference.md#knapsack_pro_test_file_list_source_file) to feed Knapsack Pro with a list of test files to run.
- Optionally, you can use [`KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES`](split-by-test-examples.md) to split slow test files by test examples automatically.
The snippet above uses:
- [`KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES`] to split tests by examples
- [`KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE`] to specify what tests to run

ArturT and others added 11 commits December 4, 2023 19:57
Co-authored-by: Riccardo <riccardo.odone@gmail.com>
Co-authored-by: Riccardo <riccardo.odone@gmail.com>
Co-authored-by: Riccardo <riccardo.odone@gmail.com>
Co-authored-by: Riccardo <riccardo.odone@gmail.com>
Co-authored-by: Riccardo <riccardo.odone@gmail.com>
Co-authored-by: Riccardo <riccardo.odone@gmail.com>
…docs.knapsackpro.com into circleci-rerun-failed-tests
@ArturT ArturT merged commit 9eff5f1 into main Dec 4, 2023
3 checks passed
@ArturT ArturT deleted the circleci-rerun-failed-tests branch December 4, 2023 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants