@suffolklitlab/alkiln 5.13.4 → 5.15.0-deps-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.github/workflows/github_server.yml +1 -1
  2. package/.github/workflows/playground.yml +2 -1
  3. package/.github/workflows/unit_tests.yml +1 -1
  4. package/CHANGELOG.md +40 -0
  5. package/action.yml +26 -10
  6. package/action_for_github_server/action.yml +31 -27
  7. package/docs/4_environments.md +2 -2
  8. package/docs/artifacts_folder_name.md +121 -71
  9. package/docs/constrained_random_tests.md +220 -289
  10. package/docs/decisions/move_runtime_config_to_sources_folder.md +3 -1
  11. package/docs/prioritize_constrained_random_tests.md +35 -76
  12. package/lib/docassemble/server_install.js +0 -2
  13. package/lib/docassemble/setup.js +1 -3
  14. package/lib/docassemble/takedown.js +2 -2
  15. package/lib/globals.js +10 -0
  16. package/lib/run_cucumber.js +40 -53
  17. package/lib/scope.js +44 -1
  18. package/lib/setup/TestGenerator.js +1757 -0
  19. package/lib/setup/artifacts.js +20 -0
  20. package/lib/setup/generate.js +42 -0
  21. package/lib/setup/get_Gherkin_AST.js +26 -0
  22. package/lib/setup/validate.js +89 -0
  23. package/lib/steps.js +101 -42
  24. package/lib/utils/Log.js +317 -165
  25. package/lib/utils/_alkiln-constrained_random_tests_old.js +1776 -0
  26. package/lib/utils/get_error_stacks.js +16 -0
  27. package/lib/utils/pdf_reader.js +9 -2
  28. package/lib/utils/reports.js +44 -22
  29. package/lib/utils/session_vars.js +77 -57
  30. package/lib/utils/set_sources_paths.js +98 -0
  31. package/npm-shrinkwrap.json +739 -924
  32. package/package.json +17 -10
  33. package/tests/log_codes/check_codes.sh +17 -13
  34. package/tests/log_codes/log_code_expected_instances.txt +58 -0
  35. package/tests/unit_tests/constrained_random_answers/invalid.fixtures.js +178 -0
  36. package/tests/unit_tests/constrained_random_answers/invalid.test.js +251 -0
  37. package/tests/unit_tests/constrained_random_answers/valid.fixtures.js +957 -0
  38. package/tests/unit_tests/constrained_random_answers/valid.test.js +563 -0
  39. package/tests/unit_tests/example_of_chai_test_lifecycle.js +78 -0
  40. package/tests/unit_tests/log.test.js +17 -41
  41. package/docs/seprate_file_generation_GitHub_action.md +0 -11
  42. package/lib/parse.js +0 -36
  43. package/lib/utils/get_sources_paths.js +0 -162
  44. package/lib/utils/parse.js +0 -1
  45. package/lib/utils/proccess_command_line_args.js +0 -267
  46. /package/docs/{expected_inernal_results.md → expected_internal_results.md} +0 -0
@@ -21,115 +21,165 @@ Our 4 environments can be condensed into 3 environments for the purpose of manag
21
21
  - ALKilnInThePlayground
22
22
  - The command line for internal development
23
23
 
24
- The GitHub action creates an artifact folder name and sends it to various scripts that use an instance of the `Log` class to create the folder and save the name. In other environments, an instance of the `Log` class both creates the name, creates the folder, and saves the name. The instance of the `Log` saves the name in `runtime_config.json`. That instance of `Log` and other ALKiln code uses that name to create and store files in that artifacts folder.
24
+ Every environment runs npm commands. Those commands are sometimes run separately and thus trigger separate processes. We must find a way to persist information, like the name of the artifacts folder, across these processes.
25
25
 
