@suffolklitlab/alkiln 5.0.2-feat-github-server-7 → 5.0.2-feat-github-server-9

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.
@@ -8,10 +8,10 @@ on:
8
8
  tags:
9
9
  required: False
10
10
  description: 'Optional. Use a "tag expression" specify which tagged tests to run (https://cucumber.io/docs/cucumber/api/#tag-expressions)'
11
- # Only test 2 tests - one uses an env var, the other uses AL.
12
- # They test if env vars get set correctly and depencencies get
13
- # pulled in correctly.
14
- default: '@e6 or @al1'
11
+ # # Only test 2 tests - one uses an env var, the other uses AL.
12
+ # # They test if env vars get set correctly and depencencies get
13
+ # # pulled in correctly.
14
+ # default: '@al1'
15
15
  enable_tmate:
16
16
  type: boolean
17
17
  description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
@@ -33,6 +33,7 @@ jobs:
33
33
  SECRET_VAR1: secret-var1-value
34
34
  SECRET_VAR2: secret-var2-value
35
35
  SECRET_FOR_MISSING_FIELD: secret for missing field
36
+ _ALKILN_DANGEROUS_DEBUG: true
36
37
 
37
38
  steps:
38
39
  - uses: actions/checkout@v3
@@ -56,6 +57,7 @@ jobs:
56
57
  SERVER_URL: "${{ steps.github_server.outputs.SERVER_URL }}"
57
58
  DOCASSEMBLE_DEVELOPER_API_KEY: "${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}"
58
59
  INSTALL_METHOD: "server"
59
- ALKILN_VERSION: "5.0.2-feat-github-server-7"
60
+ # TODO: See what happens if this is an empty string
61
+ ALKILN_VERSION: "5.0.2-feat-github-server-9"
60
62
  - run: echo "Finished running ALKiln tests"
61
63
 
package/action.yml CHANGED
@@ -53,7 +53,7 @@ runs:
53
53
  echo -e "\nALKiln version is $ALKILN_VERSION\nRepo is $REPO_URL\nBranch ref is $BRANCH_PATH\nMAX_SECONDS_FOR_SETUP is $MAX_SECONDS_FOR_SETUP\nSERVER_RELOAD_TIMEOUT_SECONDS is $SERVER_RELOAD_TIMEOUT_SECONDS\n"
54
54
  shell: bash
55
55
 
56
- # Install node
56
+ # Install
57
57
  - name: "ALKiln: Install node packages"
58
58
  uses: actions/setup-node@v3
59
59
  with:
@@ -81,33 +81,31 @@ runs:
81
81
  if: ${{ inputs.INSTALL_METHOD == 'server' && failure() }}
82
82
  shell: bash
83
83
 
84
- # debugging
85
- - name: Setup tmate session
86
- uses: mxschmitt/action-tmate@v3
87
-
88
84
  ############
89
85
  ##### !!! WARNING: RESTORE CODE FOR TAGS
90
86
  ############
91
- ## run tests
92
- #- name: "ALKiln: Run tests"
93
- # if: ${{ success() }}
94
- # run: alkiln-run @e6 or @al1
95
- # #run: alkiln-run ${{ github.event.inputs.tags && format('{0}', github.event.inputs.tags) }}
96
- # shell: bash
97
- #
98
- ## on playground, delete project
99
- #- name: "ALKiln: Try to delete the project from the playground of the docassemble test account."
100
- # if: ${{ inputs.INSTALL_METHOD == 'playground' }}
101
- # run: alkiln-takedown
102
- # shell: bash
103
- #
104
- ## Upload artifacts that subscribers can download on the Actions summary page
105
- #- name: "ALKiln: Upload artifacts folder"
106
- # if: ${{ always() }}
107
- # uses: actions/upload-artifact@v3
108
- # with:
109
- # name: ${{ env.ARTIFACT_NAME }}
110
- # path: ./alkiln-*
87
+ # run tests
88
+ - name: "ALKiln: Run tests"
89
+ if: ${{ success() }}
90
+ # run: alkiln-run @e6 or @al1
91
+ run: alkiln-run @al1
92
+ shell: bash
93
+
94
+ # run: alkiln-run ${{ github.event.inputs.tags && format('{0}', github.event.inputs.tags) }}
95
+
96
+ # on playground, delete project
97
+ - name: "ALKiln: Try to delete the project from the playground of the docassemble test account."
98
+ if: ${{ inputs.INSTALL_METHOD == 'playground' }}
99
+ run: alkiln-takedown
100
+ shell: bash
101
+
102
+ # Upload artifacts that subscribers can download on the Actions summary page
103
+ - name: "ALKiln: Upload artifacts folder"
104
+ if: ${{ always() }}
105
+ uses: actions/upload-artifact@v3
106
+ with:
107
+ name: ${{ env.ARTIFACT_NAME }}
108
+ path: ./alkiln-*
111
109
 
