@suffolklitlab/alkiln 5.0.2-feat-github-server-11 → 5.0.2-feat-github-server-13
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/.github/workflows/github_server.yml +20 -11
- package/action.yml +3 -9
- package/github_server/action.yml +32 -36
- package/lib/docassemble/docassemble_api_REST.js +0 -16
- package/lib/docassemble/docassemble_api_interface.js +0 -21
- package/lib/docassemble/server_install.js +0 -9
- package/lib/scope.js +0 -2
- package/package.json +1 -1
|
@@ -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:
|
|
19
|
+
default: false
|
|
20
20
|
# TODO: alkiln_version:
|
|
21
21
|
|
|
22
22
|
jobs:
|
|
@@ -28,16 +28,18 @@ jobs:
|
|
|
28
28
|
node-version: [18.x]
|
|
29
29
|
|
|
30
30
|
env:
|
|
31
|
-
# USER1_EMAIL: admin@example.com
|
|
32
|
-
# USER1_PASSWORD: "@12lsdnejewng"
|
|
33
31
|
# How would a dev make another user/password if they wanted to?
|
|
34
32
|
SECRET_VAR1: secret-var1-value
|
|
35
33
|
SECRET_VAR2: secret-var2-value
|
|
36
34
|
SECRET_FOR_MISSING_FIELD: secret for missing field
|
|
37
|
-
_ALKILN_DANGEROUS_DEBUG: true
|
|
35
|
+
#_ALKILN_DANGEROUS_DEBUG: true
|
|
38
36
|
|
|
39
37
|
steps:
|
|
38
|
+
# Place the root directory in this branch
|
|
40
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.
|
|
41
43
|
- name: Setup tmate session
|
|
42
44
|
if: ${{ inputs.enable_tmate }}
|
|
43
45
|
uses: mxschmitt/action-tmate@v3
|
|
@@ -51,15 +53,22 @@ jobs:
|
|
|
51
53
|
CONFIG_CONTENTS: "${{ secrets.CONFIG_CONTENTS }}"
|
|
52
54
|
- run: echo "Finished starting the GitHub server"
|
|
53
55
|
|
|
54
|
-
|
|
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: Env vars from server output
|
|
55
63
|
run: |
|
|
56
64
|
echo "USER1_EMAIL=${{ steps.github_server.outputs.DA_ADMIN_EMAIL }}" >> $GITHUB_ENV
|
|
57
65
|
echo "USER1_PASSWORD=${{ steps.github_server.outputs.DA_ADMIN_PASSWORD }}" >> $GITHUB_ENV
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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"
|
|
63
72
|
|
|
64
73
|
- name: "Run ALKiln tests"
|
|
65
74
|
if: ${{ success() }}
|
|
@@ -69,6 +78,6 @@ jobs:
|
|
|
69
78
|
DOCASSEMBLE_DEVELOPER_API_KEY: "${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}"
|
|
70
79
|
INSTALL_METHOD: "server"
|
|
71
80
|
# TODO: See what happens if this is an empty string
|
|
72
|
-
ALKILN_VERSION: "5.0.2-feat-github-server-
|
|
81
|
+
ALKILN_VERSION: "5.0.2-feat-github-server-13"
|
|
73
82
|
- run: echo "Finished running ALKiln tests"
|
|
74
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
|
|
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
|
|
@@ -81,17 +81,11 @@ runs:
|
|
|
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
|
-
|
|
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
|
#
|
package/github_server/action.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
#
|
|
4
|
+
# Bug? Race condition? Exit with 52 when waiting for container to finish starting
|
|
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
|
|
@@ -12,6 +12,16 @@ description: "Download and start up a temporary docassemble server on GitHub's s
|
|
|
12
12
|
# 120 sec with exit code 56:
|
|
13
13
|
# https://github.com/SuffolkLITLab/ALKiln/actions/runs/5914963614/job/16040773624#step:4:206
|
|
14
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
|
|
24
|
+
|
|
15
25
|
inputs:
|
|
16
26
|
CONFIG_CONTENTS:
|
|
17
27
|
description: "The contents of the config file of the docassemble server"
|
|
@@ -37,23 +47,23 @@ outputs:
|
|
|
37
47
|
runs:
|
|
38
48
|
using: "composite"
|
|
39
49
|
steps:
|
|
50
|
+
- uses: actions/checkout@v3
|
|
51
|
+
|
|
40
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
|
|
44
|
-
echo "CLONE_URL=${{ github.server_url }}/${{ github.repository }}.git" >> $GITHUB_ENV
|
|
45
|
-
echo "OWNER_AND_REPO_NAME=${{ github.repository }}" >> $GITHUB_ENV
|
|
46
|
-
echo "BRANCH_REF=${{ github.ref }}" >> $GITHUB_ENV
|
|
47
56
|
echo "DA_ADMIN_EMAIL=admin@example.com" >> $GITHUB_ENV
|
|
48
57
|
# Login will fail if this is "password"
|
|
49
58
|
echo "DA_ADMIN_PASSWORD=@123abcdefg" >> $GITHUB_ENV
|
|
50
59
|
shell: bash
|
|
51
60
|
- id: api_key_output_step
|
|
52
61
|
run: |
|
|
53
|
-
echo "
|
|
54
|
-
echo "
|
|
55
|
-
echo "
|
|
62
|
+
echo "DOCASSEMBLE_DEVELOPER_API_KEY=$DA_ADMIN_API_KEY" >> "$GITHUB_OUTPUT"
|
|
63
|
+
echo "DA_ADMIN_EMAIL=$DA_ADMIN_EMAIL" >> "$GITHUB_OUTPUT"
|
|
64
|
+
echo "DA_ADMIN_PASSWORD=$DA_ADMIN_PASSWORD" >> "$GITHUB_OUTPUT"
|
|
56
65
|
shell: bash
|
|
66
|
+
|
|
57
67
|
- name: "ALKiln github_server: Download and start docker"
|
|
58
68
|
run: |
|
|
59
69
|
mkdir /tmp/config
|
|
@@ -63,33 +73,33 @@ runs:
|
|
|
63
73
|
shell: bash
|
|
64
74
|
- name: "ALKiln github_server: Wait for server to start"
|
|
65
75
|
run: |
|
|
66
|
-
# github_server: Wait for server to start
|
|
76
|
+
# ALKiln github_server: Wait for server to start
|
|
67
77
|
|
|
68
78
|
# Reset the SECONDS variable
|
|
69
79
|
SECONDS=0
|
|
70
80
|
# Wait 1 minute before pinging the server constantly
|
|
71
81
|
sleep 60
|
|
72
82
|
|
|
73
|
-
# Use a variable instead of checking $
|
|
83
|
+
# Use a variable instead of checking $response so we can control to avoid race
|
|
74
84
|
# conditions from preventing the success log message.
|
|
75
85
|
ready="false"
|
|
76
86
|
|
|
77
87
|
while [[ $ready == "false" ]]; do
|
|
78
88
|
echo "Time ellapsed: $SECONDS seconds"
|
|
79
89
|
|
|
80
|
-
# Get input for max number of seconds to wait
|
|
81
|
-
# ${{ inputs.MAX_SECONDS_FOR_DOCKER }} as a number? Bash doesn't have types, just strings
|
|
82
90
|
# Check if max seconds till loading has passed
|
|
83
91
|
if [[ $SECONDS -ge $MAX_SECONDS_FOR_DOCKER ]]; then
|
|
84
92
|
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."
|
|
93
|
+
# Exit with failure, or allow this to keep going?
|
|
85
94
|
break
|
|
86
95
|
fi
|
|
87
96
|
|
|
88
97
|
# Set the variable to a new string value in each iteration
|
|
89
|
-
|
|
98
|
+
response=$(curl -o /dev/null -s -w "%{http_code}\n" http://localhost:80/health_check?ready=1)
|
|
99
|
+
echo "response is $response"
|
|
90
100
|
|
|
91
101
|
# Check if the string includes the desired text
|
|
92
|
-
if [[
|
|
102
|
+
if [[ $response == *"200"* ]]; then
|
|
93
103
|
echo "Success! The docker container is ready!"
|
|
94
104
|
ready="true"
|
|
95
105
|
else
|
|
@@ -100,29 +110,14 @@ runs:
|
|
|
100
110
|
done
|
|
101
111
|
shell: bash
|
|
102
112
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
repo_name=${repo_parts[-1]}
|
|
112
|
-
echo "repo_name is $repo_name"
|
|
113
|
-
cd $repo_name
|
|
114
|
-
|
|
115
|
-
echo "BRANCH_REF is $BRANCH_REF"
|
|
116
|
-
ref_name=$BRANCH_REF
|
|
117
|
-
branch_name="${ref_name#refs/heads/}"
|
|
118
|
-
echo "branch name is $branch_name"
|
|
119
|
-
git checkout -b $branch_name
|
|
120
|
-
git fetch origin $branch_name
|
|
121
|
-
git reset --hard origin/$branch_name
|
|
122
|
-
|
|
123
|
-
cd ..
|
|
124
|
-
pip install docassemblecli
|
|
125
|
-
dainstall $repo_name --apiurl http://localhost --apikey $DA_ADMIN_API_KEY
|
|
113
|
+
# Don't rely on the environment's version of python
|
|
114
|
+
- uses: actions/setup-python@v4
|
|
115
|
+
with:
|
|
116
|
+
python-version: '3.10'
|
|
117
|
+
- run: pip install docassemblecli
|
|
118
|
+
shell: bash
|
|
119
|
+
# Install the current directory into docassemble
|
|
120
|
+
- run: dainstall . --apiurl http://localhost --apikey $DA_ADMIN_API_KEY
|
|
126
121
|
shell: bash
|
|
127
122
|
|
|
128
123
|
# Upload artifacts that subscribers can download on the Actions summary page
|
|
@@ -136,6 +131,7 @@ runs:
|
|
|
136
131
|
|
|
137
132
|
# Should this date/time be created at the start of this action?
|
|
138
133
|
- name: "ALKiln github_server: Get folder name with date and time"
|
|
134
|
+
if: ${{ always() }}
|
|
139
135
|
run: |
|
|
140
136
|
echo "GITHUB_SERVER_ARTIFACT_NAME=alkiln-github-server-$(date +'%Y-%m-%d at %Hh%Mm%Ss' -u)UTC" >> $GITHUB_ENV
|
|
141
137
|
shell: bash
|
|
@@ -54,22 +54,6 @@ da.create_project = async function ( project_name, timeout ) {
|
|
|
54
54
|
}
|
|
55
55
|
}; // Ends da.create_project()
|
|
56
56
|
|
|
57
|
-
da.install_on_server = async function ( github_repo, branch_name, timeout ) {
|
|
58
|
-
let options = {
|
|
59
|
-
method: 'POST',
|
|
60
|
-
url: `${ session_vars.get_da_server_url() }/api/package`,
|
|
61
|
-
data: qs.stringify( {
|
|
62
|
-
key: session_vars.get_dev_api_key(),
|
|
63
|
-
github_url: github_repo,
|
|
64
|
-
branch: branch_name
|
|
65
|
-
}),
|
|
66
|
-
timeout: timeout,
|
|
67
|
-
};
|
|
68
|
-
console.log("%o", options);
|
|
69
|
-
|
|
70
|
-
return await axios.request(options);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
57
|
|
|
74
58
|
// node -e 'require("./lib/docassemble/docassemble_api_REST.js").pull()'
|
|
75
59
|
da.pull = async function ( timeout ) {
|
|
@@ -329,27 +329,6 @@ da_i.pull = async function ( pull_options ) {
|
|
|
329
329
|
}
|
|
330
330
|
}; // Ends da_i.pull()
|
|
331
331
|
|
|
332
|
-
|
|
333
|
-
da_i.install_on_server = async function ( install_options ) {
|
|
334
|
-
let { timeout } = install_options || { timeout: DEFAULT_MAX_REQUEST_MS };
|
|
335
|
-
|
|
336
|
-
try {
|
|
337
|
-
let response = await _da_REST.install_on_server(
|
|
338
|
-
session_vars.get_repo_url(),
|
|
339
|
-
session_vars.get_branch_name(),
|
|
340
|
-
timeout
|
|
341
|
-
);
|
|
342
|
-
if ( response && response.status === 200 ) {
|
|
343
|
-
log.debug({ pre: `install task id: ${ response.data.task_id }` });
|
|
344
|
-
return response.data.task_id;
|
|
345
|
-
}
|
|
346
|
-
return null;
|
|
347
|
-
} catch (error ) {
|
|
348
|
-
log.error({ pre: `Installing on the docassemble serve ran into an unexpected error.`, data: error.toJSON()});
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
};
|
|
352
|
-
|
|
353
332
|
// node -e 'require("./lib/docassemble/docassemble_api_interface.js").has_task_finished()'
|
|
354
333
|
da_i.has_task_finished = async function ( api_endpoint, task_id, options ) {
|
|
355
334
|
/** Check task status if it exists. If not, return true as task did
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
//const da_i = require('./docassemble_api_interface');
|
|
4
3
|
const session_vars = require('../utils/session_vars');
|
|
5
4
|
|
|
6
5
|
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
6
|
session_vars.save_install_type("server");
|
|
15
|
-
|
|
16
7
|
}; // Ends server_install();
|
|
17
8
|
|
|
18
9
|
server_install();
|
package/lib/scope.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suffolklitlab/alkiln",
|
|
3
|
-
"version": "5.0.2-feat-github-server-
|
|
3
|
+
"version": "5.0.2-feat-github-server-13",
|
|
4
4
|
"description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|