26
- The artifact folder name generation code is in 2 places - the GitHub action and ALKiln's core code[^1]. In future, we may reduce that to just one location - the core code.
26
+ The GitHub action creates an artifact folder name and sends it to a script that use an instance of the `Log` class to create the folder and save the name. In other environments, an instance of the `Log` class is what creates the name.
27
27
 
28
- <!-- More complex description that I don't think we need now, but want to double check:
29
- The scripts that GitHub action uses need to store its output in the same artifacts folder. The GitHub action therefore builds the name of the artifact folder and passes that around to the different scripts. The scripts pass the folder name to the `Log` class every time, which saves the folder name in `runtime_config.json`. After that, the core code uses that `json` value to put other artifacts in the same folder. We also have folder-naming code in the core code which we use for other purposes. The GitHub action duplicates that folder-naming code, which is unfortunate.
28
+ The instance of the `Log` saves the name in `runtime_config.json`. That instance of `Log` and other ALKiln code uses that name to create and store files in that artifacts folder.
30
29
 
31
- At the same time, tests that run in ALKilnInThePlayground don't have GitHub to manage the artifact folder name. It only uses the `run_cucumber` script, not any of the others...
30
+ The artifact folder name generation code is in 2 places - the GitHub action and ALKiln's core code[^1]. In future, we may be able to reduce that to just one location - the core code.
32
31
 
33
- Adding to that confusion, when people (like internal ALKiln developers) run tests from their command line, they do use the `setup` script once at first, but then run test suites repeatedly...
32
+ Below are more detailed descriptions of how each environment interacts with the folder name. Where the folder name is created, gets passed, gets saved, and gets used. These descriptions still gloss over many details.
34
33
 
35
- Neither of the last 2 can depend on the `runtime_config.json` folder name that `setup` creates. If they did, all their multiple test runs would save to that first folder. Since both those environments use `run_cucumber.js` alone repeatedly, and since we don't want to duplicate folder-naming behavior between even more scripts, we decided that those non-GitHub environments should be able to let `Log` create a folder name from scratch every time. The `Log` constructor has to be able to accept a `path` argument with a folder name and also to accept an undefined `path` argument.
36
- -->
34
+ The diagrams highlight `Log` to help visualize a common point in all the flows.
37
35
 
38
- A future goal is to remove the need to store the name in the runtime configuration file to reduce that complexity a bit. These flows are up for discussion.
39
36
 
40
- Below are more detailed descriptions of the different paths the folder name takes in the different environments. Where the folder name is created, gets passed, gets saved, and gets used. Note that there's a little glossing over the details. For example, everything saves to `runtime_config.json`, but only the core code[^1] ever uses the value there.
37
+ ### Shared behavior
38
+
39
+ For each environment, the start and end of how they manage the artifacts folder name is different. In the middle, though - once the artifacts folder name is already stored in the `runtime_config` file - the flow is the same.
40
+
41
+ Npm commands that come in the middle have this flow to save logs:
42
+
43
+ ```mermaid
44
+ flowchart LR
45
+
46
+ environment --triggers--> commands["middle</br>commands"]
47
+ commands --trigger--> scripts["package</br>code"]
48
+ scripts --make--> log2["#96;Log#96;"]:::log
49
+ log2 --"gets name</br>from"--> runtime2["runtime config</br>file"]
50
+ log2 --"adds to"--> folder2[folder</br>& files]
51
+
52
+ classDef log fill:#d6fd88,stroke:#000,stroke-width:2px,color:#000
53
+ ```
54
+
55
+ The core code also needs to use the artifacts folder name in order to save both logs and other artifacts:
56
+
57
+ ```mermaid
58
+ flowchart LR
59
+
60
+ core["core</br>code"] --"makes"--> log4["#96;Log#96;"]:::log
61
+ core --"adds to"--> folder3[folder</br>& files]
62
+ core --"gets name</br>from"--> runtime3["runtime config</br>file"]
63
+ log4 --"gets name</br>from"--> runtime3
64
+ log4 --"adds to"--> folder3
65
+
66
+ classDef log fill:#d6fd88,stroke:#000,stroke-width:2px,color:#000
67
+ ```
68
+
69
+ Those are the shared flows. Each environment, though, has its own way to store the name at the start and each environment has its own way to give the author the final artifacts.
41
70
 
