@suffolklitlab/alkiln 5.10.4 β†’ 5.11.1

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.
@@ -45,85 +45,86 @@ runs:
45
45
  using: "composite"
46
46
  steps:
47
47
  # Place the root directory in this branch
48
- - uses: actions/checkout@v3
48
+ - uses: actions/checkout@v4
49
49
 
50
- - name: "ALKiln GitHub server - Set environment variables"
50
+ - shell: bash
51
51
  env:
52
52
  MAX_SECONDS_FOR_DOCKER: ${{ inputs.MAX_SECONDS_FOR_DOCKER }}
53
53
  DOCASSEMBLECLI_VERSION: ${{ inputs.DOCASSEMBLECLI_VERSION }}
54
54
  run: |
55
- # ALKiln GitHub server info: Set environment variables
55
+ # πŸ’‘ALK0001 INFO: Set environment variables
56
56
  echo "MAX_SECONDS_FOR_DOCKER=$MAX_SECONDS_FOR_DOCKER" >> $GITHUB_ENV
57
57
  echo "DOCASSEMBLECLI_VERSION=$DOCASSEMBLECLI_VERSION" >> $GITHUB_ENV
58
58
  echo "DA_ADMIN_API_KEY=abcd1234abcd1234abcd5678abdc5678" >> $GITHUB_ENV
59
59
  echo "DA_ADMIN_EMAIL=admin@example.com" >> $GITHUB_ENV
60
60
  # Login will fail if this value is "password"
61
61
  echo "DA_ADMIN_PASSWORD=@123abcdefg" >> $GITHUB_ENV
62
+ - name: "πŸ’‘ ALK0002 INFO: Prepare GitHub step output variables"
63
+ id: api_key_output_step
62
64
  shell: bash
63
- - id: api_key_output_step
64
65
  run: |
66
+ # πŸ’‘ ALK0002 INFO: Create GitHub step output variables
65
67
  echo "DOCASSEMBLE_DEVELOPER_API_KEY=$DA_ADMIN_API_KEY" >> "$GITHUB_OUTPUT"
66
68
  echo "DA_ADMIN_EMAIL=$DA_ADMIN_EMAIL" >> "$GITHUB_OUTPUT"
67
69
  echo "DA_ADMIN_PASSWORD=$DA_ADMIN_PASSWORD" >> "$GITHUB_OUTPUT"
68
- shell: bash
69
70
 
70
- - name: "ALKiln GitHub server - Get config"
71
+ - name: "πŸ’‘ ALK0003 INFO: Get config"
71
72
  env:
72
73
  CONFIG: ${{ inputs.CONFIG_CONTENTS }}
74
+ shell: bash
73
75
  run: |
74
- # ALKiln GitHub server info: config values
76
+ # πŸ’‘ ALK0003 INFO: Get config
75
77
  mkdir /tmp/config
76
78
  # Worth making this silent by defining a variable with > /dev/null...?
77
79
  if [ -n "$CONFIG" ]
78
80
  then
79
- echo "ALKiln GitHub server - The developer did provide a custom docassemble config file as an input into this action."
81
+ echo "πŸ’‘ ALK0004 INFO: The developer did provide a custom docassemble config file as an input into this action."
80
82
  echo "$CONFIG" > /tmp/config/myconfig.yml
81
83
  echo "CONFIG_ARGS=--env DA_CONFIG=/tmp/config/myconfig.yml --volume /tmp/config:/tmp/config " >> $GITHUB_ENV
82
84
  else
83
- echo "ALKiln GitHub server - The developer did NOT provide a custom docassemble config file as an input into this action. Docassemble will use its default config."
85
+ echo "πŸ’‘ ALK0005 INFO: The developer did NOT provide a custom docassemble config file as an input into this action. Docassemble will use its default config."
84
86
  echo "CONFIG_ARGS=" >> $GITHUB_ENV
85
87
  fi
86
- shell: bash
87
88
 
88
89
  # Question: If in future we allow GitHub variables instead of just secrets,
89
90
  # should we let those be visible or prevent them along with the docker logs?
90
91
  # Also, does GitHub hide job environment output of secrets as well as
91
92
  # hiding the secrets' output from the job console?
92
93
 