112
110
  # ##################################
113
111
  # # A developer's workflow should look similar to the below
@@ -1,6 +1,12 @@
1
1
  name: "ALKiln/github_server: Isolated docassemble tests"
2
2
  description: "Download and start up a temporary docassemble server on GitHub's servers, in an isolated environment. Avoids docassemble reload errors and other external factors."
3
3
 
4
+ # Wat? Exit with 52?
5
+ # https://github.com/SuffolkLITLab/ALKiln/actions/runs/5912900256/job/16036751264#step:4:188
6
+ # Had no completion messages, but it exited with an error anyway
7
+ # Took 121 seconds
8
+ # The rerun of the test completed that step just fine, though it took less time
9
+ # Took 120 and was fine: https://github.com/SuffolkLITLab/ALKiln/actions/runs/5913167036/job/16037288791
4
10
 
5
11
  inputs:
6
12
  CONFIG_CONTENTS:
@@ -27,6 +33,9 @@ runs:
27
33
  run: |
28
34
  echo "DA_ADMIN_API_KEY=abcd1234abcd1234abcd5678abdc5678" >> $GITHUB_ENV
29
35
  echo "MAX_SECONDS_FOR_DOCKER=${{ inputs.MAX_SECONDS_FOR_DOCKER }}" >> $GITHUB_ENV
36
+ echo "CLONE_URL=${{ github.server_url }}/${{ github.repository }}.git" >> $GITHUB_ENV
37
+ echo "OWNER_AND_REPO_NAME=${{ github.repository }}" >> $GITHUB_ENV
38
+ echo "BRANCH_REF=${{ github.ref }}" >> $GITHUB_ENV
30
39
  shell: bash
31
40
  - id: api_key_output_step
32
41
  run: echo "::set-output name=DOCASSEMBLE_DEVELOPER_API_KEY::$DA_ADMIN_API_KEY"
@@ -47,8 +56,8 @@ runs:
47
56
  # Wait 1 minute before pinging the server constantly
48
57
  sleep 60
49
58
 
50
- # Use a variable we can control to avoid race conditions from
51
- # preventing the success log message.
59
+ # Use a variable instead of checking $result so we can control to avoid race
60
+ # conditions from preventing the success log message.
52
61
  ready="false"
53
62
 
54
63
  while [[ $ready == "false" ]]; do
@@ -76,6 +85,37 @@ runs:
76
85
 
77
86
  done
78
87
  shell: bash
88
+
89
+ - name: Install the package
90
+ run: |
91
+ echo "CLONE_URL is $CLONE_URL"
92
+ git clone $CLONE_URL
93
+
94
+ # Split the full repository name by '/' and get the last element (repo name)
95
+ IFS='/' read -ra repo_parts <<< "$OWNER_AND_REPO_NAME"
96
+ repo_name=${repo_parts[-1]}
97
+ echo "repo_name is $repo_name"
98
+ cd $repo_name
99
+
100
+ echo "BRANCH_REF is $BRANCH_REF"
101
+ ref_name=$BRANCH_REF
102
+ branch_name="${ref_name#refs/heads/}"
103
+ echo "branch name is $branch_name"
104
+ git checkout -b $branch_name
105
+ git fetch origin $branch_name
106
+ git reset --hard origin/$branch_name
107
+
108
+ cd ..
109
+ pip install docassemblecli
110
+ dainstall $repo_name --apiurl http://localhost --apikey $DA_ADMIN_API_KEY
111
+
112
+ ## Below here is just for development
113
+ #container_name=$(docker ps --format '{{.Names}}' | head -n 1)
114
+ #echo $container_name
115
+ #docker exec -it "$container_name /bin/bash"
116
+ #echo "ls /usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble"
117
+ shell: bash
118
+
79
119
  - name: Docker logs