42
- The diagrams highlight `Log` to help visualize a common point in all the flows.
43
71
 
44
72
  ### GitHub action
45
73
 
46
- 1. GitHub action creates a new folder name, passes that name to `setup`, which passes that name to `Log`, which creates the artifacts folder and saves the name in `runtime_config.json`. The setup `Log` uses the name to store logs in the folder. The setup uses its `Log`.
47
- 2. GitHub action uses the same folder name, passes that same name to `run_cucumber`, which passes that same name to `Log`. The `runtime_cucumber` process uses that `Log`. The `run_cucumber` process also triggers the core code, which uses the folder name in `runtime_config.json` to create its own `Log`. The core code also uses that name to store other artifact files in the folder.
48
- 3. GitHub action creates the folder name, passes that same name to `takedown`, which passes that same name when instantiating its `Log`. The takedown `Log` uses the name to store logs in the folder.
74
+ The GitHub action starts off with an empty `runtime_config` file. The action creates a new folder name and passes that name to the `artifacts` script, which passes that name to a `Log`. The `Log` creates the artifacts folder and saves the name in `runtime_config.json`.
49
75
 
50
76
  ```mermaid
51
- %% "pass name too" has 2 o's at the end because mermaid makes one of them disappear
77
+ flowchart LR
78
+
79
+ action["GitHub action"] --creates--> name["artifacts</br>folder name"]
80
+ action --"passes</br>name "--> command["'artifacts'</br>command"]
81
+ command --"passes</br>name"--> artifacts["artifacts.js"]
82
+ artifacts --"passes</br>name"--> log1["#96;Log#96;"]:::log
83
+ log1 --"stores name in</br>& uses"--> runtime1["runtime config</br>file"]
84
+ log1 --"creates</br>with name"--> folder1["folder</br>& files"]
85
+ log1 --"adds to"--> folder1
52
86
 
87
+ classDef log fill:#d6fd88,stroke:#000,stroke-width:2px,color:#000
88
+ ```
89
+
90
+ Then other processes use the name from the config to store logs and other files in the artifacts folder (as we've already shown).
91
+
92
+ Finally, the action uses the name in the action context to download the artifacts folder so the user can have access to it after the action is done.
93
+
94
+ ```mermaid
53
95
  flowchart LR
54
- action[action part 1] --create/pass name too--> setup
55
- setup["setup"] --pass name too--> log1["#96;Log#96;"]:::log
56
- log1 --store name in/ignore--> runtime1["runtime config file"]
57
- log1 --create with name--> folder1[folder]
58
-
59
- action2[action part 2] --pass name too--> run["run"]
60
- run --pass name too--> log2["#96;Log#96;"]:::log
61
- log2 --store name in/ignore--> runtime2["runtime config file"]
62
- log2 --use with name--> folder2[folder]
63
- run --> core["core code"]
64
- core --pass name too--> log3["#96;Log#96;"]:::log
65
- core --use with name--> folder2
66
- core --get name from--> runtime2
67
- log3 --use with name--> folder2
68
- log3 --store name in/ignore--> runtime2
69
-
70
- action3[action part 3] --pass name too--> takedown["takedown"]
71
- takedown --pass name too--> log4["#96;Log#96;"]:::log
72
- log4 --store name in/ignore--> runtime3["runtime config file"]
73
- log4 --create with name--> folder5[folder]
96
+
97
+ action["GitHub action"] --previously created--> name["artifacts folder name"]
98
+ action --uses name to get--> folder["folder & files"]
74
99
 
75
100
  classDef log fill:#d6fd88,stroke:#000,stroke-width:2px,color:#000
76
101
  ```
77
102
 
103
+
78
104
  ### ALKilnInThePlayground
79
105
 
80
- 1. ALKilnInThePlayground triggers `run_cucumber` without a folder name which triggers `Log` without a folder name. `Log` creates a new folder name and saves it in `runtime_config.json`. It also creates the artifacts folder. The `run_cucumber` process also triggers the core code, which uses the folder name in `runtime_config.json` to create its own `Log`. The core code also uses that name to store other artifact files in the folder.
106
+ _Note: This should be implemented by the time anyone actually reads this. Here's hoping._
107
+
108
+ ALKilnInThePlayground starts off with an empty `runtime_config` file. ALKilnInThePlayground triggers the `artifacts` command, but without a folder name. The code still creates a `Log` (also without a folder name). The `Log` itself creates the name.
81
109
 
82
110
  ```mermaid
83
111
  flowchart LR
84
- ALKilnInThePlayground --> run["run"]
85
- run --> log2["#96;Log#96;"]:::log
86
- log2 --store name in/ignore--> runtime2["runtime config file"]
87
- log2 --create with name--> folder2[folder]
88
- run --> core["core code"]
89
- core --> log3["#96;Log#96;"]:::log
90
- core --use with name--> folder2
91
- core --get name from--> runtime2
92
- log3 --use with name--> folder2
93
- log3 --store name in/ignore--> runtime2
112
+
113
+ ALKilnInThePlayground --> command["'artifacts'</br>command"]
114
+ command --> artifacts["artifacts.js"]
115
+ artifacts --> log1["#96;Log#96;"]:::log
116
+ log1 --creates--> name["artifacts</br>folder name"]
117
+ log1 --stores name--> runtime1["runtime config file"]
118
+ log1 --"gets name</br>from"--> runtime1["runtime config</br>file"]
119
+ log1 --creates</br>with name--> folder1["folder</br>& files"]
94
120
 
95
121
  classDef log fill:#d6fd88,stroke:#000,stroke-width:2px,color:#000
96
122
  ```
97
123
 
124
+ Then other processes use the name from the config to store logs and other files in the artifacts folder (as we've already shown).
125
+
126
+ Finally, ALKilnInThePlayground itself uses the runtime config file to get the name so it can give the artifacts to the user.
127
+
128
+ ```mermaid
129
+ flowchart LR
130
+
131
+ ALKilnInThePlayground --"gets name from"--> runtime1["runtime config file"]
132
+ ALKilnInThePlayground --"uses name to get"--> folder["folder & files"]
133
+
134
+ classDef log fill:#d6fd88,stroke:#000,stroke-width:2px,color:#000
135
+ ```
136
+
137
+
98
138
  ### Command line
99
139
 
100
- 1. The developer uses the command line to trigger setup without a folder name which triggers `Log` without a folder name. `Log` creates a name and creates the artifacts folder, then stores files in that folder.
101
- 2. The developer uses the command line to trigger `run_cucumber` without a folder name which triggers `Log` without a folder name. `Log` creates and saves a new folder name in `runtime_config.json`, and creates the artifacts folder. The `run_cucumber` process also triggers the core code, which uses the folder name in `runtime_config.json` to create its own `Log`. The core code also uses that name to store other artifact files in the folder.
102
- 3. The developer uses the command line to trigger `takedown` without a folder name which triggers `Log` without a folder name. `Log` creates a name and the artifacts folder, then stores files in that folder.
140
+ The command line flow is similar to ALKilnInThePlayground, but has to deal with a pre-existing runtime config file[^2]. The command line flow overwrites the artifacts folder name on each run.
141
+
142
+ An internal developer uses the command line to trigger the `artifacts` command, but without a folder name. The code still creates a `Log` (also without a folder name). The `Log` itself creates a name and overwrites the current name in the runtime config file.
103
143
 
104
144
  ```mermaid
105
145
  flowchart LR
106
- cmd1[command line] --> setup
107
- setup["setup"] --> log1["#96;Log#96;"]:::log
108
- log1 --store name in/ignore--> runtime1["runtime config file"]
109
- log1 --create with/use with name--> folder1[folder]
110
-
111
- cmd2[command line] --> run["run"]
112
- run --> log2["#96;Log#96;"]:::log
113
- log2 --store name in/ignore--> runtime2["runtime config file"]
114
- log2 --create with name--> folder2[folder]
115
- run --> core["core code"]
116
- core --> log3["#96;Log#96;"]:::log
117
- core --use with name--> folder2
118
- core --get name from--> runtime2
119
- log3 --use with name--> folder2
120
- log3 --store name in/ignore--> runtime2
121
-
122
- cmd3[command line] --> takedown["takedown"]
123
- takedown --> log4["#96;Log#96;"]:::log
124
- log4 --store name in/ignore--> runtime3["runtime config file"]
125
- log4 --create with name--> folder5[folder]
146
+
147
+ dev --> command["'artifacts'</br>command"]
148
+ command --> artifacts["artifacts.js"]
149
+ artifacts --> log1["#96;Log#96;"]:::log
150
+ log1 --creates--> name["artifacts</br>folder name"]
151
+ log1 --"overwrites</br>previous name"--> runtime1["runtime config file"]
152
+ log1 --"gets name</br>from"--> runtime1["runtime config</br>file"]
153
+ log1 --creates</br>with name--> folder1["folder</br>& files"]
126
154
 
127
155
  classDef log fill:#d6fd88,stroke:#000,stroke-width:2px,color:#000
128
156
  ```
129
157
 
158
+ Then other processes use the name from the config to store logs and other files in the artifacts folder (as we've already shown).
159
+
160
+ ALKiln stores the artifacts folder in the root of the local repository folder. The developer has direct access to the file system and can see every new artifacts folder. In fact, they can also see any previous artifacts folders. We avoid adding those artifacts folders to the repo by including the folder name pattern in the `.gitignore` and `.npmignore` files.
161
+
162
+ ```mermaid
163
+ flowchart LR
164
+
165
+ git --🙈--> folder["folders & files"]
166
+ dev --👁️--> folder
167
+ npm --🙉--> folder
168
+
169
+ classDef log fill:#d6fd88,stroke:#000,stroke-width:2px,color:#000
170
+ ```
171
+
172
+
130
173
  ## Alternatives considered
131
174
 
132
- - One script for creating the artifacts folder name: Make a script that saves the folder name to the ALKiln `runtime_config.json`. Then all the other code, including instances of `Log`, would always use `runtime_config.json`. We would want `package.json` scripts for the command line environment that would include getting the name of the folder. That potentially complicates the code and process for internal development. We will see how our current design behaves first.
133
- - Use `Log`'s path name instead of the one in `runtime_config.json`. We thought we would want to save in previous artifacts folders, but it now seems potentially unnecessary. This seems the most viable option for the future, but it is unclear how we can integrate `Log` with all the other files. I wouldn't consider PDFs and screenshots to be logs.
175
+ - Each originator (GitHub, ALKilnInThePlayground, the dev) could always create the name from the outside. This would duplicate work, but would give more fine-grained control.
176
+ - Have `Log` make a different folder name each time and, at the very end, combine the contents of those folders into one folder. Hey, all ideas are welcome here.
177
+
178
+ For name creation:
179
+
180
+ - Avoid GitHub actions creating names. That is, create names only in `artifacts.js` and pass that out again. Needs research.
181
+
134
182
 
135
183
  [^1]: **Core framework code/core code:** the code that implements the Steps in the `.feature` test files.
184
+
185
+ [^2] Keeping the `runtime_config` file around helps greatly improves the local development experience. You can read more in the document that talks about the 4 environments ALKiln supports.