@suffolklitlab/alkiln 5.12.0 → 5.13.0-logs2
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.
- package/.env.example +29 -0
- package/.github/workflows/github_server.yml +59 -12
- package/.github/workflows/playground.yml +11 -4
- package/CHANGELOG.md +41 -1
- package/CONTRIBUTING.md +98 -83
- package/README.md +1 -1
- package/action.yml +69 -29
- package/action_for_github_server/action.yml +65 -31
- package/docs/decisions/006_which_log_level_to_pick_2024_09_5.md +46 -0
- package/docs/decisions/adopt_architectural_decision_records.md +58 -0
- package/docs/decisions/detect_sign_in.md +124 -0
- package/docs/decisions/pdfjs_version_2024_08_08.md +18 -0
- package/docs/decisions/reports_and_logs_2024_08_11.md +141 -0
- package/docs/decisions/update_puppeteer_2024_07_28.md +62 -0
- package/docs/story_tables.md +1 -1
- package/lib/docassemble/docassemble_api_REST.js +67 -1
- package/lib/docassemble/docassemble_api_interface.js +225 -18
- package/lib/docassemble/server_install.js +23 -9
- package/lib/docassemble/setup.js +33 -20
- package/lib/docassemble/takedown.js +27 -7
- package/lib/run_cucumber.js +83 -33
- package/lib/scope.js +222 -82
- package/lib/steps.js +206 -62
- package/lib/utils/files.js +8 -6
- package/lib/utils/log.js +477 -84
- package/lib/utils/reports.js +14 -5
- package/lib/utils/session_vars.js +25 -18
- package/lib/utils/time.js +44 -0
- package/npm-shrinkwrap.json +635 -193
- package/package.json +8 -8
- package/setup.py +1 -1
- package/tests/log_codes/check_codes.sh +163 -108
- package/tests/log_codes/log_code_expected_instances.txt +213 -0
- package/tests/unit_tests/getAllFields.test.js +5 -0
- package/tests/unit_tests/getMatchingRows.test.js +5 -0
- package/tests/unit_tests/log.test.js +20 -0
- package/tests/unit_tests/normalizeTable.test.js +5 -0
- package/tests/log_codes/deleted_codes.json +0 -8
package/lib/run_cucumber.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
|
+
const path = require(`path`);
|
|
4
5
|
const cucumber_api = require('@cucumber/cucumber/api');
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
+
const Log = require('./utils/log');
|
|
7
8
|
const session_vars = require('./utils/session_vars');
|
|
8
9
|
|
|
9
10
|
const SUMMARY_FILENAME = `cucumber-report.txt`;
|
|
10
11
|
|
|
12
|
+
|
|
11
13
|
function build_config( command_args ) {
|
|
12
14
|
// Turn all the paths to the sources folders into paths to the feature files
|
|
13
15
|
let sources_paths = session_vars.get_sources_paths();
|
|
@@ -52,11 +54,14 @@ function build_config( command_args ) {
|
|
|
52
54
|
}; // Ends build_config()
|
|
53
55
|
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
async function main() {
|
|
56
58
|
/** Create the cucumber config, run the tests, create and
|
|
57
59
|
* manipluate the output. */
|
|
60
|
+
|
|
58
61
|
const environment = { cwd: process.cwd() };
|
|
59
|
-
log.info({
|
|
62
|
+
log.info({ code: `ALK0049`, context: `pre_run environment` },
|
|
63
|
+
environment
|
|
64
|
+
);
|
|
60
65
|
|
|
61
66
|
// We'll use the user info to construct the possible paths to /sources
|
|
62
67
|
let id = session_vars.get_user_id();
|
|
@@ -64,8 +69,9 @@ function build_config( command_args ) {
|
|
|
64
69
|
let project = session_vars.get_user_project_name();
|
|
65
70
|
|
|
66
71
|
// process.argv is a list of strings of commands and args.
|
|
67
|
-
// If using `npm run cucumber
|
|
68
|
-
|
|
72
|
+
// If using `npm run cucumber` (as opposed to the bin commands),
|
|
73
|
+
// use `--` before `--sources=./foo`
|
|
74
|
+
const argv = require(`minimist`)( process.argv.slice(2), {
|
|
69
75
|
default: {
|
|
70
76
|
sources: [
|
|
71
77
|
`./docassemble/*/data/sources`, // In GitHub folder
|
|
@@ -84,35 +90,45 @@ function build_config( command_args ) {
|
|
|
84
90
|
let one_dir_exists = session_vars.set_sources_paths( sources_list );
|
|
85
91
|
if ( !one_dir_exists ) {
|
|
86
92
|
// If we don't throw, it'll be more confusing when no tests run
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
log.throw({ code: `ALK0050`, context: `pre_run`,
|
|
94
|
+
error: new ReferenceError(
|
|
95
|
+
`ALKiln can't find your "sources" folder(s). See above for details.`
|
|
96
|
+
),
|
|
97
|
+
});
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
const { runConfiguration } = await cucumber_api.loadConfiguration({
|
|
94
101
|
provided: build_config( argv ),
|
|
95
102
|
}, environment);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
log.info({
|
|
103
|
+
log.info({ code: `ALK0051`, context: `pre_run config`, },
|
|
104
|
+
runConfiguration
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const codeDir = path.dirname(require.main.filename);
|
|
108
|
+
log.info({ code: `ALK0052`, context: `pre_run directory`, },
|
|
109
|
+
codeDir, `\n\n`
|
|
110
|
+
);
|
|
102
111
|
const support = await cucumber_api.loadSupport({ support: {
|
|
103
112
|
requireModules: [ `${ codeDir }/index.js` ],
|
|
104
113
|
requirePaths: [ `${ codeDir }/index.js` ],
|
|
105
114
|
importPaths: [],
|
|
106
115
|
}, sources: {paths: []}}, environment);
|
|
107
116
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
117
|
+
// ====================
|
|
118
|
+
// Run
|
|
119
|
+
// ====================
|
|
111
120
|
const { success } = await cucumber_api.runCucumber({...runConfiguration, support});
|
|
121
|
+
// ====================
|
|
122
|
+
|
|
112
123
|
if ( success ) {
|
|
113
|
-
log.success({
|
|
124
|
+
log.success({ code: `ALK0054`, context: `post_run`, },
|
|
125
|
+
`Tests succeeded!`
|
|
126
|
+
);
|
|
114
127
|
} else {
|
|
115
|
-
|
|
128
|
+
// Don't want to throw error here, so don't pass error object
|
|
129
|
+
log.warn({ code: `ALK0055`, context: `post_run`, },
|
|
130
|
+
`The tests ran into something unexpected. Look above for more details.`
|
|
131
|
+
);
|
|
116
132
|
}
|
|
117
133
|
// Custom exit code. May overlap with other systems.
|
|
118
134
|
// Best info I've found via stack overflow: https://tldp.org/LDP/abs/html/exitcodes.html
|
|
@@ -122,30 +138,64 @@ function build_config( command_args ) {
|
|
|
122
138
|
// This is hardcoded information from `provide_config` above.
|
|
123
139
|
// This code isn't used for anything other than detecting and removing color codes.
|
|
124
140
|
let summary_file_name = SUMMARY_FILENAME;
|
|
125
|
-
fs.readFile(summary_file_name, 'utf8', (
|
|
126
|
-
if (
|
|
127
|
-
|
|
141
|
+
fs.readFile(summary_file_name, 'utf8', (read_error, text) => {
|
|
142
|
+
if ( read_error ) {
|
|
143
|
+
// Something else will probably show an error that's more relevant
|
|
144
|
+
log.warn({ code: `ALK0056`, context: `post_run error`, },
|
|
145
|
+
`Failed to read cucumber report`, read_error
|
|
146
|
+
);
|
|
128
147
|
return;
|
|
129
148
|
}
|
|
130
149
|
|
|
131
150
|
// Replace terminal color codes, if present
|
|
132
151
|
// https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#colors--graphics-mode
|
|
133
152
|
text = text.replace(/\x1b\[[0-9][0-9]?[0-9]?m/g, '');
|
|
134
|
-
|
|
135
|
-
// Put it in the correct file in the correct folder
|
|
136
|
-
let artifacts_path = session_vars.get_artifacts_path_name();
|
|
153
|
+
// Add to the debug file
|
|
137
154
|
try {
|
|
138
|
-
fs.appendFileSync( `${ artifacts_path }/${ log.debug_log_file }`, `\n\n${text}`);
|
|
155
|
+
// fs.appendFileSync( `${ artifacts_path }/${ log.debug_log_file }`, `\n\n${text}`);
|
|
156
|
+
log.debug({ code: `ALK0216`, context: `post_run`, },
|
|
157
|
+
`\n\n`, text
|
|
158
|
+
);
|
|
139
159
|
} catch ( error ) {
|
|
140
|
-
log.
|
|
160
|
+
log.warn({ code: `ALK0182`, context: `post_run error`, },
|
|
161
|
+
`Something probably went wrong earlier. Look above for more details. Problem when writing to ${ log.path }/${ log.debug_log_filename }.`,
|
|
162
|
+
error
|
|
163
|
+
);
|
|
141
164
|
}
|
|
165
|
+
|
|
166
|
+
// Add to the non-passed test output file
|
|
142
167
|
try {
|
|
143
|
-
//
|
|
168
|
+
// Save only non-passing test output to cut out cruft.
|
|
169
|
+
// cucumber only outputs non-success details anyway.
|
|
170
|
+
// Our reports only non-passing tests to this file.
|
|
144
171
|
if ( exitCode === 50 ) {
|
|
145
|
-
fs.appendFileSync( `${
|
|
172
|
+
// fs.appendFileSync( `${ log.path }/${ Log.unexpected_filename }`, `\n\n${ text }` );
|
|
173
|
+
log.unexpected({ text });
|
|
146
174
|
}
|
|
147
|
-
} catch (
|
|
148
|
-
|
|
175
|
+
} catch ( unexpected_file_error ) {
|
|
176
|
+
console.warn(
|
|
177
|
+
`🔎 ALK0181 internal WARNING: Something probably went wrong earlier. Problem when writing to ${ log.path }/${ log.unexpected_filename }`,
|
|
178
|
+
unexpected_file_error
|
|
179
|
+
);
|
|
149
180
|
}
|
|
181
|
+
|
|
182
|
+
return;
|
|
150
183
|
});
|
|
151
|
-
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
// 1. session_vars - make sure all the required env vars exist
|
|
188
|
+
session_vars.validateEnvironment();
|
|
189
|
+
|
|
190
|
+
// 2. Prepare logs
|
|
191
|
+
// process.argv is a list of strings of commands and args.
|
|
192
|
+
// If using `npm run cucumber` (as opposed to the bin commands),
|
|
193
|
+
// use `--` before `--sources=./foo`
|
|
194
|
+
const argv = require(`minimist`)( process.argv.slice(2) );
|
|
195
|
+
// The artifacts folder might be getting created for the first
|
|
196
|
+
// time right here. The tests themselves should avoid creating
|
|
197
|
+
// their own file.
|
|
198
|
+
const log = new Log({ path: argv.path, context: `run` });
|
|
199
|
+
|
|
200
|
+
// 3. run
|
|
201
|
+
main();
|