93
- # Define the var to prevent/show docker output
94
- # TODO: Why are we only doing this for manually triggered workflows?
95
- - name: Env var for showing docker output
94
+ # Define the var to prevent/show docker output based on action input
95
+ - name: "πŸ’‘ ALK0006 INFO: Determine docker logs visibility"
96
96
  env:
97
97
  SHOW_DOCKER_OUTPUT: ${{ inputs.SHOW_DOCKER_OUTPUT }}
98
+ shell: bash
98
99
  run: |
99
- # ALKiln GitHub server info: Docker logs visibility decision
100
+ # πŸ’‘ ALK0006 INFO: Determine docker logs visibility
100
101
  if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
101
102
  echo "OUTPUT_DOCKER=$SHOW_DOCKER_OUTPUT" >> $GITHUB_ENV
102
103
  else
103
104
  echo "OUTPUT_DOCKER=false" >> $GITHUB_ENV
104
105
  fi
105
- shell: bash
106
106
 
107
107
  # Messages about output
108
- - if: ${{ env.OUTPUT_DOCKER == 'false' }}
109
- run: |
110
- # ALKiln GitHub server info: no output
111
- printf '===\nALKiln GitHub server - GitHub will now stop showing output to avoid possibly showing details about your config. If you want to get output to see more of what is going on, use "with:" and set the input "SHOW_DOCKER_OUTPUT" to "true". This output will only be visible to those who can already see the action output, like people with admin or write permissions.\n==='
108
+ - name: "πŸ’‘ ALK0007 INFO: ALKiln will now hide docker output"
109
+ if: ${{ env.OUTPUT_DOCKER == 'false' }}
112
110
  shell: bash
113
- - if: ${{ env.OUTPUT_DOCKER == 'true' }}
114
111
  run: |
115
- # ALKiln GitHub server info: show output
116
- printf '===\nALKiln GitHub server - GitHub will now show the output of docker creation. ALKiln cannot control this output. If you want to prevent output, use "with:" and set the input "SHOW_DOCKER_OUTPUT" to "false". This output will only be visible to those who can already see the action output, like people with admin or write permissions.\n==='
112
+ echo '===\nπŸ’‘ ALK0007 INFO: ALKiln will now hide docker output to avoid possibly showing details about your config. If you want to get output to see more of what is going on, use "with:" and set the input "SHOW_DOCKER_OUTPUT" to "true". This output will only be visible to those who can already see the action output, like people with admin or write permissions.\n==='
113
+ - name: "πŸ’‘ ALK0008 INFO: ALKiln will show docker output"
114
+ if: ${{ env.OUTPUT_DOCKER == 'true' }}
117
115
  shell: bash
116
+ run: |
117
+ echo '===\nπŸ’‘ ALK0008 INFO: ALKiln will show docker output. ALKiln cannot control this output. If you want to prevent output, use "with:" and set the input "SHOW_DOCKER_OUTPUT" to "false". This output will only be visible to those who can already see the action output, like people with admin or write permissions.\n==='
118
118
 
119
119
  # TODO: Reduce these to 1 block by putting ` > /dev/null 2>&1` into an env var
120
- # No output
121
- - name: "ALKiln GitHub server - Download and start docker silently"
120
+ # No docker output
121
+ - name: "πŸ’‘ ALK0009 INFO: Download and start docker silently"
122
122
  if: ${{ env.OUTPUT_DOCKER == 'false' }}
123
123
  env:
124
124
  CONFIG_ARGS: ${{ env.CONFIG_ARGS }}
125
+ shell: bash
125
126
  run: |
126
- # ALKiln GitHub server info: Silent docker pull/run
127
+ # πŸ’‘ ALK0009 INFO: Download and start docker silently
127
128
  docker pull jhpyle/docassemble > /dev/null 2>&1
128
129
  docker run --name docassemble_container \
129
130
  --env DA_ADMIN_EMAIL="$DA_ADMIN_EMAIL" \
@@ -132,14 +133,14 @@ runs:
132
133
  $CONFIG_ARGS \
133
134
  --cap-add SYS_PTRACE \
134
135
  --memory="4gb" -d -p 80:80 jhpyle/docassemble > /dev/null 2>&1
135
- shell: bash
136
136
  # With output
137
- - name: "ALKiln GitHub server - Download and start docker"
137
+ - name: "πŸ’‘ ALK0010 INFO: Download and start docker"
138
138
  if: ${{ env.OUTPUT_DOCKER == 'true' }}
139
139
  env:
140
140
  CONFIG_ARGS: ${{ env.CONFIG_ARGS }}
141
+ shell: bash
141
142
  run: |
142
- # ALKiln GitHub server info: Docker pull/run
143
+ # πŸ’‘ ALK0010 INFO: Download and start docker
143
144
  docker pull jhpyle/docassemble
144
145
  docker run --name docassemble_container \
145
146
  --env DA_ADMIN_EMAIL="$DA_ADMIN_EMAIL" \
@@ -148,18 +149,19 @@ runs:
148
149
  $CONFIG_ARGS \
149
150
  --cap-add SYS_PTRACE \
150
151
  --memory="4gb" -d -p 80:80 jhpyle/docassemble
151
- shell: bash
152
152
 
153
- # Show the time it takes to start the server.
154
- - if: ${{ env.OUTPUT_DOCKER == 'false' }}
155
- run: |
156
- # ALKiln GitHub server info: temporary visible logs
157
- echo "ALKiln GitHub server - ALKiln will show safe ALKiln-only output temporarily as ALKiln waits for the server to start"
153
+ # Section for showing the time it takes to start the server.
154
+
155
+ - name: "πŸ’‘ ALK0011 INFO: The following messages are not docker output"
156
+ if: ${{ env.OUTPUT_DOCKER == 'false' }}
158
157
  shell: bash
158
+ run: |
159
+ echo "πŸ’‘ ALK0011 INFO: The following messages are not docker output, just ALKiln waiting for the server to start"
159
160
 
160
- - name: "ALKiln GitHub server - Wait for server to start"
161
+ - name: "πŸ’‘ ALK0012 INFO: Waiting for server to start"
162
+ shell: bash
161
163
  run: |
162
- # ALKiln GitHub server - Wait for server to start
164
+ # πŸ’‘ ALK0012 INFO: Waiting for server to start
163
165
 
164
166
  # Reset the SECONDS variable
165
167
  SECONDS=0
@@ -168,39 +170,30 @@ runs:
168
170
 
169
171
  response="start"
170
172
  while [[ $response != *"200"* ]]; do
171
- echo "ALKiln GitHub server - Time elapsed: $SECONDS seconds"
173
+ echo "πŸ’‘ ALK0013 INFO: Time elapsed: $SECONDS seconds"
172
174
 
173
175
  # Check if max seconds till loading has passed
174
176
  if [[ $SECONDS -ge $MAX_SECONDS_FOR_DOCKER ]]; then
175
- echo "ALKiln GitHub server Error: Timed out waiting for docker container to serve the site. If you want to give your docker container more timem to install, set the MAX_SECONDS_FOR_DOCKER input for this action."
177
+ echo "πŸ€• ALK0014 ERROR: Timed out waiting for docker container to serve the site. If you want to give your docker container more timem to install, set the MAX_SECONDS_FOR_DOCKER input for this action."
176
178
  exit 1
177
179
  fi
178
180
 
179
181
  # Set the variable to a new string value in each iteration