80
120
  if: ${{ always() }}
81
121
  # TODO: create an arifact for this instead
@@ -11,18 +11,12 @@ let get_base_interview_url = async function () {
11
11
  * when the user is not logged in.) We can't use `reset=2` because it caused an
12
12
  * 'Unable to locate interview session' error. */
13
13
  let server_url = session_vars.get_da_server_url();
14
- console.log(session_vars.get_install_type());
15
14
  if (session_vars.get_install_type() === "server") {
16
- let x = `${ server_url }/interview?new_session=1&i=docassemble.${session_vars.get_package_name().replace("-", ".")}%3Adata/questions/`;
17
- // e.g. http://localhost/interview?new_session=1&i=ALKiln%3A
18
- console.log(`base_interview_url: ${x}`)
19
- return x;
15
+ return `${ server_url }/interview?new_session=1&i=docassemble.${session_vars.get_package_name().replace("-", ".")}%3Adata/questions/`;
20
16
  } else {
21
17
  let dev_id = await docassemble_api_interface.get_dev_id();
22
18
  let project_name = session_vars.get_project_name();
23
- let x = `${ server_url }/interview?new_session=1&i=docassemble.playground${ dev_id }${ project_name }%3A`;
24
- console.log(`base_interview_url: ${x}`)
25
- return x;
19
+ return `${ server_url }/interview?new_session=1&i=docassemble.playground${ dev_id }${ project_name }%3A`;
26
20
  }
27
21
  };
28
22
 
@@ -56,12 +56,12 @@ const startserver = async () => {
56
56
  await browser.close();
57
57
  */
58
58
 
59
- let task_id = await da_i.install_on_server();
60
- if (task_id) {
61
- console.log("Waiting...")
62
- await da_i.wait_for_package_to_restart(task_id);
63
- }
64
- console.log("Done!")
59
+ // let task_id = await da_i.install_on_server();
60
+ // if (task_id) {
61
+ // console.log("Waiting...")
62
+ // await da_i.wait_for_package_to_restart(task_id);
63
+ // }
64
+ // console.log("Done!")
65
65
  session_vars.save_install_type("server");
66
66
 
67
67
  }; // Ends startserver();
package/lib/scope.js CHANGED
@@ -44,6 +44,9 @@ let printable_var_value = function(row) {
44
44
  /* `row` might be a row, a source row, or an original row. */
45
45
  let original = get_original_row(row);
46
46
  if ( is_secret_var(original) ) {
47
+ if ( session_vars.get_dangerous_debug() ) {
48
+ return `alkiln_dangerous ${ row.value }`;
49
+ }
47
50
  return original.flags.secret_name;
48
51
  }
49
52
  return row.value;
@@ -755,7 +758,7 @@ module.exports = {
755
758
  if ( session_vars.get_debug() ) { console.log( `interview_url:`, interview_url ); }
756
759
 
757
760
  if ( !scope.page ) { scope.page = await scope.browser.newPage(); }
758
-
761
+
759
762
  console.log(`interview_url:`, interview_url);
760
763
 
761
764
  // TODO: implement and use scope.handle_possible_timeout()
@@ -2522,6 +2525,10 @@ module.exports = {
2522
2525
  /** Sets a non-story table variable to a "secret" value (i.e. an env var) */
2523
2526
  // Prevent pictures of a screen with a secret.
2524
2527
  scope.disable_error_screenshot = true;
2528
+ if ( session_vars.get_dangerous_debug() ) {
2529
+ scope.disable_error_screenshot = false;
2530
+ }
2531
+
2525
2532
  let var_data = await scope.normalizeTable( scope, {
2526
2533
  var_data: [{
2527
2534
  var: var_name,
@@ -2665,7 +2672,10 @@ module.exports = {
2665
2672
  */
2666
2673
  // Don't take a picture of a failed login in case one of the inputs is correct
2667
2674
  scope.disable_error_screenshot = true;
2668
-
2675
+ if ( session_vars.get_dangerous_debug() ) {
2676
+ scope.disable_error_screenshot = false;
2677
+ }
2678
+
2669
2679
  // If there is no browser open, start a new one
2670
2680
  if (!scope.browser) {
2671
2681
  scope.browser = await scope.driver.launch({ headless: !session_vars.DEBUG });
@@ -2698,6 +2708,10 @@ module.exports = {
2698
2708
  let email = process.env[ email_secret_name ];
2699
2709
  let password = process.env[ password_secret_name ];
2700
2710
 
2711
+ if ( session_vars.get_dangerous_debug() ) {
2712
+ log.debug({ type: `unsafe`, data: `login: ${ email }, ${ password }` });
2713
+ }
2714
+
2701
2715
  // Give as many useful messages to the user as possible if the env vars
2702
2716
  // aren't defined. Eventually, just provide a link to the docs because
2703
2717
  // this is complex
@@ -23,6 +23,7 @@ module.exports = session_vars;
23
23
  // These default to null
24
24
  // TODO: How to isolate debug elsewhere so this file can use the logger?
25
25
  session_vars.get_debug = function () { return process.env.DEBUG || null; };
26
+ session_vars.get_dangerous_debug = function () { return process.env._ALKILN_DANGEROUS_DEBUG || null; };
26
27
  session_vars.is_dev_env = function () { return process.env.DEV || null; }
27
28
 
28
29
  session_vars.get_dev_api_key = function () { return process.env.DOCASSEMBLE_DEVELOPER_API_KEY || null; };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "5.0.2-feat-github-server-7",
3
+ "version": "5.0.2-feat-github-server-9",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,61 +0,0 @@
1
- import os
2
- import sys
3
- from setuptools import setup, find_packages
4
- from fnmatch import fnmatchcase
5
- from distutils.util import convert_path
6
-
7
- standard_exclude = ('*.pyc', '*~', '.*', '*.bak', '*.swp*')
8
- standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', './dist', 'EGG-INFO', '*.egg-info')
9
-
10
- def find_package_data(where='.', package='', exclude=standard_exclude, exclude_directories=standard_exclude_directories):
11
- out = {}
12
- stack = [(convert_path(where), '', package)]
13
- while stack:
14
- where, prefix, package = stack.pop(0)
15
- for name in os.listdir(where):
16
- fn = os.path.join(where, name)
17
- if os.path.isdir(fn):
18
- bad_name = False
19
- for pattern in exclude_directories:
20
- if (fnmatchcase(name, pattern)
21
- or fn.lower() == pattern.lower()):
22
- bad_name = True
23
- break
24
- if bad_name:
25
- continue
26
- if os.path.isfile(os.path.join(fn, '__init__.py')):
27
- if not package:
28
- new_package = name
29
- else:
30
- new_package = package + '.' + name
31
- stack.append((fn, '', new_package))
32
- else:
33
- stack.append((fn, prefix + name + '/', package))
34
- else:
35
- bad_name = False
36
- for pattern in exclude:
37
- if (fnmatchcase(name, pattern)
38
- or fn.lower() == pattern.lower()):
39
- bad_name = True
40
- break
41
- if bad_name:
42
- continue
43
- out.setdefault(package, []).append(prefix+name)
44
- return out
45
-
46
- setup(name='docassemble.ALKiln',
47
- version='0.0.1',
48
- description=('A docassemble extension.'),
49
- long_description='# docassemble.ALKiln\r\n\r\nA docassemble extension.\r\n\r\nALKiln, or Assembly Line Kiln, is an open source project that helps [docassemble](https://docassemble.org/) developers create automated tests for their interviews (online forms). It works well with the [Document Assembly Line Project](https://suffolklitlab.org/docassemble-AssemblyLine-documentation) but is independent of it.\r\n\r\n',
50
- long_description_content_type='text/markdown',
51
- author='plocket',
52
- author_email='52798256+plocket@users.noreply.github.com',
53
- license='The MIT License (MIT)',
54
- url='https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln',
55
- packages=find_packages(),
56
- namespace_packages=['docassemble'],
57
- install_requires=[],
58
- zip_safe=False,
59
- package_data=find_package_data(where='docassemble/ALKiln/', package='docassemble.ALKiln'),
60
- )
61
-