@suffolklitlab/alkiln 5.0.2-feat-github-server-10 → 5.0.2-feat-github-server-12

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.
@@ -16,7 +16,7 @@ on:
16
16
  type: boolean
17
17
  description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
18
18
  required: false
19
- default: true
19
+ default: false
20
20
  # TODO: alkiln_version:
21
21
 
22
22
  jobs:
@@ -28,15 +28,18 @@ jobs:
28
28
  node-version: [18.x]
29
29
 
30
30
  env:
31
- USER1_EMAIL: admin@example.com
32
- USER1_PASSWORD: password
31
+ # How would a dev make another user/password if they wanted to?
33
32
  SECRET_VAR1: secret-var1-value
34
33
  SECRET_VAR2: secret-var2-value
35
34
  SECRET_FOR_MISSING_FIELD: secret for missing field
36
- _ALKILN_DANGEROUS_DEBUG: true
35
+ #_ALKILN_DANGEROUS_DEBUG: true
37
36
 
38
37
  steps:
38
+ # Place the root directory in this branch
39
39
  - uses: actions/checkout@v3
40
+
41
+ # Debugging. Maybe add a long sleep after whatever it is we want to check
42
+ # to give us time to explore.
40
43
  - name: Setup tmate session
41
44
  if: ${{ inputs.enable_tmate }}
42
45
  uses: mxschmitt/action-tmate@v3
@@ -50,6 +53,23 @@ jobs:
50
53
  CONFIG_CONTENTS: "${{ secrets.CONFIG_CONTENTS }}"
51
54
  - run: echo "Finished starting the GitHub server"
52
55
 
56
+ # Debugging on failure
57
+ # Trying to catch that intermittent bug mentioned in ./github_server/action.yml
58
+ - name: Docker failure tmate session
59
+ if: ${{ failure() }}
60
+ uses: mxschmitt/action-tmate@v3
61
+
62
+ - name: Set more env vars
63
+ run: |
64
+ echo "USER1_EMAIL=${{ steps.github_server.outputs.DA_ADMIN_EMAIL }}" >> $GITHUB_ENV
65
+ echo "USER1_PASSWORD=${{ steps.github_server.outputs.DA_ADMIN_PASSWORD }}" >> $GITHUB_ENV
66
+ #- name: Work with docker
67
+ # run: |
68
+ # # Authors can use this to do more with the docker container.
69
+ # # There may be a better way. Would take research. A docker action?
70
+ # container_name=$(docker ps --format '{{.Names}}' | head -n 1)
71
+ # echo "container_name is $container_name"
72
+
53
73
  - name: "Run ALKiln tests"
54
74
  if: ${{ success() }}
55
75
  uses: ./
@@ -58,6 +78,6 @@ jobs:
58
78
  DOCASSEMBLE_DEVELOPER_API_KEY: "${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}"
59
79
  INSTALL_METHOD: "server"
60
80
  # TODO: See what happens if this is an empty string
61
- ALKILN_VERSION: "5.0.2-feat-github-server-10"
81
+ ALKILN_VERSION: "5.0.2-feat-github-server-12"
62
82
  - run: echo "Finished running ALKiln tests"
63
83
 
package/action.yml CHANGED
@@ -24,7 +24,7 @@ inputs:
24
24
  required: false
25
25
  # no default to let the custom Scenario timeouts create the reload timeout
26
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.
27
+ # Maybe `INSTALL_LOCATION` could be "playground", "server", or a custom path and we could handle all those.
28
28
  INSTALL_METHOD:
29
29
  description: "Default is 'playground'. Other option: 'server'. How to install the package onto the server."
30
30
  required: false
@@ -75,23 +75,17 @@ runs:
75
75
  # Install on server
76
76
  - name: "ALKiln: Install the GitHub package onto the server"
77
77
  if: ${{ inputs.INSTALL_METHOD == 'server' }}
78
- run: alkiln-startserver
78
+ run: alkiln-server-install
79
79
  shell: bash
80
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
81
  if: ${{ inputs.INSTALL_METHOD == 'server' && failure() }}
82
82
  shell: bash
