@suffolklitlab/alkiln 5.0.2-feat-github-server-1 → 5.0.2-feat-github-server-2
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:
|
|
25
|
-
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:
|
|
33
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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-2"
|
|
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
|
-
#
|
|
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
|
|
67
|
-
|
|
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
|
-
|
|
72
|
-
|
|
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
|
|
package/github_server/action.yml
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
name: "ALKiln/github_server: Isolated docassemble tests"
|
|
2
|
-
description: "
|
|
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
|
-
|
|
10
|
-
|
|
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:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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:
|
|
@@ -30,27 +27,56 @@ runs:
|
|
|
30
27
|
run: |
|
|
31
28
|
echo "DA_ADMIN_API_KEY=abcd1234abcd1234abcd5678abdc5678" >> $GITHUB_ENV
|
|
32
29
|
shell: bash
|
|
30
|
+
- id: api_key_output_step
|
|
31
|
+
run: echo "::set-output name=DOCASSEMBLE_DEVELOPER_API_KEY::$DA_ADMIN_API_KEY"
|
|
32
|
+
shell: bash
|
|
33
33
|
- name: "github_server: Download and start docker"
|
|
34
34
|
run: |
|
|
35
35
|
mkdir /tmp/config
|
|
36
|
-
echo "$CONFIG_CONTENTS" > /tmp/config/myconfig.yml
|
|
37
|
-
docker pull
|
|
36
|
+
echo "${{ inputs.CONFIG_CONTENTS }}" > /tmp/config/myconfig.yml
|
|
37
|
+
docker pull jhpyle/docassemble
|
|
38
38
|
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
39
|
shell: bash
|
|
44
|
-
- name: "github_server:
|
|
45
|
-
run:
|
|
40
|
+
- name: "github_server: Wait for server to start"
|
|
41
|
+
run: |
|
|
42
|
+
# github_server: Wait for server to start
|
|
43
|
+
|
|
44
|
+
# Wait 1 minute before pinging the server constantly
|
|
45
|
+
sleep 60
|
|
46
|
+
|
|
47
|
+
# Use a variable we can control to avoid race conditions from
|
|
48
|
+
# preventing the success log message.
|
|
49
|
+
ready="false"
|
|
50
|
+
# Reset the SECONDS variable
|
|
51
|
+
SECONDS=60
|
|
52
|
+
|
|
53
|
+
while [[ $ready == "false" ]]; do
|
|
54
|
+
echo "Time ellapsed: $SECONDS seconds"
|
|
55
|
+
|
|
56
|
+
# Get input for max number of seconds to wait
|
|
57
|
+
# ${{ inputs.MAX_SECONDS_FOR_DOCKER }} as a number? Bash doesn't have types, just strings
|
|
58
|
+
# Check if max seconds till loading has passed
|
|
59
|
+
if [[ $SECONDS -ge 600 ]]; then
|
|
60
|
+
echo "Error: Timed out waiting for docker container to serve the site."
|
|
61
|
+
break
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# Set the variable to a new string value in each iteration
|
|
65
|
+
result=$(curl -s localhost)
|
|
66
|
+
|
|
67
|
+
# Check if the string includes the desired text
|
|
68
|
+
if [[ ! $result == *"Docassemble is starting"* ]]; then
|
|
69
|
+
echo "Success! The docker container is ready!"
|
|
70
|
+
ready="true"
|
|
71
|
+
else
|
|
72
|
+
echo "The docker container isn't ready yet. Will check again in 30 seconds."
|
|
73
|
+
sleep 30
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
done
|
|
46
77
|
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
78
|
- name: Docker logs
|
|
79
|
+
if: ${{ always() }}
|
|
54
80
|
# TODO: create an arifact for this instead
|
|
55
81
|
run: |
|
|
56
82
|
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("-", ".")}%
|
|
16
|
+
let x = `${ server_url }/interview?new_session=1&i=${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