180
182
  response=$(curl -o /dev/null -s -w "%{http_code}\n" http://localhost:80/health_check?ready=1)
181
- echo "ALKiln GitHub server - response is $response"
183
+ echo "πŸ’‘ ALK0015 INFO: Response is $response"
182
184
 
183
185
  # Check if the string includes the desired text
184
186
  if [[ $response == *"200"* ]]; then
185
- echo "ALKiln GitHub server - Success! The docker container is ready!"
187
+ echo "🌈 ALK0016 SUCCESS: Success! The docker container is ready!"
186
188
  else
187
- echo "ALKiln GitHub server - The docker container is not ready yet. Will check again in 30 seconds."
189
+ echo "πŸ’‘ ALK0017 INFO: The docker container is not ready yet. Will check again in 30 seconds."
188
190
  sleep 30
189
191
  fi
190
192
 
191
193
  done
192
- shell: bash
193
-
194
- # Output visibility message
195
- - name: Message about docassemble install output
196
- if: ${{ env.OUTPUT_DOCKER == 'false' }}
197
- run: |
198
- # ALKiln GitHub server info: Silent install message
199
- echo "ALKiln GitHub server - ALKiln will now prevent output again"
200
- shell: bash
201
194
 
202
195
  # Don't rely on the environment's version of python
203
- - uses: actions/setup-python@v4
196
+ - uses: actions/setup-python@v5
204
197
  with:
205
198
  python-version: '3.10'
206
199
  # No output
@@ -223,32 +216,33 @@ runs:
223
216
 
224
217
  # Upload artifacts that devs can download on the Actions summary page
225
218
  # Only if the developer wants to get that info, though
226
- - name: "ALKiln GitHub server - Get path names with date and time"
219
+ - name: "πŸ’‘ ALK0018 INFO: Get path names with date and time"
227
220
  if: ${{ always() && env.OUTPUT_DOCKER == 'true' }}
221
+ shell: bash
228
222
  run: |
223
+ # πŸ’‘ ALK0018 INFO: Get path names with date and time
229
224
  echo "GITHUB_SERVER_LOG_FILE_NAME=/tmp/alkiln_docker_logs-$(date +'%Y-%m-%d at %Hh%Mm%Ss' -u)UTC.txt" >> $GITHUB_ENV
230
225
  echo "GITHUB_SERVER_ARTIFACT_NAME=alkiln_github_server-$(date +'%Y-%m-%d at %Hh%Mm%Ss' -u)UTC" >> $GITHUB_ENV
231
- shell: bash
232
- - name: "ALKiln GitHub server - Docker output"
226
+ - name: "πŸ’‘ ALK0019 INFO: Create docker artifact data"
233
227
  if: ${{ always() && env.OUTPUT_DOCKER == 'true' }}
228
+ shell: bash
234
229
  run: |
230
+ # πŸ’‘ ALK0019 INFO: Create docker artifact data
235
231
  echo "$(docker output docassemble_container)" > "${{ env.GITHUB_SERVER_LOG_FILE_NAME }}"
236
- shell: bash
237
- - name: "ALKiln GitHub server - Upload artifacts folder"
232
+ - name: "πŸ’‘ ALK0020 INFO: Upload artifacts folder"
238
233
  if: ${{ always() && env.OUTPUT_DOCKER == 'true' }}
239
- uses: actions/upload-artifact@v3
234
+ uses: actions/upload-artifact@v4
240
235
  with:
241
236
  name: ${{ env.GITHUB_SERVER_ARTIFACT_NAME }}
242
237
  path: ${{ env.GITHUB_SERVER_LOG_FILE_NAME }}
243
238
 
244
- - run: |
245
- # ALKiln GitHub server info: End silent output
246
- echo "ALKiln GitHub server - ALKiln will show output again"
247
- if: ${{ always() && env.OUTPUT_DOCKER == 'false' }}
248
- shell: bash
239
+ - shell: bash
240
+ if: ${{ success() }}
241
+ run: |
242
+ echo "🌈 ALK0021 SUCCESS: ALKiln created the docker container and started the server!"
243
+
244
+ - shell: bash
245
+ if: ${{ failure() }}
246
+ run: |
247
+ echo "πŸ€• ALK0022 ERROR: Something went wrong. See above for more details."
249
248
 
250
- - run: |
251
- # ALKiln GitHub server info: Done
252
- echo "ALKiln GitHub server - ALKiln will show output again"
253
- if: ${{ always() && env.OUTPUT_DOCKER == 'false' }}
254
- shell: bash
@@ -2,6 +2,7 @@
2
2
  module.exports = async function wrapPromiseWithTimeout (
3
3
  promise,
4
4
  timeoutInMilliseconds,
5
+ // TODO: Turn this into a function
5
6
  timeoutMessage=''
6
7
  ) {
7
8
  /** Race between a timeout and another function and clean up
@@ -10,7 +11,7 @@ module.exports = async function wrapPromiseWithTimeout (
10
11
  * Taken from https://github.com/cucumber/cucumber-js/blob/main/src/time.ts#L42-L59
11
12
  */
12
13
  if ( timeoutMessage === '' ) {
13
- timeoutMessage = `Action did not complete within ${ timeoutInMilliseconds } milliseconds`;
14
+ timeoutMessage = `πŸ€• ALK0174 ERROR: Action did not complete within ${ timeoutInMilliseconds } milliseconds`;
14
15
  }
15
16
 
16
17
  let timeoutId;
@@ -63,7 +63,7 @@ da.__delete_projects_starting_with = async function ( base_name, starting_num=1,
63
63
  while ( name_incrementor <= final_num ) {
64
64
  try {
65
65
  let project_name = base_name + name_incrementor;
66
- console.log( `Deleting Project ${ project_name }` );
66
+ console.log( `🐞 ALKiln internal debug 1: Deleting Project ${ project_name }` );
67
67
 
68
68
  let options = {
69
69
  method: 'DELETE',
@@ -78,7 +78,7 @@ da.__delete_projects_starting_with = async function ( base_name, starting_num=1,
78
78
  await axios.request( options );
79
79
  } catch ( error ) {
80
80
  let response = error.response || {data: null}
81
- console.log( {...error.toJSON(), data: response.data});
81
+ console.log({...error.toJSON(), data: response.data, alkiln_code: `🐞 ALKiln internal debug 2`});
82
82
  }
83
83
  name_incrementor++;
84
84
  }
@@ -89,7 +89,7 @@ da_i.throw_an_error_if_server_is_not_responding = async function ( options ) {
89
89
 
90
90
  // Defaults
91
91
  let { timeout } = options || { timeout: DEFAULT_MAX_REQUEST_MS };
92
- log.info({ pre: `Waiting for the docassemble server to respond. Will wait for ${ timeout/1000 } seconds at most.` });
92
+ log.info({ type: `da api`, code: `ALK0166`, pre: `Waiting for the docassemble server to respond. Will wait for ${ timeout/1000 } seconds at most.` });
93
93
 
94
94
  try {
95
95
  let start_time = Date.now()
@@ -97,7 +97,7 @@ da_i.throw_an_error_if_server_is_not_responding = async function ( options ) {
97
97
  let response = await _da_REST.get_dev_id( timeout );
98
98
  let end_time = Date.now()
99
99
  if ( response && response.data && response.data.id ) {
100
- log.info({ pre: `The docassemble server responded after ${ (end_time - start_time)/1000 } seconds.` });
100
+ log.info({ type: `da api`, code: `ALK0167`, pre: `The docassemble server responded after ${ (end_time - start_time)/1000 } seconds.` });
101
101
  return false;
102
102
  }
103
103
 
@@ -106,13 +106,16 @@ da_i.throw_an_error_if_server_is_not_responding = async function ( options ) {
106
106
  if ( is_timeout_error( error ) ) {
107
107
  // Anything that's waiting for the server to not be busy does not want
108
108
  // to move forward without a free server.
109
- log.info({ pre: `The docassemble server was still busy after ${ timeout/1000 } seconds.` });
109
+ log.info({ type: `da api`, code: `ALK0168`, pre: `The docassemble server was still busy after ${ timeout/1000 } seconds.` });
110
110
  } else {
111
111
  // Not sure what to do for other errors. It could be a server
112
112
  // error, like an 'Access Denied' error, which should be handled.
113
113
  log.error({
114
+ type: `da api`,
115
+ code: `ALK0169`,
114
116
  pre: `Tried to check if the docassemble server was busy, but `
115
- + `ran into an unexpected error. The error didn't indicate a busy server, though.`
117
+ + `ran into an unexpected error. The error didn't indicate a busy server, though. Error message:\n`
118
+ + error
116
119
  });
117
120
  }
118
121
 
@@ -180,14 +183,15 @@ da_i.delete_project = async function ( delete_options ) {
180
183
  let { timeout } = delete_options || { timeout: DEFAULT_MAX_REQUEST_MS };
181
184
 
182
185
  let project_name = session_vars.get_project_name()
183
- log.info({ pre: `Trying to delete Project ${ project_name }` });
186
+ log.info({ type: `da api`, code: `ALK0170`, pre: `Trying to delete Project ${ project_name }` });
184
187
 
185
188
  try {
186
189
  let response = await _da_REST.delete_project( timeout );
187
- log.info({ pre: `Deleted Project "${ project_name }"` });
190
+ log.info({ type: `da api`, code: `ALK0171`, pre: `Deleted Project "${ project_name }"` });
188
191
  } catch ( error ) {
189
- log.error({ pre: `Ran into an error when deleting Project "${ project_name }"` });
190
- log.debug({ pre: `See https://docassemble.org/docs/api.html#playground_delete_project.` });
192
+ let msg = `Ran into an error when deleting Project "${ project_name }". See https://docassemble.org/docs/api.html#playground_delete_project.`
193
+ log.error({ type: `da api`, code: `ALK0172`, pre: msg });
194
+ log.debug({ type: `da api`, code: `ALK0173`, pre: msg });
191
195
  throw error;
192
196
  }
193
197
 
@@ -23,14 +23,15 @@ const server_install = async () => {
23
23
  // Get names of all folders in repo "docassemble" folder
24
24
  let chosen_folder = folders[0];
25
25
  if ( folders.length === 0 ) {
26
- let msg = `There are 0 folders at ${path}. Tests won't run.`;
27
- log.error({ type: `setup`, data: msg })
26
+ let msg = `There are 0 folders at ${path}. Stopping tests.`;
27
+ log.error({ type: `setup`, code: `ALK0044`, data: msg })
28
28
  throw new ReferenceError( msg );
29
29
  }
30
30
 
31
31
  if ( folders.length > 1 ) {
32
32
  log.warn({
33
33
  type: `setup`,
34
+ code: `ALK0045`,
34
35
  data: `There are ${folders.length} folders at ${path}: "${folders.join('", "')}". ALKiln chose to use the folder "${chosen_folder}".`
35
36
  })
36
37
  }
@@ -18,7 +18,7 @@ const setup = async () => {
18
18
  let project_name = session_vars.get_project_base_name().replace(/[^A-Za-z0-9]/g, '') + `${Date.now()}`;
19
19
  session_vars.save_project_name( project_name );
20
20
 
21
- log.info({ type: `setup`, pre: `Starting to upload this package to `
21
+ log.info({ type: `setup`, code: `ALK0046`, pre: `Starting to upload this package to `
22
22
  + `a new Project called ${project_name} in the Playground `
23
23
  + `of your server's testing account. It may take a couple of minutes.` });
24
24
 
@@ -43,14 +43,16 @@ const setup = async () => {
43
43
  if ( result.status !== 0 ) {
44
44
  log.error({
45
45
  type: `setup`,
46
+ code: `ALK0047`,
46
47
  pre: `Status code ${ result.status }. Could not dainstall this package on your server. See above for more details.`
47
48
  });
48
49
  throw(result.stderr);
49
50
  }
50
51
 
51
- log.info({
52
+ log.success({
52
53
  type: `setup`,
53
- pre: `Success! ALKiln created a Project in your Playground named "${ project_name }"`
54
+ code: `ALK0048`,
55
+ pre: `ALKiln created a Project in your Playground named "${ project_name }"!`
54
56
  });
55
57
  }; // Ends setup();
56
58
 
@@ -9,16 +9,16 @@ const takedown = async () => {
9
9
  * DOCASSEMBLE_DEVELOPER_API_KEY secret, delete the
10
10
  * Project created for this test.
11
11
  * For local development, clean up project name file. */
12
- log.info({ type: `takedown`, pre: `Trying to remove the docassemble Project from the testing account.` });
12
+ log.info({ type: `takedown`, code: `ALK0177`, pre: `Trying to remove the docassemble Project from the testing account.` });
13
13
  // Explicit try-catch prevents "Unhandled promise rejection error"
14
14
  // avoids showing confusing node errors to users that they shouldn't have to fix
15
15
  try {
16
16
  await da_i.delete_project();
17
17
  session_vars.delete_project_name();
18
- log.info({ type: `takedown`, pre: `Success! Test takedown has finished successfully.` });
18
+ log.success({ type: `takedown`, code: `ALK0178`, pre: `Test takedown has finished successfully!` });
19
19
  } catch (error) {
20
- log.error({type: `takedown`, pre: `could not delete project`, data: JSON.stringify(error, null, 4)})
21
- // we don't re-throw the exception, so make sure to exit with 1 to let Github Actions know the script failed
20
+ log.error({type: `takedown`, code: `ALK0179`, pre: `Could not delete project`, data: JSON.stringify(error, null, 4)})
21
+ // we don't re-throw the exception, so make sure to exit with 1 to let GitHub Actions know the script failed
22
22
  process.exitCode = 1;
23
23
  }
24
24
  };
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const fs = require('fs');
4
+ const cucumber_api = require('@cucumber/cucumber/api');
5
+
4
6
  const log = require('./utils/log');
5
7
  const session_vars = require('./utils/session_vars');
6
8
 
7
- const cucumber_api = require('@cucumber/cucumber/api');
8
-
9
9
  function build_config( command_args ) {
10
10
  // Turn all the paths to the sources folders into paths to the feature files
11
11
  let sources_paths = session_vars.get_sources_paths();
@@ -51,7 +51,7 @@ function build_config( command_args ) {
51
51
  /** Create the cucumber config, run the tests, create and
52
52
  * manipluate the output. */
53
53
  const environment = { cwd: process.cwd() };
54
- console.log("alkiln-run: environment: %o", environment);
54
+ log.info({ type: `run`, code: `ALK0049`, pre: `environment`, data: environment });
55
55
 
56
56
  // We'll use the user info to construct the possible paths to /sources
57
57
  let id = session_vars.get_user_id();
@@ -79,46 +79,54 @@ function build_config( command_args ) {
79
79
  let one_dir_exists = session_vars.set_sources_paths( sources_list );
80
80
  if ( !one_dir_exists ) {
81
81
  // If we don't throw, it'll be more confusing when no tests run
82
- throw new ReferenceError( `ALKiln ERROR: ALKiln can't find your "sources" folder(s). See above for details.`);
82
+ let msg = `ALKiln can't find your "sources" folder(s). See above for details.`;
83
+ let code = `ALK0050`
84
+ log.error({ type: `run`, code: code, pre: msg });
85
+ throw new ReferenceError(`πŸ€• ${ code } run ERROR: ${ msg }`);
83
86
  }
84
87
 
85
88
  const { runConfiguration } = await cucumber_api.loadConfiguration({
86
89
  provided: build_config( argv ),
87
90
  }, environment);
88
91
 
89
- console.log("alkiln-run: runConfiguration: %o", runConfiguration);
92
+ log.info({ type: `run`, code: `ALK0051`, pre: `runConfiguration`, data: runConfiguration });
90
93
 
91
- var path = require('path');
94
+ var path = require(`path`);
92
95
  var codeDir = path.dirname(require.main.filename);
93
- console.log("alkiln-run: working directory: %o", codeDir);
96
+ log.info({ type: `run`, code: `ALK0052`, pre: `working directory`, data: codeDir });
94
97
  const support = await cucumber_api.loadSupport({ support: {
95
98
  requireModules: [ `${ codeDir }/index.js` ],
96
99
  requirePaths: [ `${ codeDir }/index.js` ],
97
100
  importPaths: [],
98
101
  }, sources: {paths: []}}, environment);
99
102
 
100
- console.log(`\n\n`);
103
+ log.info({ type: `run`, code: `ALK0053`, pre: `working directory`, data: codeDir });
104
+ log.info({ type: `plain`, pre: `\n\n` });
101
105
 
102
106
  const { success } = await cucumber_api.runCucumber({...runConfiguration, support});
103
- console.log("alkiln-run: success: %b", success);
107
+ if ( success ) {
108
+ log.info({ type: `run`, code: `ALK0054`, pre: `Cucumber executed correctly` });
109
+ } else {
110
+ log.error({ type: `run`, code: `ALK0055`, pre: `Cucumber ran into an error` });
111
+ }
104
112
  const exitCode = success ? 0 : 1;
105
113
  process.exitCode = exitCode;
106
114
 
107
115
  // This is hardcoded information from `provide_config` above.
108
116
  // This code isn't used for anything other than detecting and removing color codes.
109
117
  let summary_file_name = 'cucumber-report.txt';
110
- fs.readFile(summary_file_name, 'utf8', (err, data) => {
118
+ fs.readFile(summary_file_name, 'utf8', (err, text) => {
111
119
  if (err) {
112
- console.error(err);
120
+ log.error({ type: `run`, code: `ALK0056`, pre: `cucumber report`, data: err });
113
121
  return;
114
122
  }
115
123
 
116
124
  // Replace terminal color codes, if present
117
125
  // https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#colors--graphics-mode
118
- data = data.replace(/\x1b\[[0-9][0-9]?[0-9]?m/g, '');
126
+ text = text.replace(/\x1b\[[0-9][0-9]?[0-9]?m/g, '');
119
127
 
120
128
  // Put it in the correct file in the correct folder
121
129
  let artifacts_path = session_vars.get_artifacts_path_name();
122
- fs.appendFileSync( `${ artifacts_path }/${ log.debug_log_file }`, data);
130
+ fs.appendFileSync( `${ artifacts_path }/${ log.debug_log_file }`, `\n\n${text}`);
123
131
  });
124
132
  })();