83
83
 
84
- ############
85
- ##### !!! WARNING: RESTORE CODE FOR TAGS
86
- ############
87
84
  # run tests
88
85
  - name: "ALKiln: Run tests"
89
86
  if: ${{ success() }}
90
- # run: alkiln-run @e6 or @al1
91
- run: alkiln-run @e6
87
+ run: alkiln-run ${{ github.event.inputs.tags && format('{0}', github.event.inputs.tags) }}
92
88
  shell: bash
93
-
94
- # run: alkiln-run ${{ github.event.inputs.tags && format('{0}', github.event.inputs.tags) }}
95
89
 
96
90
  # on playground, delete project
97
91
  - name: "ALKiln: Try to delete the project from the playground of the docassemble test account."
@@ -108,7 +102,7 @@ runs:
108
102
  path: ./alkiln-*
109
103
 
110
104
  # ##################################
111
- # # A developer's workflow should look similar to the below
105
+ # # A developer's workflow should look similar to the below.
112
106
  # # In place of `uses: suffolkLITLab/ALKiln@v5`, they
113
107
  # # might use another version.
114
108
  #
@@ -1,14 +1,26 @@
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?
4
+ # Wat? Exit with 52
5
5
  # https://github.com/SuffolkLITLab/ALKiln/actions/runs/5912900256/job/16036751264#step:4:188
6
6
  # Had no completion messages, but it exited with an error anyway
7
7
  # Took 121 seconds
8
8
  # The rerun of the test completed that step just fine, though it took less time
9
9
  # Took 120 and was fine: https://github.com/SuffolkLITLab/ALKiln/actions/runs/5913167036/job/16037288791
10
- # 150:
11
- # https://github.com/SuffolkLITLab/ALKiln/actions/runs/5914677262/job/16040233419
10
+ # 150 secs with exit code 56:
11
+ # https://github.com/SuffolkLITLab/ALKiln/actions/runs/5914677262/job/16040233419#step:4:196
12
+ # 120 sec with exit code 56:
13
+ # https://github.com/SuffolkLITLab/ALKiln/actions/runs/5914963614/job/16040773624#step:4:206
14
+
15
+ # If we want to control the version of the docassemble image, we'd have
16
+ # to make our own image:
17
+ # You can build your own image by doing git clone jhpyle/docassemble and then
18
+ # using git checkout to select a particular version, and then using docker build
19
+ # to build an image. https://docassemble.org/docs/docker.html#downgrading
20
+ # If we just want to use an older version of da (as long as it works with
21
+ # the latest image):
22
+ # If you have an existing container you can use dainstall from the command
23
+ # line to install docassemble.webapp==1.4.68
12
24
 
13
25
  inputs:
14
26
  CONFIG_CONTENTS:
@@ -27,17 +39,17 @@ outputs:
27
39
  description: "Use this inside `with:` for the ALKiln step. URL of the temporary docassemble server."
28
40
  value: "http://localhost"
29
41
  DA_ADMIN_EMAIL:
30
- #value: ${{ steps.api_key_output_step.outputs.DA_ADMIN_EMAIL }}
31
- value: "admin@example.com"
42
+ value: ${{ steps.api_key_output_step.outputs.DA_ADMIN_EMAIL }}
32
43
  DA_ADMIN_PASSWORD:
33
- #value: ${{ steps.api_key_output_step.outputs.DA_ADMIN_PASSWORD }}
34
- value: "password"
44
+ value: ${{ steps.api_key_output_step.outputs.DA_ADMIN_PASSWORD }}
35
45
 
36
46
 
37
47
  runs:
38
48
  using: "composite"
39
49
  steps:
40
- - name: "github_server: Set environment variables"
50
+ - uses: actions/checkout@v3
51
+
52
+ - name: "ALKiln github_server: Set environment variables"
41
53
  run: |
42
54
  echo "DA_ADMIN_API_KEY=abcd1234abcd1234abcd5678abdc5678" >> $GITHUB_ENV
43
55
  echo "MAX_SECONDS_FOR_DOCKER=${{ inputs.MAX_SECONDS_FOR_DOCKER }}" >> $GITHUB_ENV
