You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docusaurus/docs/ruby/predict.mdx
+35-2Lines changed: 35 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,39 @@ A substantial percentage of your CI builds is spent running tests that would nev
25
25
26
26
PREDICT runs only the tests that are likely to fail. The subset of tests is calculated by combining the test code coverage collected over time with the changes you are working on.
27
27
28
+
## How it works
29
+
30
+
PREDICT collects test coverage into a report that looks like the following:
31
+
32
+
```json
33
+
{
34
+
"spec/models/user_spec.rb[1:1]": [
35
+
"app/models/user.rb"
36
+
],
37
+
"spec/features/dashboard_spec.rb[1:1:1]": [
38
+
"app/models/user.rb",
39
+
"app/models/organization.rb",
40
+
"app/controllers/application_controller.rb",
41
+
"app/controllers/dashboard_controller.rb",
42
+
"app/views/dashboard/index.html.erb"
43
+
]
44
+
}
45
+
```
46
+
47
+
The test prediction is based on the following steps:
48
+
1. Fetch from the API the most recent test coverage report
49
+
1. Calculate what files changed between the current commit and the commit that generated the report
50
+
1. Find in the report which test examples cover the changed files
51
+
52
+
For example, if `app/models/user.rb` changed, PREDICT would run:
53
+
-`spec/models/user_spec.rb[1:1]`
54
+
-`spec/features/dashboard_spec.rb[1:1:1]`
55
+
56
+
If `app/views/dashboard/index.html.erb` changed instead, PREDICT would only run:
57
+
-`spec/features/dashboard_spec.rb[1:1:1]`
58
+
59
+
## Configuration
60
+
28
61
To enable PREDICT, set any of the following ENV variables:
29
62
30
63
*`KNAPSACK_PRO_PREDICT_DISABLED_ON_BRANCHES` (comma-separated strings or regular expressions): on what branches to run all the tests
@@ -38,7 +71,7 @@ Given the dynamic nature of Ruby, PREDICT will likely not be correct 100% of the
38
71
* Include `[skip predict]` / `[predict skip]` in the last commit message before you merge a pull request
39
72
* Include your production branch in `KNAPSACK_PRO_PREDICT_DISABLED_ON_BRANCHES`
40
73
41
-
##**Example**
74
+
### Example
42
75
43
76
Given the following configuration on CI:
44
77
@@ -57,7 +90,7 @@ You can expect the following behaviour:
57
90
* The current commit message contains `[skip predict]` / `[predict skip]`
58
91
* The per-test coverage does not exist on the Knapsack Pro API (e.g., you just enabled PREDICT)
59
92
60
-
## Ruby glob
93
+
###Ruby glob
61
94
62
95
Both `KNAPSACK_PRO_PREDICT_DISABLED_ON_CHANGED_FILES` and `KNAPSACK_PRO_PREDICT_ALWAYS_RUN_TESTS` accept a Ruby glob as a value.
0 commit comments