@suffolklitlab/alkiln 5.0.2-feat-github-server-1 → 5.0.2-feat-github-server-3

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.
@@ -2,6 +2,7 @@ name: GitHub server tests
2
2
 
3
3
  on:
4
4
  push:
5
+ # why is workflow dispatch not showing up in github?
5
6
  workflow_dispatch:
6
7
  inputs:
7
8
  tags:
@@ -11,6 +12,12 @@ on:
11
12
  # They test if env vars get set correctly and depencencies get
12
13
  # pulled in correctly.
13
14
  default: '@e6 or @al1'
15
+ enable_tmate:
16
+ type: boolean
17
+ description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
18
+ required: false
19
+ default: true
20
+ # TODO: alkiln_version:
14
21
 
15
22
  jobs:
16
23
 
@@ -21,17 +28,34 @@ jobs:
21
28
  node-version: [18.x]
22
29
 
23
30
  env:
24
- USER1_EMAIL: ${{ secrets.USER1_EMAIL }}
25
- USER1_PASSWORD: ${{ secrets.USER1_PASSWORD }}
31
+ USER1_EMAIL: admin@example.com
32
+ USER1_PASSWORD: password
26
33
  SECRET_VAR1: secret-var1-value
27
34
  SECRET_VAR2: secret-var2-value
28
35
  SECRET_FOR_MISSING_FIELD: secret for missing field
29
36
 
30
37
  steps:
31
38
  - uses: actions/checkout@v3
32
- - name: Run ALKiln on the GitHub server
33
- uses: SuffolkLITLab/ALKiln/github_server@start_server_take_2
39
+ - name: Setup tmate session
40
+ if: ${{ inputs.enable_tmate }}
41
+ uses: mxschmitt/action-tmate@v3
42
+ with:
43
+ detached: true
44
+
45
+ - name: Start the temporary GitHub server
46
+ id: github_server
47
+ uses: ./github_server
34
48
  with:
35
49
  CONFIG_CONTENTS: "${{ secrets.CONFIG_CONTENTS }}"
36
- ALKILN_VERSION: 5.0.2-feat-github-server-1
37
- - run: echo "Finished running on the GitHub server"
50
+ - run: echo "Finished starting the GitHub server"
51
+
52
+ - name: "Run ALKiln tests"
53
+ if: ${{ success() }}
54
+ uses: ./
55
+ with:
56
+ SERVER_URL: "${{ steps.github_server.outputs.SERVER_URL }}"
57
+ DOCASSEMBLE_DEVELOPER_API_KEY: "${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}"
58
+ INSTALL_METHOD: "server"
59
+ ALKILN_VERSION: "5.0.2-feat-github-server-3"
60
+ - run: echo "Finished running ALKiln tests"
61
+
package/action.yml CHANGED
@@ -23,6 +23,12 @@ inputs:
23
23
  description: "Max amount of time to give the server to reload if it needs to"
24
24
  required: false
25
25
  # no default to let the custom Scenario timeouts create the reload timeout
26
+ # INSTALL_LOCATION? Will that get confused with the location passed into the command line?
27
+ # Maybe it could be "playground", "server", or a custom path and we could handle all those.
28
+ INSTALL_METHOD:
29
+ description: "Default is 'playground'. Other option: 'server'. How to install the package onto the server."
30
+ required: false
31
+ default: "playground"
26
32
 
27
33
  runs:
28
34
  using: "composite"
@@ -54,22 +60,44 @@ runs:
54
60
  node-version: "18"
55
61
  - name: Install ALKiln directly from npm
56
62
  run: |
57
- npm install -g @suffolklitlab/alkiln
63
+ npm install -g @suffolklitlab/alkiln@$ALKILN_VERSION
58
64
  shell: bash
59
65
 
60
- # Run tests
66
+ # Install on playground
61
67
  - name: "ALKiln: Create a Project and pull the package from GitHub"
68
+ if: ${{ inputs.INSTALL_METHOD == 'playground' }}
62
69
  run: alkiln-setup
63
70
  shell: bash