@@ -45,22 +57,24 @@ runs:
45
57
  echo "OWNER_AND_REPO_NAME=${{ github.repository }}" >> $GITHUB_ENV
46
58
  echo "BRANCH_REF=${{ github.ref }}" >> $GITHUB_ENV
47
59
  echo "DA_ADMIN_EMAIL=admin@example.com" >> $GITHUB_ENV
48
- echo "DA_ADMIN_PASSWORD=password" >> $GITHUB_ENV
60
+ # Login will fail if this is "password"
61
+ echo "DA_ADMIN_PASSWORD=@123abcdefg" >> $GITHUB_ENV
49
62
  shell: bash
50
63
  - id: api_key_output_step
51
64
  run: |
52
- echo "::set-output name=DOCASSEMBLE_DEVELOPER_API_KEY::$DA_ADMIN_API_KEY"
53
- echo "::set-output name=DA_ADMIN_EMAIL::$DA_ADMIN_EMAIL"
54
- echo "::set-output name=DA_ADMIN_PASSWORD::$DA_ADMIN_PASSWORD"
65
+ echo "DOCASSEMBLE_DEVELOPER_API_KEY=$DA_ADMIN_API_KEY" >> "$GITHUB_OUTPUT"
66
+ echo "DA_ADMIN_EMAIL=$DA_ADMIN_EMAIL" >> "$GITHUB_OUTPUT"
67
+ echo "DA_ADMIN_PASSWORD=$DA_ADMIN_PASSWORD" >> "$GITHUB_OUTPUT"
55
68
  shell: bash
56
- - name: "github_server: Download and start docker"
69
+
70
+ - name: "ALKiln github_server: Download and start docker"
57
71
  run: |
58
72
  mkdir /tmp/config
59
- echo "${{ inputs.CONFIG_CONTENTS }}" > /tmp/config/myconfig.yml
73
+ echo "${{ inputs.CONFIG_CONTENTS }}" > /tmp/config/myconfig.yml
60
74
  docker pull jhpyle/docassemble
61
- 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
75
+ docker run --env DA_ADMIN_EMAIL="${{ env.DA_ADMIN_EMAIL }}" --env DA_ADMIN_PASSWORD="${{ env.DA_ADMIN_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
62
76
  shell: bash
63
- - name: "github_server: Wait for server to start"
77
+ - name: "ALKiln github_server: Wait for server to start"
64
78
  run: |
65
79
  # github_server: Wait for server to start
66
80
 
@@ -69,26 +83,26 @@ runs:
69
83
  # Wait 1 minute before pinging the server constantly
70
84
  sleep 60
71
85
 
72
- # Use a variable instead of checking $result so we can control to avoid race
86
+ # Use a variable instead of checking $response so we can control to avoid race
73
87
  # conditions from preventing the success log message.
74
88
  ready="false"
75
89
 
76
90
  while [[ $ready == "false" ]]; do
77
91
  echo "Time ellapsed: $SECONDS seconds"
78
92
 
79
- # Get input for max number of seconds to wait
80
- # ${{ inputs.MAX_SECONDS_FOR_DOCKER }} as a number? Bash doesn't have types, just strings
81
93
  # Check if max seconds till loading has passed
82
94
  if [[ $SECONDS -ge $MAX_SECONDS_FOR_DOCKER ]]; then
83
95
  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."
96
+ # Exit with failure, or allow this to keep going?
84
97
  break
85
98
  fi
86
99
 
87
100
  # Set the variable to a new string value in each iteration
88
- result=$(curl -s localhost)
101
+ response=$(curl -o /dev/null -s -w "%{http_code}\n" http://localhost:80/health_check?ready=1)
102
+ echo "response is $response"
89
103
 
90
104
  # Check if the string includes the desired text
91
- if [[ ! $result == *"Docassemble is starting"* ]]; then
105
+ if [[ $response == *"200"* ]]; then
92
106
  echo "Success! The docker container is ready!"
93
107
  ready="true"
94
108
  else
@@ -99,39 +113,34 @@ runs:
99
113
  done
100
114
  shell: bash
101
115
 
102
- - name: Install the package
103
- run: |
104
- echo "CLONE_URL is $CLONE_URL"
105
- git clone $CLONE_URL
106
-
107
- # Split the full repository name by '/' and get the last element (repo name)
108
- IFS='/' read -ra repo_parts <<< "$OWNER_AND_REPO_NAME"
109
- repo_name=${repo_parts[-1]}
110
- echo "repo_name is $repo_name"
111
- cd $repo_name
112
-
113
- echo "BRANCH_REF is $BRANCH_REF"
114
- ref_name=$BRANCH_REF
115
- branch_name="${ref_name#refs/heads/}"
116
- echo "branch name is $branch_name"
117
- git checkout -b $branch_name
118
- git fetch origin $branch_name
119
- git reset --hard origin/$branch_name
120
-
121
- cd ..
122
- pip install docassemblecli
123
- dainstall $repo_name --apiurl http://localhost --apikey $DA_ADMIN_API_KEY
124
-
125
- ## Below here is just for development
126
- #container_name=$(docker ps --format '{{.Names}}' | head -n 1)
127
- #echo $container_name
128
- #docker exec -it "$container_name /bin/bash"
129
- #echo "ls /usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble"
116
+ # Don't rely on the environment's version of python
117
+ - uses: actions/setup-python@v4
118
+ with:
119
+ python-version: '3.10'
120
+ - run: pip install docassemblecli
121
+ shell: bash
122
+ # Install the current directory into docassemble
123
+ - run: dainstall . --apiurl http://localhost --apikey $DA_ADMIN_API_KEY
130
124
  shell: bash
131
125
 
132
- - name: Docker logs
126
+ # Upload artifacts that subscribers can download on the Actions summary page
127
+ - name: "ALKiln github_server: Docker logs"
133
128
  if: ${{ always() }}
134
- # TODO: create an arifact for this instead
135
129
  run: |
136
- docker logs $(docker ps --filter "ancestor=jhpyle/docassemble" --format {{.ID}})
130
+ docker_logs=$(docker logs $(docker ps --filter "ancestor=jhpyle/docassemble" --format {{.ID}}))
131
+ # Should this name have a date/time attached? The logs themselves have timestamps
132
+ echo "$docker_logs" > /tmp/alkiln_docker_logs.txt
137
133
  shell: bash
134
+
135
+ # Should this date/time be created at the start of this action?
136
+ - name: "ALKiln github_server: Get folder name with date and time"
137
+ if: ${{ always() }}
138
+ run: |
139
+ echo "GITHUB_SERVER_ARTIFACT_NAME=alkiln-github-server-$(date +'%Y-%m-%d at %Hh%Mm%Ss' -u)UTC" >> $GITHUB_ENV
140
+ shell: bash
141
+ - name: "ALKiln github_server: Upload artifacts folder"
142
+ if: ${{ always() }}
143
+ uses: actions/upload-artifact@v3
144
+ with:
145
+ name: ${{ env.GITHUB_SERVER_ARTIFACT_NAME }}
146
+ path: /tmp/alkiln_docker_logs.txt
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+
3
+ //const da_i = require('./docassemble_api_interface');
4
+ const session_vars = require('../utils/session_vars');
5
+
6
+ const server_install = async () => {
7
+ // let task_id = await da_i.install_on_server();
8
+ // if (task_id) {
9
+ // console.log("Waiting...")
10
+ // await da_i.wait_for_package_to_restart(task_id);
11
+ // }
12
+ // console.log("Done!")
13
+
14
+ session_vars.save_install_type("server");
15
+
16
+ }; // Ends server_install();
17
+
18
+ server_install();
package/lib/scope.js CHANGED
@@ -759,8 +759,6 @@ module.exports = {
759
759
 
760
760
  if ( !scope.page ) { scope.page = await scope.browser.newPage(); }
761
761
 
762
- console.log(`interview_url:`, interview_url);
763
-
764
762
  // TODO: implement and use scope.handle_possible_timeout()
765
763
  try {
766
764
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "5.0.2-feat-github-server-10",
3
+ "version": "5.0.2-feat-github-server-12",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -9,7 +9,7 @@
9
9
  "local": "npm run setup && npm run cucumber; npm run takedown",
10
10
  "setup": "./lib/docassemble/setup.js",
11
11
  "takedown": "./lib/docassemble/takedown.js",
12
- "startserver": "./lib/docassemble/startserver.js",
12
+ "server_install": "./lib/docassemble/server_install.js",
13
13
  "unit": "mocha tests/unit_tests/*.test.*"
14
14
  },
15
15
  "repository": {
@@ -48,7 +48,7 @@
48
48
  "uuid": "8.3.2"
49
49
  },
50
50
  "bin": {
51
- "alkiln-startserver": "./lib/docassemble/startserver.js",
51
+ "alkiln-server-install": "./lib/docassemble/server_install.js",
52
52
  "alkiln-setup": "./lib/docassemble/setup.js",
53
53
  "alkiln-takedown": "./lib/docassemble/takedown.js",
54
54
  "alkiln-run": "./lib/run_cucumber.js"
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env node
2
- const puppeteer = require('puppeteer');
3
- const da_i = require('./docassemble_api_interface');
4
- const session_vars = require('../utils/session_vars');
5
-
6
- const fs = require('fs')
7
-
8
- const startserver = async () => {
9
- // Open the browser, login with env var creds
10
- /*
11
- let browser = await puppeteer.launch({headless: !session_vars.get_debug()})
12
- let page = await browser.newPage();
13
- // Go to the sign in page
14
- let login_url = `${ session_vars.get_da_server_url() }/user/sign-in`;
15
- try {
16
- // puppeteer will ensure proper timeout.
17
- await page.goto( login_url, { waitUntil: `domcontentloaded`, timeout: 3000 });
18
- await page.waitForSelector( `.dabody` );
19
- } catch ( error ) {
20
- let err_msg = `Error occurred when ALKiln tried to go to "${ login_url }: ${ error }".`
21
- console.log(err_msg);
22
- throw error;
23
- }
24
-
25
- let email = process.env[ "DA_ADMIN_API_KEY" ];
26
- let password = process.env[ "USER_PASSWORD" ];
27
-
28
- // Try to log in
29
- await page.type( `#email`, email );
30
- await page.type( `#password`, password );
31
- let elem = await page.$( `button[name="submit"]` );
32
- await elem.click();
33
- await page.waitForNavigation({waitUntil: 'domcontentloaded'});
34
-
35
- // Wait to see the success message.
36
- // This is a bit of an assumption and needs success and failure testing
37
- // TODO: use a Promise.race to fail faster.
38
- await page.waitForSelector( `.datopcenter .alert-success` );
39
- // make an API key
40
-
41
- // TODO(brycew): with or without the API key?
42
- // Install the package in order to also install all of its dependencies
43
- let api_key_url = `${ session_vars.get_da_server_url() }/manage_api?action=new`;
44
- await page.goto( api_key_url, { waitUntil: `domcontentloaded`, timeout: 3000 });
45
- await page.type( `#name`, "ALKiln tmp key");
46
- await page.select( `#method`, "none");
47
- let winner = await Promise.all([page.click(`#submit`), page.waitForNavigation({waitUntil: 'domcontentloaded'})]);
48
- console.log(`submitted`);
49
- const api_text = await page.$eval('body p code', elem => elem.innerText);
50
- process.env.DOCASSEMBLE_DEVELOPER_API_KEY = api_text;
51
- console.log(`api key: ${api_text}`);
52
- let file = fs.writeFileSync( ".tmpenv", `export DOCASSEMBLE_DEVELOPER_API_KEY=${api_text}`);
53
-
54
- await page.goto(`${ session_vars.get_da_server_url() }/user/sign-out`, {waitUntil: `domcontentloaded`});
55
- console.log(`signed out`);
56
- await browser.close();
57
- */
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!")
65
- session_vars.save_install_type("server");
66
-
67
- }; // Ends startserver();
68
-
69
- startserver();