71
+ - run: echo -e "\n\n====\nALKiln could not create a project on your server's testing account or pull your package into it. Check the messages above this line.\n\n"
72
+ if: ${{ inputs.INSTALL_METHOD == 'playground' && failure() }}
73
+ shell: bash
74
+
75
+ # Install on server
76
+ - name: "ALKiln: Install the GitHub package onto the server"
77
+ if: ${{ inputs.INSTALL_METHOD == 'server' }}
78
+ run: alkiln-startserver
79
+ shell: bash
80
+ - run: echo -e "\n\n====\nALKiln could not install the package on the temporary GitHub docassemble server. Check the steps above this line.\n\n"
81
+ if: ${{ inputs.INSTALL_METHOD == 'server' && failure() }}
82
+ shell: bash
83
+
84
+ ## debugging
85
+ #- name: Setup tmate session
86
+ # uses: mxschmitt/action-tmate@v3
87
+
88
+ ###########
89
+ #### !!! WARNING: RESTORE CODE FOR TAGS
90
+ ###########
91
+ # run tests
64
92
  - name: "ALKiln: Run tests"
65
93
  if: ${{ success() }}
66
- run: alkiln-run ${{ github.event.inputs.tags && format('{0}', github.event.inputs.tags) }}
67
- shell: bash
68
- - run: echo -e "\n\n====ALKiln could not create a project on your server's testing account or pull your package into it. Check the messages above this line.\n\n"
69
- if: ${{ failure() }}
94
+ run: alkiln-run @e6 or @al1
95
+ #run: alkiln-run ${{ github.event.inputs.tags && format('{0}', github.event.inputs.tags) }}
70
96
  shell: bash
71
- - name: "ALKiln: Delete project from docassemble test account"
72
- if: ${{ always() }}
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' }}
73
101
  run: alkiln-takedown
74
102
  shell: bash
75
103
 
@@ -1,26 +1,23 @@
1
1
  name: "ALKiln/github_server: Isolated docassemble tests"
2
- description: "Automatically test docassemble interviews on GitHub's servers, in an isolated environment. Avoids docassemble reload errors and other external factors."
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
4
 
5
5
  inputs:
6
6
  CONFIG_CONTENTS:
7
7
  description: "The contents of the config file of the docassemble server"
8
8
  required: false
9
- # This is necessary to test pre-releases at the very least. It does seem
10
- # strange considering we're controlling everything through the action, but
11
- # that actually doesn't touch the npm version that's pulled in.
12
- ALKILN_VERSION:
13
- description: 'Version of ALKiln to get from npm.'
9
+ MAX_SECONDS_FOR_DOCKER:
10
+ description: "Maximum amount of seconds to give the docassemble docker container to serve the site."
14
11
  required: false
15
- default: '^5.0.0'
16
- MAX_SECONDS_FOR_SETUP:
17
- description: "Amount of time to give the Project to upload your package's GitHub code."
18
- required: false
19
- default: '120'
20
- SERVER_RELOAD_TIMEOUT_SECONDS:
21
- description: "Max amount of time to give the server to reload if it needs to"
22
- required: false
23
- # no default to let the custom Scenario timeouts create the reload timeout
12
+ default: 600 # 10 min
13
+
14
+ outputs:
15
+ DOCASSEMBLE_DEVELOPER_API_KEY:
16
+ description: "Use this inside `with:` for the ALKiln step. Temporary admin api key. It will be destroyed after the tests are done."
17
+ value: ${{ steps.api_key_output_step.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}
18
+ SERVER_URL:
19
+ description: "Use this inside `with:` for the ALKiln step. URL of the temporary docassemble server."
20
+ value: "http://localhost"
24
21
 
25
22
 
26
23
  runs:
@@ -29,28 +26,58 @@ runs:
29
26
  - name: "github_server: Set environment variables"
30
27
  run: |
31
28
  echo "DA_ADMIN_API_KEY=abcd1234abcd1234abcd5678abdc5678" >> $GITHUB_ENV
29
+ echo "MAX_SECONDS_FOR_DOCKER=${{ inputs.MAX_SECONDS_FOR_DOCKER }}" >> $GITHUB_ENV
30
+ shell: bash
31
+ - id: api_key_output_step
32
+ run: echo "::set-output name=DOCASSEMBLE_DEVELOPER_API_KEY::$DA_ADMIN_API_KEY"
32
33
  shell: bash
33
34
  - name: "github_server: Download and start docker"
34
35
  run: |
35
36
  mkdir /tmp/config
36
- echo "$CONFIG_CONTENTS" > /tmp/config/myconfig.yml
37
- docker pull brycewilley/smoldocassemble
37
+ echo "${{ inputs.CONFIG_CONTENTS }}" > /tmp/config/myconfig.yml
38
+ docker pull jhpyle/docassemble
38
39
  docker run --env DA_ADMIN_EMAIL="admin@example.com" --env DA_ADMIN_PASSWORD="password" --env DA_ADMIN_API_KEY="${{ env.DA_ADMIN_API_KEY }}" --env DA_CONFIG=/tmp/config/myconfig.yml --volume /tmp/config:/tmp/config --cap-add SYS_PTRACE --memory="4gb" -d -p 80:80 jhpyle/docassemble
39
- # TODO before merge: do a while loop here until `localhost` shows "It's ready"
40
- sleep 600
41
- sleep 600
42
- curl localhost
43
40
  shell: bash
44
- - name: "github_server: Install the package"
45
- run: alkiln-startserver
41
+ - name: "github_server: Wait for server to start"
42
+ run: |
43
+ # github_server: Wait for server to start
44
+
45
+ # Reset the SECONDS variable
46
+ SECONDS=60
47
+ # Wait 1 minute before pinging the server constantly
48
+ sleep $SECONDS
49
+
50
+ # Use a variable we can control to avoid race conditions from
51
+ # preventing the success log message.
52
+ ready="false"
53
+
54
+ while [[ $ready == "false" ]]; do
55
+ echo "Time ellapsed: $SECONDS seconds"
56
+
57
+ # Get input for max number of seconds to wait
58
+ # ${{ inputs.MAX_SECONDS_FOR_DOCKER }} as a number? Bash doesn't have types, just strings
59
+ # Check if max seconds till loading has passed
60
+ if [[ $SECONDS -ge $MAX_SECONDS_FOR_DOCKER ]]; then
61
+ 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."
62
+ break
63
+ fi
64
+
65
+ # Set the variable to a new string value in each iteration
66
+ result=$(curl -s localhost)
67
+
68
+ # Check if the string includes the desired text
69
+ if [[ ! $result == *"Docassemble is starting"* ]]; then
70
+ echo "Success! The docker container is ready!"
71
+ ready="true"
72
+ else
73
+ echo "The docker container isn't ready yet. Will check again in 30 seconds."
74
+ sleep 30
75
+ fi
76
+
77
+ done
46
78
  shell: bash
47
- - name: "github_server: Run Kiln"
48
- # TODO: Research how to get this to always be the same branch we're on
49
- uses: SuffolkLITLab/ALKiln@v5
50
- with:
51
- SERVER_URL: "http://localhost"
52
- DOCASSEMBLE_DEVELOPER_API_KEY: "${{ env.DA_ADMIN_API_KEY }}"
53
79
  - name: Docker logs
80
+ if: ${{ always() }}
54
81
  # TODO: create an arifact for this instead
55
82
  run: |
56
83
  docker logs $(docker ps --filter "ancestor=jhpyle/docassemble" --format {{.ID}})
@@ -340,11 +340,9 @@ da_i.install_on_server = async function ( install_options ) {
340
340
  timeout
341
341
  );
342
342
  if ( response && response.status === 200 ) {
343
- // console.log("%o", response);
344
343
  log.debug({ pre: `install task id: ${ response.data.task_id }` });
345
344
  return response.data.task_id;
346
345
  }
347
- // console.log(`${ response.status }: ${ response.data }`);
348
346
  return null;
349
347
  } catch (error ) {
350
348
  log.error({ pre: `Installing on the docassemble serve ran into an unexpected error.`, data: error.toJSON()});
@@ -13,7 +13,8 @@ let get_base_interview_url = async function () {
13
13
  let server_url = session_vars.get_da_server_url();
14
14
  console.log(session_vars.get_install_type());
15
15
  if (session_vars.get_install_type() === "server") {
16
- let x = `${ server_url }/interview?new_session=1&i=${session_vars.get_package_name().replace("-", ".")}%3A`;
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
17
18
  console.log(`base_interview_url: ${x}`)
18
19
  return x;
19
20
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "5.0.2-feat-github-server-1",
3
+ "version": "5.0.2-feat-github-server-3",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {